From 7284445d7ec48527d76bbcb02aed7277f6b9224d Mon Sep 17 00:00:00 2001 From: David Anderson Date: Sat, 30 Apr 2005 18:45:41 +0000 Subject: [PATCH] committed new callclass code --HG-- extra : convert_revision : svn%3Ac2935e3e-5518-0410-8daf-afa5dab7d4e3/trunk%4045 --- sourcemm/sample_mm/SamplePlugin.cpp | 10 ++++++++++ sourcemm/sample_mm/SamplePlugin.h | 2 ++ 2 files changed, 12 insertions(+) diff --git a/sourcemm/sample_mm/SamplePlugin.cpp b/sourcemm/sample_mm/SamplePlugin.cpp index dbcbc7b..cb7d975 100644 --- a/sourcemm/sample_mm/SamplePlugin.cpp +++ b/sourcemm/sample_mm/SamplePlugin.cpp @@ -108,6 +108,8 @@ bool SamplePlugin::Load(PluginId id, ISmmAPI *ismm, factories *list, char *error return false; } + META_LOG(g_PLAPI, "Starting plugin.\n"); + //We're hooking the following things as POST, in order to seem like Server Plugins. //However, I don't actually know if Valve has done server plugins as POST or not. //Change the last parameter to 'false' in order to change this to PRE. @@ -139,6 +141,12 @@ bool SamplePlugin::Load(PluginId id, ISmmAPI *ismm, factories *list, char *error //Hook ClientCommand to our function SH_ADD_HOOK_MEMFUNC(IServerGameClients, ClientCommand, m_ServerClients, &g_SamplePlugin, ClientCommand, false); + //Get the call class for IVServerEngine so we can safely call functions without + // invoking their hooks (when needed). + m_Engine_CC = SH_GET_CALLCLASS(m_Engine); + + SH_CALL(m_Engine_CC, &IVEngineServer::LogPrint)("All hooks started!\n"); + return true; } @@ -159,6 +167,8 @@ bool SamplePlugin::Unload(char *error, size_t maxlen) SH_REMOVE_HOOK_MEMFUNC(IServerGameClients, ClientConnect, m_ServerClients, &g_SamplePlugin, ClientConnect, false); SH_REMOVE_HOOK_MEMFUNC(IServerGameClients, ClientCommand, m_ServerClients, &g_SamplePlugin, ClientCommand, false); + SH_RELEASE_CALLCLASS(m_Engine_CC); + return true; } diff --git a/sourcemm/sample_mm/SamplePlugin.h b/sourcemm/sample_mm/SamplePlugin.h index eebde0c..f96e673 100644 --- a/sourcemm/sample_mm/SamplePlugin.h +++ b/sourcemm/sample_mm/SamplePlugin.h @@ -12,6 +12,7 @@ #define _INCLUDE_SAMPLEPLUGIN_H #include +#include class SamplePlugin : public ISmmPlugin { @@ -107,6 +108,7 @@ private: IVEngineServer *m_Engine; IServerGameDLL *m_ServerDll; IServerGameClients *m_ServerClients; + SourceHook::CallClass *m_Engine_CC; }; extern SamplePlugin g_SamplePlugin;