00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032 #ifndef _INCLUDE_SOURCEMOD_COMPAT_WRAPPERS_H_
00033 #define _INCLUDE_SOURCEMOD_COMPAT_WRAPPERS_H_
00034
00035 #include <datamap.h>
00036
00037 #if SOURCE_ENGINE >= SE_ORANGEBOX
00038 #define CONVAR_REGISTER(object) ConVar_Register(0, object)
00039
00040 inline bool IsFlagSet(ConCommandBase *cmd, int flag)
00041 {
00042 return cmd->IsFlagSet(flag);
00043 }
00044 inline void InsertServerCommand(const char *buf)
00045 {
00046 engine->InsertServerCommand(buf);
00047 }
00048 inline ConCommandBase *FindCommandBase(const char *name)
00049 {
00050 return icvar->FindCommandBase(name);
00051 }
00052 inline ConCommand *FindCommand(const char *name)
00053 {
00054 return icvar->FindCommand(name);
00055 }
00056 #else
00057 class CCommand
00058 {
00059 public:
00060 inline const char *ArgS() const
00061 {
00062 return engine->Cmd_Args();
00063 }
00064 inline int ArgC() const
00065 {
00066 return engine->Cmd_Argc();
00067 }
00068 inline const char *Arg(int index) const
00069 {
00070 return engine->Cmd_Argv(index);
00071 }
00072 };
00073
00074 inline bool IsFlagSet(ConCommandBase *cmd, int flag)
00075 {
00076 return cmd->IsBitSet(flag);
00077 }
00078 inline void InsertServerCommand(const char *buf)
00079 {
00080 engine->InsertServerCommand(buf);
00081 }
00082 inline ConCommandBase *FindCommandBase(const char *name)
00083 {
00084 ConCommandBase *pBase = icvar->GetCommands();
00085 while (pBase)
00086 {
00087 if (strcmp(pBase->GetName(), name) == 0)
00088 {
00089 if (!pBase->IsCommand())
00090 {
00091 return NULL;
00092 }
00093
00094 return pBase;
00095 }
00096 pBase = const_cast<ConCommandBase *>(pBase->GetNext());
00097 }
00098 return NULL;
00099 }
00100 inline ConCommand *FindCommand(const char *name)
00101 {
00102 ConCommandBase *pBase = icvar->GetCommands();
00103 while (pBase)
00104 {
00105 if (strcmp(pBase->GetName(), name) == 0)
00106 {
00107 if (!pBase->IsCommand())
00108 {
00109 return NULL;
00110 }
00111
00112 return static_cast<ConCommand *>(pBase);
00113 }
00114 pBase = const_cast<ConCommandBase *>(pBase->GetNext());
00115 }
00116 return NULL;
00117 }
00118
00119 #define CVAR_INTERFACE_VERSION VENGINE_CVAR_INTERFACE_VERSION
00120
00121 #define CONVAR_REGISTER(object) ConCommandBaseMgr::OneTimeInit(object)
00122 typedef FnChangeCallback FnChangeCallback_t;
00123 #endif //SOURCE_ENGINE >= SE_ORANGEBOX
00124
00125 #if SOURCE_ENGINE >= SE_LEFT4DEAD
00126 inline int IndexOfEdict(const edict_t *pEdict)
00127 {
00128 return (int)(pEdict - gpGlobals->pEdicts);
00129 }
00130 inline edict_t *PEntityOfEntIndex(int iEntIndex)
00131 {
00132 if (iEntIndex >= 0 && iEntIndex < gpGlobals->maxEntities)
00133 {
00134 return (edict_t *)(gpGlobals->pEdicts + iEntIndex);
00135 }
00136 return NULL;
00137 }
00138 inline int GetTypeDescOffs(typedescription_t *td)
00139 {
00140 return td->fieldOffset;
00141 }
00142 #else
00143 inline int IndexOfEdict(const edict_t *pEdict)
00144 {
00145 return engine->IndexOfEdict(pEdict);
00146 }
00147 inline edict_t *PEntityOfEntIndex(int iEntIndex)
00148 {
00149 return engine->PEntityOfEntIndex(iEntIndex);
00150 }
00151 inline int GetTypeDescOffs(typedescription_t *td)
00152 {
00153 return td->fieldOffset[TD_OFFSET_NORMAL];
00154 }
00155 #endif //SOURCE_ENGINE >= SE_LEFT4DEAD
00156
00157 #endif //_INCLUDE_SOURCEMOD_COMPAT_WRAPPERS_H_