From e95f0f333e939880da73962c8e3b362fe8f6b5c8 Mon Sep 17 00:00:00 2001 From: Nicholas Hastings Date: Mon, 27 Aug 2012 17:52:15 -0400 Subject: [PATCH] Compatibility shim to fix IServer lookup on CS:S (bug 5450, r=asherkin). --- extensions/sdktools/vglobals.cpp | 14 ++++++-- gamedata/sdktools.games/engine.ep2valve.txt | 38 +++++++++++++++++---- 2 files changed, 43 insertions(+), 9 deletions(-) diff --git a/extensions/sdktools/vglobals.cpp b/extensions/sdktools/vglobals.cpp index 5bdae558..02f9a119 100644 --- a/extensions/sdktools/vglobals.cpp +++ b/extensions/sdktools/vglobals.cpp @@ -125,6 +125,7 @@ void GetIServer() int offset; void *vfunc = NULL; +#if SOURCE_ENGINE != SE_ORANGEBOXVALVE #if defined METAMOD_PLAPI_VERSION || PLAPI_VERSION >= 11 /* Get the CreateFakeClient function pointer */ if (!(vfunc=SH_GET_ORIG_VFNPTR_ENTRY(engine, &IVEngineServer::CreateFakeClient))) @@ -142,7 +143,8 @@ void GetIServer() void **vtable = *reinterpret_cast(enginePatch->GetThisPtr() + info.thisptroffs + info.vtbloffs); vfunc = vtable[info.vtblindex]; } -#endif +#endif // defined METAMOD_PLAPI_VERSION || PLAPI_VERSION >= 11 +#endif // SOURCE_ENGINE != SE_ORANGEBOXVALVE /* Get signature string for IVEngineServer::CreateFakeClient() */ sigstr = g_pGameConf->GetKeyValue("CreateFakeClient_Windows"); @@ -154,12 +156,20 @@ void GetIServer() /* Convert signature string to signature bytes */ siglen = UTIL_StringToSignature(sigstr, sig, sizeof(sig)); - + +#if SOURCE_ENGINE == SE_ORANGEBOXVALVE + vfunc = memutils->FindPattern(engine, sigstr, siglen); + if (!vfunc) + { + return; + } +#else /* Check if we're on the expected function */ if (!UTIL_VerifySignature(vfunc, sig, siglen)) { return; } +#endif /* Get the offset into CreateFakeClient */ if (!g_pGameConf->GetOffset("sv", &offset)) diff --git a/gamedata/sdktools.games/engine.ep2valve.txt b/gamedata/sdktools.games/engine.ep2valve.txt index e7d45e86..3af96583 100644 --- a/gamedata/sdktools.games/engine.ep2valve.txt +++ b/gamedata/sdktools.games/engine.ep2valve.txt @@ -150,12 +150,7 @@ "Keys" { /* Signature for the beginning of IVEngineServer::CreateFakeClientEx. - * - * The engine binary is not actually scanned in order to look for - * this. SourceHook is used to used to determine the address of the - * function and this signature is used to verify that it contains - * the expected code. A pointer to sv (IServer interface) is used - * here. + * (Must be unique!) */ "CreateFakeClient_Windows" "\x55\x8B\xEC\x8B\x2A\x2A\x50\xB9\x2A\x2A\x2A\x2A\xE8" @@ -184,7 +179,36 @@ "#default" { - // This is broken for now on css. Functionality is compiled in and we only have a unified ep2v/css build on 1.4.x. + "#supported" + { + "game" "cstrike" + } + + "Keys" + { + /* Signature for the beginning of IVEngineServer::CreateFakeClientEx. + * (Must be unique!) + */ + "CreateFakeClient_Windows" "\x55\x8B\xEC\x8B\x2A\x2A\x8A\x2A\x2A\x51\xB9\x2A\x2A\x2A\x2A\xA2" + } + + "Offsets" + { + "sv" + { + "windows" "11" + } + } + + "Signatures" + { + "sv" + { + "library" "engine" + "linux" "@sv" + "mac" "@sv" + } + } } /* EntityFactoryDictionary function */