1.1 --- a/extensions/sdktools/extension.cpp Sun Jul 08 09:34:20 2007 +0000
1.2 +++ b/extensions/sdktools/extension.cpp Sun Jul 08 09:46:27 2007 +0000
1.3 @@ -25,6 +25,7 @@
1.4 #include "vcallbuilder.h"
1.5 #include "vnatives.h"
1.6 #include "tempents.h"
1.7 +#include "gamerules.h"
1.8
1.9 /**
1.10 * @file extension.cpp
1.11 @@ -102,7 +103,9 @@
1.12 void SDKTools::SDK_OnAllLoaded()
1.13 {
1.14 SM_GET_LATE_IFACE(BINTOOLS, g_pBinTools);
1.15 +
1.16 g_TEManager.Initialize();
1.17 + InitializeGameRules();
1.18 }
1.19
1.20 bool SDKTools::QueryRunning(char *error, size_t maxlength)
2.1 --- a/extensions/sdktools/msvc8/sdktools.vcproj Sun Jul 08 09:34:20 2007 +0000
2.2 +++ b/extensions/sdktools/msvc8/sdktools.vcproj Sun Jul 08 09:46:27 2007 +0000
2.3 @@ -188,6 +188,10 @@
2.4 >
2.5 </File>
2.6 <File
2.7 + RelativePath="..\gamerules.cpp"
2.8 + >
2.9 + </File>
2.10 + <File
2.11 RelativePath="..\tempents.cpp"
2.12 >
2.13 </File>
2.14 @@ -230,6 +234,10 @@
2.15 >
2.16 </File>
2.17 <File
2.18 + RelativePath="..\gamerules.h"
2.19 + >
2.20 + </File>
2.21 + <File
2.22 RelativePath="..\tempents.h"
2.23 >
2.24 </File>
3.1 --- a/extensions/sdktools/vcallbuilder.cpp Sun Jul 08 09:34:20 2007 +0000
3.2 +++ b/extensions/sdktools/vcallbuilder.cpp Sun Jul 08 09:46:27 2007 +0000
3.3 @@ -80,6 +80,8 @@
3.4
3.5 ValveCall *vc = new ValveCall;
3.6
3.7 + vc->type = vcalltype;
3.8 +
3.9 size_t size = 0;
3.10 vc->stackSize = 0;
3.11
3.12 @@ -109,16 +111,24 @@
3.13 {
3.14 thisinfo = &thisbuf;
3.15 thisinfo->type = PassType_Basic;
3.16 - if (vcalltype == ValveCall_Entity)
3.17 + switch (vcalltype)
3.18 {
3.19 + case ValveCall_Entity:
3.20 thisinfo->vtype = Valve_CBaseEntity;
3.21 + thisinfo->flags = PASSFLAG_BYVAL;
3.22 thisinfo->decflags |= VDECODE_FLAG_ALLOWWORLD;
3.23 - } else if (vcalltype == ValveCall_Player) {
3.24 + break;
3.25 + case ValveCall_Player:
3.26 thisinfo->vtype = Valve_CBasePlayer;
3.27 + thisinfo->flags = PASSFLAG_BYVAL;
3.28 + thisinfo->decflags = 0;
3.29 + break;
3.30 + case ValveCall_GameRules:
3.31 + thisinfo->vtype = Valve_POD;
3.32 + thisinfo->flags = PASSFLAG_ASPOINTER;
3.33 thisinfo->decflags = 0;
3.34 }
3.35 thisinfo->encflags = 0;
3.36 - thisinfo->flags = PASSFLAG_BYVAL;
3.37 thisinfo->offset = 0;
3.38 vc->stackSize += sizeof(void *);
3.39 cv = CallConv_ThisCall;
3.40 @@ -227,6 +237,8 @@
3.41
3.42 ValveCall *vc = new ValveCall;
3.43
3.44 + vc->type = vcalltype;
3.45 +
3.46 size_t size = 0;
3.47 vc->stackSize = 0;
3.48
3.49 @@ -314,16 +326,25 @@
3.50 /* Save the this info for the dynamic decoder */
3.51 vc->thisinfo = &(vc->vparams[numParams + 1]);
3.52 vc->thisinfo->type = PassType_Basic;
3.53 - if (vcalltype == ValveCall_Entity)
3.54 + switch (vcalltype)
3.55 {
3.56 + case ValveCall_Entity:
3.57 vc->thisinfo->vtype = Valve_CBaseEntity;
3.58 + vc->thisinfo->flags = PASSFLAG_BYVAL;
3.59 vc->thisinfo->decflags = VDECODE_FLAG_ALLOWWORLD;
3.60 - } else if (vcalltype == ValveCall_Player) {
3.61 + break;
3.62 + case ValveCall_Player:
3.63 vc->thisinfo->vtype = Valve_CBasePlayer;
3.64 + vc->thisinfo->flags = PASSFLAG_BYVAL;
3.65 vc->thisinfo->decflags = 0;
3.66 + break;
3.67 + case ValveCall_GameRules:
3.68 + vc->thisinfo->vtype = Valve_POD;
3.69 + vc->thisinfo->flags = PASSFLAG_ASPOINTER;
3.70 + vc->thisinfo->decflags = 0;
3.71 + break;
3.72 }
3.73 vc->thisinfo->encflags = 0;
3.74 - vc->thisinfo->flags = PASSFLAG_BYVAL;
3.75 vc->thisinfo->offset = 0;
3.76 vc->thisinfo->obj_offset = 0;
3.77 normSize += sizeof(void *);
4.1 --- a/extensions/sdktools/vcallbuilder.h Sun Jul 08 09:34:20 2007 +0000
4.2 +++ b/extensions/sdktools/vcallbuilder.h Sun Jul 08 09:46:27 2007 +0000
4.3 @@ -37,6 +37,7 @@
4.4 struct ValveCall
4.5 {
4.6 ICallWrapper *call; /**< From IBinTools */
4.7 + ValveCallType type; /**< Call type */
4.8 ValvePassInfo *vparams; /**< Valve parameter info */
4.9 ValvePassInfo *retinfo; /**< Return buffer info */
4.10 ValvePassInfo *thisinfo; /**< Thiscall info */
5.1 --- a/extensions/sdktools/vcaller.cpp Sun Jul 08 09:34:20 2007 +0000
5.2 +++ b/extensions/sdktools/vcaller.cpp Sun Jul 08 09:46:27 2007 +0000
5.3 @@ -23,6 +23,7 @@
5.4
5.5 #include "extension.h"
5.6 #include "vcallbuilder.h"
5.7 +#include "gamerules.h"
5.8
5.9 enum SDKLibrary
5.10 {
5.11 @@ -245,25 +246,50 @@
5.12 unsigned int startparam = 2;
5.13 /* Do we need to write a thispointer? */
5.14
5.15 - if (vc->thisinfo &&
5.16 - (vc->thisinfo->vtype == Valve_CBaseEntity
5.17 - || vc->thisinfo->vtype == Valve_CBasePlayer))
5.18 + if (vc->thisinfo)
5.19 {
5.20 - if (startparam > numparams)
5.21 + switch (vc->type)
5.22 {
5.23 - vc->stk_put(ptr);
5.24 - return pContext->ThrowNativeError("Expected 1 parameter for entity pointer; found none");
5.25 + case ValveCall_Entity:
5.26 + case ValveCall_Player:
5.27 + {
5.28 + if (startparam > numparams)
5.29 + {
5.30 + vc->stk_put(ptr);
5.31 + return pContext->ThrowNativeError("Expected 1 parameter for entity pointer; found none");
5.32 + }
5.33 +
5.34 + if (DecodeValveParam(pContext,
5.35 + params[startparam],
5.36 + vc,
5.37 + vc->thisinfo,
5.38 + ptr) == Data_Fail)
5.39 + {
5.40 + vc->stk_put(ptr);
5.41 + return 0;
5.42 + }
5.43 + startparam++;
5.44 + }
5.45 + break;
5.46 + case ValveCall_GameRules:
5.47 + {
5.48 + if (g_pGameRules == NULL)
5.49 + {
5.50 + vc->stk_put(ptr);
5.51 + return pContext->ThrowNativeError("GameRules unsupported or not available; file a bug report");
5.52 + }
5.53 +
5.54 + void *gamerules = *g_pGameRules;
5.55 +
5.56 + if (gamerules == NULL)
5.57 + {
5.58 + vc->stk_put(ptr);
5.59 + return pContext->ThrowNativeError("GameRules not available before map is loaded");
5.60 + }
5.61 + *(void **)ptr = gamerules;
5.62 + }
5.63 + break;
5.64 }
5.65 - if (DecodeValveParam(pContext,
5.66 - params[startparam],
5.67 - vc,
5.68 - vc->thisinfo,
5.69 - ptr) == Data_Fail)
5.70 - {
5.71 - vc->stk_put(ptr);
5.72 - return 0;
5.73 - }
5.74 - startparam++;
5.75 }
5.76
5.77 /* See if we need to skip any more parameters */
6.1 --- a/extensions/sdktools/vdecoder.h Sun Jul 08 09:34:20 2007 +0000
6.2 +++ b/extensions/sdktools/vdecoder.h Sun Jul 08 09:46:27 2007 +0000
6.3 @@ -67,9 +67,10 @@
6.4 */
6.5 enum ValveCallType
6.6 {
6.7 - ValveCall_Static, /**< Static call */
6.8 - ValveCall_Entity, /**< Thiscall (CBaseEntity implicit first parameter) */
6.9 - ValveCall_Player, /**< Thiscall (CBasePlayer implicit first parameter) */
6.10 + ValveCall_Static, /**< Static call */
6.11 + ValveCall_Entity, /**< Thiscall (CBaseEntity implicit first parameter) */
6.12 + ValveCall_Player, /**< Thiscall (CBasePlayer implicit first parameter) */
6.13 + ValveCall_GameRules, /**< Thiscall (CGameRules implicit first paramater) */
6.14 };
6.15
6.16 /**
7.1 --- a/gamedata/sdktools.games.txt Sun Jul 08 09:34:20 2007 +0000
7.2 +++ b/gamedata/sdktools.games.txt Sun Jul 08 09:46:27 2007 +0000
7.3 @@ -8,9 +8,9 @@
7.4 "game" "cstrike"
7.5 "game" "dod"
7.6 "game" "hl2mp"
7.7 - "game" "insurgency"
7.8 - "game" "dystopia_v1"
7.9 - "game" "sourceforts"
7.10 + "game" "!Dystopia"
7.11 + "game" "!Insurgency"
7.12 + "game" "!SourceForts v1.9.2"
7.13 }
7.14
7.15 "Offsets"
7.16 @@ -48,41 +48,50 @@
7.17 }
7.18 }
7.19 }
7.20 -
7.21 - /* HL2MP */
7.22 - "hl2mp"
7.23 +
7.24 + /* General GameRules */
7.25 + "#default"
7.26 {
7.27 + "#supported"
7.28 + {
7.29 + "game" "cstrike"
7.30 + "game" "dod"
7.31 + "game" "garrysmod"
7.32 + "game" "hl2mp"
7.33 + "game" "ship"
7.34 + "game" "!Dystopia"
7.35 + "game" "!Insurgency"
7.36 + "game" "!SourceForts v1.9.2"
7.37 + }
7.38 +
7.39 "Offsets"
7.40 {
7.41 - "GiveNamedItem"
7.42 - {
7.43 - "windows" "327"
7.44 - "linux" "328"
7.45 - }
7.46 - "RemovePlayerItem"
7.47 + /* Offset into CreateGameRulesObject */
7.48 + "g_pGameRules"
7.49 {
7.50 - "windows" "225"
7.51 - "linux" "226"
7.52 - }
7.53 - "Weapon_GetSlot"
7.54 - {
7.55 - "windows" "223"
7.56 - "linux" "224"
7.57 + "windows" "2"
7.58 }
7.59 - "Ignite"
7.60 - {
7.61 - "windows" "187"
7.62 - "linux" "188"
7.63 - }
7.64 - "Extinguish"
7.65 + }
7.66 +
7.67 + "Signatures"
7.68 + {
7.69 + /* This signature sometimes has multiple matches, but this
7.70 + * does not matter as g_pGameRules is involved in all of them.
7.71 + * The same g_pGameRules offset applies to each match.
7.72 + *
7.73 + * Sometimes this block of bytes is at the beginning of the static
7.74 + * CreateGameRulesObject function and sometimes it is in the middle
7.75 + * of an entirely different function. This depends on the game.
7.76 + */
7.77 + "CreateGameRulesObject"
7.78 {
7.79 - "windows" "188"
7.80 - "linux" "189"
7.81 + "library" "server"
7.82 + "windows" "\x8B\x0D\x2A\x2A\x2A\x2A\x85\xC9\x74\x2A\x8B\x01\x6A\x01\xFF\x50"
7.83 }
7.84 - "Teleport"
7.85 + "g_pGameRules"
7.86 {
7.87 - "windows" "97"
7.88 - "linux" "98"
7.89 + "library" "server"
7.90 + "linux" "@g_pGameRules"
7.91 }
7.92 }
7.93 }
7.94 @@ -162,91 +171,47 @@
7.95 }
7.96 }
7.97 }
7.98 -
7.99 - /* Insurgency */
7.100 - "insurgency"
7.101 - {
7.102 - "Offsets"
7.103 - {
7.104 - /* CBasePlayer */
7.105 - "Ignite"
7.106 - {
7.107 - "windows" "174"
7.108 - "linux" "175"
7.109 - }
7.110 - "Extinguish"
7.111 - {
7.112 - "windows" "175"
7.113 - "linux" "176"
7.114 - }
7.115 - "Teleport"
7.116 - {
7.117 - "windows" "90"
7.118 - "linux" "91"
7.119 - }
7.120 -
7.121 - /* Temp Entities */
7.122 - "s_pTempEntities"
7.123 - {
7.124 - "linux" "28"
7.125 - }
7.126 - }
7.127 - }
7.128 -
7.129 - /* SourceForts 1.9.2
7.130 - * :TODO: use description instead...
7.131 - */
7.132 - "sourceforts"
7.133 +
7.134 + /* Half-Life 2: Deathmatch */
7.135 + "hl2mp"
7.136 {
7.137 "Offsets"
7.138 {
7.139 - /* CBasePlayer */
7.140 "GiveNamedItem"
7.141 {
7.142 - "windows" "294"
7.143 - "linux" "295"
7.144 + "windows" "327"
7.145 + "linux" "328"
7.146 }
7.147 "RemovePlayerItem"
7.148 {
7.149 - "windows" "207"
7.150 - "linux" "208"
7.151 + "windows" "225"
7.152 + "linux" "226"
7.153 }
7.154 "Weapon_GetSlot"
7.155 {
7.156 - "windows" "205"
7.157 - "linux" "206"
7.158 + "windows" "223"
7.159 + "linux" "224"
7.160 }
7.161 "Ignite"
7.162 {
7.163 - "windows" "170"
7.164 - "linux" "171"
7.165 + "windows" "187"
7.166 + "linux" "188"
7.167 }
7.168 "Extinguish"
7.169 {
7.170 - "windows" "171"
7.171 - "linux" "172"
7.172 + "windows" "188"
7.173 + "linux" "189"
7.174 }
7.175 "Teleport"
7.176 {
7.177 - "windows" "90"
7.178 - "linux" "91"
7.179 - }
7.180 -
7.181 - /* Temp Entities */
7.182 - "s_pTempEntities"
7.183 - {
7.184 - "linux" "29"
7.185 - }
7.186 - "TE_GetServerClass"
7.187 - {
7.188 - "windows" "0"
7.189 - "linux" "0"
7.190 + "windows" "97"
7.191 + "linux" "98"
7.192 }
7.193 }
7.194 }
7.195 -
7.196 +
7.197 /* Dsytopia */
7.198 - "dystopia_v1"
7.199 + "!Dystopia"
7.200 {
7.201
7.202 "Offsets"
7.203 @@ -304,6 +269,98 @@
7.204 "library" "server"
7.205 "windows" "\x81\xEC\x84\x00\x00\x00\x56\x8B\xF1\x8B\x46\x6C\x57\x8D\x7E\x6C\x8D\x4C\x24\x08\x83\xC8\x20\x51\x89\x44\x24\x0C\xE8\x2A\x2A\x2A"
7.206 }
7.207 +
7.208 + /* Dystopia always has to be different, doesn't it
7.209 + *
7.210 + * This is very similar to the general signature, except that
7.211 + * it does "mov edx, [eax+2Ch]" before making a call rather than
7.212 + * doing "call dword ptr [eax+2Ch]"
7.213 + */
7.214 + "CreateGameRulesObject"
7.215 + {
7.216 + "library" "server"
7.217 + "windows" "\x8B\x0D\x2A\x2A\x2A\x2A\x85\xC9\x74\x2A\x8B\x01\x8B\x50\x2A\x6A\x01\xFF\xD2"
7.218 + }
7.219 + }
7.220 + }
7.221 +
7.222 + /* Insurgency */
7.223 + "!Insurgency"
7.224 + {
7.225 + "Offsets"
7.226 + {
7.227 + /* CBasePlayer */
7.228 + "Ignite"
7.229 + {
7.230 + "windows" "174"
7.231 + "linux" "175"
7.232 + }
7.233 + "Extinguish"
7.234 + {
7.235 + "windows" "175"
7.236 + "linux" "176"
7.237 + }
7.238 + "Teleport"
7.239 + {
7.240 + "windows" "90"
7.241 + "linux" "91"
7.242 + }
7.243 +
7.244 + /* Temp Entities */
7.245 + "s_pTempEntities"
7.246 + {
7.247 + "linux" "28"
7.248 + }
7.249 + }
7.250 + }
7.251 +
7.252 + /* SourceForts 1.9.2 */
7.253 + "!SourceForts v1.9.2"
7.254 + {
7.255 + "Offsets"
7.256 + {
7.257 + /* CBasePlayer */
7.258 + "GiveNamedItem"
7.259 + {
7.260 + "windows" "294"
7.261 + "linux" "295"
7.262 + }
7.263 + "RemovePlayerItem"
7.264 + {
7.265 + "windows" "207"
7.266 + "linux" "208"
7.267 + }
7.268 + "Weapon_GetSlot"
7.269 + {
7.270 + "windows" "205"
7.271 + "linux" "206"
7.272 + }
7.273 + "Ignite"
7.274 + {
7.275 + "windows" "170"
7.276 + "linux" "171"
7.277 + }
7.278 + "Extinguish"
7.279 + {
7.280 + "windows" "171"
7.281 + "linux" "172"
7.282 + }
7.283 + "Teleport"
7.284 + {
7.285 + "windows" "90"
7.286 + "linux" "91"
7.287 + }
7.288 +
7.289 + /* Temp Entities */
7.290 + "s_pTempEntities"
7.291 + {
7.292 + "linux" "29"
7.293 + }
7.294 + "TE_GetServerClass"
7.295 + {
7.296 + "windows" "0"
7.297 + "linux" "0"
7.298 + }
7.299 }
7.300 }
7.301 }
8.1 --- a/plugins/include/sdktools.inc Sun Jul 08 09:34:20 2007 +0000
8.2 +++ b/plugins/include/sdktools.inc Sun Jul 08 09:46:27 2007 +0000
8.3 @@ -31,6 +31,7 @@
8.4 SDKCall_Static, /**< Static call */
8.5 SDKCall_Entity, /**< CBaseEntity call */
8.6 SDKCall_Player, /**< CBasePlayer call */
8.7 + SDKCall_GameRules, /**< CGameRules call */
8.8 };
8.9
8.10 enum SDKLibrary
8.11 @@ -147,6 +148,7 @@
8.12 * Calls an SDK function with the given parameters.
8.13 *
8.14 * If the call type is Entity or Player, the index MUST ALWAYS be the FIRST parameter passed.
8.15 + * If the call type is GameRules, then nothing special needs to be passed.
8.16 * If the return value is a Vector or QAngles, the SECOND parameter must be a Float[3].
8.17 * If the return value is a string, the THIRD parameter must be a String buffer, and the
8.18 * FOURTH parameter must be the maximum length.