|
faluco@1541
|
1 |
/** |
|
faluco@1541
|
2 |
* vim: set ts=4 : |
|
faluco@1541
|
3 |
* ============================================================================= |
|
faluco@1541
|
4 |
* SourceMod |
|
ds@1947
|
5 |
* Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved. |
|
faluco@1541
|
6 |
* ============================================================================= |
|
faluco@1541
|
7 |
* |
|
faluco@1541
|
8 |
* This program is free software; you can redistribute it and/or modify it under |
|
faluco@1541
|
9 |
* the terms of the GNU General Public License, version 3.0, as published by the |
|
faluco@1541
|
10 |
* Free Software Foundation. |
|
faluco@1541
|
11 |
* |
|
faluco@1541
|
12 |
* This program is distributed in the hope that it will be useful, but WITHOUT |
|
faluco@1541
|
13 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
|
faluco@1541
|
14 |
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more |
|
faluco@1541
|
15 |
* details. |
|
faluco@1541
|
16 |
* |
|
faluco@1541
|
17 |
* You should have received a copy of the GNU General Public License along with |
|
faluco@1541
|
18 |
* this program. If not, see <http://www.gnu.org/licenses/>. |
|
faluco@1541
|
19 |
* |
|
faluco@1541
|
20 |
* As a special exception, AlliedModders LLC gives you permission to link the |
|
faluco@1541
|
21 |
* code of this program (as well as its derivative works) to "Half-Life 2," the |
|
faluco@1541
|
22 |
* "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software |
|
faluco@1541
|
23 |
* by the Valve Corporation. You must obey the GNU General Public License in |
|
faluco@1541
|
24 |
* all respects for all other code used. Additionally, AlliedModders LLC grants |
|
faluco@1541
|
25 |
* this exception to all derivative works. AlliedModders LLC defines further |
|
faluco@1541
|
26 |
* exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007), |
|
faluco@1541
|
27 |
* or <http://www.sourcemod.net/license.php>. |
|
faluco@1541
|
28 |
* |
|
faluco@1541
|
29 |
* Version: $Id$ |
|
faluco@1541
|
30 |
*/ |
|
faluco@1541
|
31 |
|
|
faluco@1541
|
32 |
#ifndef _INCLUDE_SOURCEMOD_COMPAT_WRAPPERS_H_ |
|
faluco@1541
|
33 |
#define _INCLUDE_SOURCEMOD_COMPAT_WRAPPERS_H_ |
|
faluco@1541
|
34 |
|
|
ds@2400
|
35 |
#if SOURCE_ENGINE >= SE_ORANGEBOX |
|
faluco@1541
|
36 |
#define CONVAR_REGISTER(object) ConVar_Register(0, object) |
|
faluco@1541
|
37 |
|
|
faluco@1541
|
38 |
inline bool IsFlagSet(ConCommandBase *cmd, int flag) |
|
faluco@1541
|
39 |
{ |
|
faluco@1541
|
40 |
return cmd->IsFlagSet(flag); |
|
faluco@1541
|
41 |
} |
|
faluco@1541
|
42 |
inline void InsertServerCommand(const char *buf) |
|
faluco@1541
|
43 |
{ |
|
dvander@1731
|
44 |
engine->InsertServerCommand(buf); |
|
faluco@1541
|
45 |
} |
|
ds@2400
|
46 |
inline ConCommandBase *FindCommandBase(const char *name) |
|
ds@2400
|
47 |
{ |
|
ds@2400
|
48 |
return icvar->FindCommandBase(name); |
|
ds@2400
|
49 |
} |
|
ds@2400
|
50 |
inline ConCommand *FindCommand(const char *name) |
|
ds@2400
|
51 |
{ |
|
ds@2400
|
52 |
return icvar->FindCommand(name); |
|
ds@2400
|
53 |
} |
|
faluco@1541
|
54 |
#else |
|
faluco@1541
|
55 |
class CCommand |
|
faluco@1541
|
56 |
{ |
|
faluco@1541
|
57 |
public: |
|
faluco@1541
|
58 |
inline const char *ArgS() const |
|
faluco@1541
|
59 |
{ |
|
faluco@1541
|
60 |
return engine->Cmd_Args(); |
|
faluco@1541
|
61 |
} |
|
faluco@1541
|
62 |
inline int ArgC() const |
|
faluco@1541
|
63 |
{ |
|
faluco@1541
|
64 |
return engine->Cmd_Argc(); |
|
faluco@1541
|
65 |
} |
|
faluco@1541
|
66 |
inline const char *Arg(int index) const |
|
faluco@1541
|
67 |
{ |
|
faluco@1541
|
68 |
return engine->Cmd_Argv(index); |
|
faluco@1541
|
69 |
} |
|
faluco@1541
|
70 |
}; |
|
faluco@1541
|
71 |
|
|
faluco@1541
|
72 |
inline bool IsFlagSet(ConCommandBase *cmd, int flag) |
|
faluco@1541
|
73 |
{ |
|
faluco@1541
|
74 |
return cmd->IsBitSet(flag); |
|
faluco@1541
|
75 |
} |
|
faluco@1541
|
76 |
inline void InsertServerCommand(const char *buf) |
|
faluco@1541
|
77 |
{ |
|
faluco@1541
|
78 |
engine->InsertServerCommand(buf); |
|
faluco@1541
|
79 |
} |
|
ds@2400
|
80 |
inline ConCommandBase *FindCommandBase(const char *name) |
|
ds@2400
|
81 |
{ |
|
ds@2400
|
82 |
ConCommandBase *pBase = icvar->GetCommands(); |
|
ds@2400
|
83 |
while (pBase) |
|
ds@2400
|
84 |
{ |
|
ds@2400
|
85 |
if (strcmp(pBase->GetName(), name) == 0) |
|
ds@2400
|
86 |
{ |
|
ds@2400
|
87 |
if (pBase->IsCommand()) |
|
ds@2400
|
88 |
{ |
|
ds@2400
|
89 |
return NULL; |
|
ds@2400
|
90 |
} |
|
ds@2400
|
91 |
|
|
ds@2400
|
92 |
return pBase; |
|
ds@2400
|
93 |
} |
|
ds@2400
|
94 |
pBase = const_cast<ConCommandBase *>(pBase->GetNext()); |
|
ds@2400
|
95 |
} |
|
ds@2400
|
96 |
return NULL; |
|
ds@2400
|
97 |
} |
|
ds@2400
|
98 |
inline ConCommand *FindCommand(const char *name) |
|
ds@2400
|
99 |
{ |
|
ds@2400
|
100 |
ConCommandBase *pBase = icvar->GetCommands(); |
|
ds@2400
|
101 |
while (pBase) |
|
ds@2400
|
102 |
{ |
|
ds@2400
|
103 |
if (strcmp(pBase->GetName(), name) == 0) |
|
ds@2400
|
104 |
{ |
|
ds@2400
|
105 |
if (!pBase->IsCommand()) |
|
ds@2400
|
106 |
{ |
|
ds@2400
|
107 |
return NULL; |
|
ds@2400
|
108 |
} |
|
ds@2400
|
109 |
|
|
ds@2400
|
110 |
return static_cast<ConCommand *>(pBase); |
|
ds@2400
|
111 |
} |
|
ds@2400
|
112 |
pBase = const_cast<ConCommandBase *>(pBase->GetNext()); |
|
ds@2400
|
113 |
} |
|
ds@2400
|
114 |
return NULL; |
|
ds@2400
|
115 |
} |
|
faluco@1541
|
116 |
|
|
dvander@1545
|
117 |
#define CVAR_INTERFACE_VERSION VENGINE_CVAR_INTERFACE_VERSION |
|
dvander@1545
|
118 |
|
|
faluco@1541
|
119 |
#define CONVAR_REGISTER(object) ConCommandBaseMgr::OneTimeInit(object) |
|
faluco@1541
|
120 |
typedef FnChangeCallback FnChangeCallback_t; |
|
ds@2400
|
121 |
#endif //SOURCE_ENGINE >= SE_ORANGEBOX |
|
ds@2400
|
122 |
|
|
ds@2400
|
123 |
#if SOURCE_ENGINE >= SE_LEFT4DEAD |
|
ds@2400
|
124 |
inline int IndexOfEdict(const edict_t *pEdict) |
|
ds@2400
|
125 |
{ |
|
ds@2403
|
126 |
return (int)(pEdict - gpGlobals->baseEdict); |
|
ds@2400
|
127 |
} |
|
ds@2400
|
128 |
inline edict_t *PEntityOfEntIndex(int iEntIndex) |
|
ds@2400
|
129 |
{ |
|
ds@2400
|
130 |
if (iEntIndex >= 0 && iEntIndex < gpGlobals->maxEntities) |
|
ds@2400
|
131 |
{ |
|
ds@2403
|
132 |
return (edict_t *)(gpGlobals->baseEdict + iEntIndex); |
|
ds@2400
|
133 |
} |
|
ds@2400
|
134 |
return NULL; |
|
ds@2400
|
135 |
} |
|
ds@2400
|
136 |
#else |
|
ds@2400
|
137 |
inline int IndexOfEdict(const edict_t *pEdict) |
|
ds@2400
|
138 |
{ |
|
ds@2400
|
139 |
return engine->IndexOfEdict(pEdict); |
|
ds@2400
|
140 |
} |
|
ds@2400
|
141 |
inline edict_t *PEntityOfEntIndex(int iEntIndex) |
|
ds@2400
|
142 |
{ |
|
ds@2400
|
143 |
return engine->PEntityOfEntIndex(iEntIndex); |
|
ds@2400
|
144 |
} |
|
ds@2400
|
145 |
#endif //SOURCE_ENGINE >= SE_LEFT4DEAD |
|
faluco@1541
|
146 |
|
|
faluco@1541
|
147 |
#endif //_INCLUDE_SOURCEMOD_COMPAT_WRAPPERS_H_ |