From 923164bb692b1a06223699b2aa91c5ffcdb18a0a Mon Sep 17 00:00:00 2001 From: Scott Ehlert Date: Thu, 26 Apr 2007 18:14:21 +0000 Subject: [PATCH] Client 'meta' command should now work with ServerGameClients004 and beyond. --HG-- extra : convert_revision : svn%3Ac2935e3e-5518-0410-8daf-afa5dab7d4e3/trunk%40380 --- sourcemm/changelog.txt | 2 ++ sourcemm/sourcemm.cpp | 28 ++++++++++++++++++---------- 2 files changed, 20 insertions(+), 10 deletions(-) diff --git a/sourcemm/changelog.txt b/sourcemm/changelog.txt index 2a14af5..cd41d76 100644 --- a/sourcemm/changelog.txt +++ b/sourcemm/changelog.txt @@ -1,5 +1,7 @@ 2007/??/?? 1.4.1: - Added API for getting highest supported IServerPluginCallbacks interface version. + - The client version of the "meta" command should now work on games that use + ServerGameClients004 and beyond. 2007/04/05 1.4.0: - Added API functions for retrieving User Message info without potentially crashing. diff --git a/sourcemm/sourcemm.cpp b/sourcemm/sourcemm.cpp index e4fa389..678ad9f 100644 --- a/sourcemm/sourcemm.cpp +++ b/sourcemm/sourcemm.cpp @@ -119,15 +119,6 @@ void InitMainStates() SH_ADD_HOOK_STATICFUNC(IServerGameDLL, LevelShutdown, g_GameDll.pGameDLL, LevelShutdown_handler, true); SH_ADD_HOOK_STATICFUNC(IServerGameDLL, LevelInit, g_GameDll.pGameDLL, LevelInit_handler, true); SH_ADD_HOOK_STATICFUNC(IServerGameDLL, GameInit, g_GameDll.pGameDLL, GameInit_handler, false); - - if (g_GameDll.pGameClients) - { - SH_ADD_HOOK_STATICFUNC(IServerGameClients, ClientCommand, g_GameDll.pGameClients, ClientCommand_handler, false); - } else { - /* If IServerGameClients isn't found, this really isn't a fatal error so... */ - LogMessage("[META] Warning: Could not find IServerGameClients!"); - LogMessage("[META] Warning: The 'meta' command will not be available to clients."); - } } bool DLLInit(CreateInterfaceFn engineFactory, CreateInterfaceFn physicsFactory, CreateInterfaceFn filesystemFactory, CGlobalVars *pGlobals) @@ -157,6 +148,15 @@ bool DLLInit(CreateInterfaceFn engineFactory, CreateInterfaceFn physicsFactory, g_GameDllPatch = SH_GET_CALLCLASS(g_GameDll.pGameDLL); + if (g_GameDll.pGameClients) + { + SH_ADD_HOOK_STATICFUNC(IServerGameClients, ClientCommand, g_GameDll.pGameClients, ClientCommand_handler, false); + } else { + /* If IServerGameClients isn't found, this really isn't a fatal error so... */ + LogMessage("[META] Warning: Could not find IServerGameClients!"); + LogMessage("[META] Warning: The 'meta' command will not be available to clients."); + } + if (!g_SmmAPI.CacheCmds()) { LogMessage("[META] Warning: Failed to initialize Con_Printf. Defaulting to Msg()."); @@ -374,7 +374,6 @@ SMM_API void *CreateInterface(const char *iface, int *ret) pInfo->lib = gamedll; pInfo->loaded = true; pInfo->pGameDLL = NULL; - pInfo->pGameClients = (IServerGameClients *)((fn)(INTERFACEVERSION_SERVERGAMECLIENTS, NULL)); gamedll_list.push_back(pInfo); break; } @@ -447,6 +446,15 @@ SMM_API void *CreateInterface(const char *iface, int *ret) } } + /* We use this interface for responding to the meta client command */ + if (strncmp(iface, "ServerGameClients", 17) == 0) + { + void *ptr = (g_GameDll.factory)(iface, ret); + g_GameDll.pGameClients = static_cast(ptr); + + return ptr; + } + /* If we got here, there's definitely a GameDLL */ IFACE_MACRO(g_GameDll.factory, GameDLL); }