1
0
mirror of https://github.com/alliedmodders/metamod-source.git synced 2025-02-26 19:54:14 +01:00

committed new callclass code

--HG--
extra : convert_revision : svn%3Ac2935e3e-5518-0410-8daf-afa5dab7d4e3/trunk%4045
This commit is contained in:
David Anderson 2005-04-30 18:45:41 +00:00
parent 9ab8eae041
commit 7284445d7e
2 changed files with 12 additions and 0 deletions

View File

@ -108,6 +108,8 @@ bool SamplePlugin::Load(PluginId id, ISmmAPI *ismm, factories *list, char *error
return false; return false;
} }
META_LOG(g_PLAPI, "Starting plugin.\n");
//We're hooking the following things as POST, in order to seem like Server Plugins. //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. //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. //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 //Hook ClientCommand to our function
SH_ADD_HOOK_MEMFUNC(IServerGameClients, ClientCommand, m_ServerClients, &g_SamplePlugin, ClientCommand, false); 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; 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, ClientConnect, m_ServerClients, &g_SamplePlugin, ClientConnect, false);
SH_REMOVE_HOOK_MEMFUNC(IServerGameClients, ClientCommand, m_ServerClients, &g_SamplePlugin, ClientCommand, false); SH_REMOVE_HOOK_MEMFUNC(IServerGameClients, ClientCommand, m_ServerClients, &g_SamplePlugin, ClientCommand, false);
SH_RELEASE_CALLCLASS(m_Engine_CC);
return true; return true;
} }

View File

@ -12,6 +12,7 @@
#define _INCLUDE_SAMPLEPLUGIN_H #define _INCLUDE_SAMPLEPLUGIN_H
#include <ISmmPlugin.h> #include <ISmmPlugin.h>
#include <sourcehook/sourcehook.h>
class SamplePlugin : public ISmmPlugin class SamplePlugin : public ISmmPlugin
{ {
@ -107,6 +108,7 @@ private:
IVEngineServer *m_Engine; IVEngineServer *m_Engine;
IServerGameDLL *m_ServerDll; IServerGameDLL *m_ServerDll;
IServerGameClients *m_ServerClients; IServerGameClients *m_ServerClients;
SourceHook::CallClass<IVEngineServer> *m_Engine_CC;
}; };
extern SamplePlugin g_SamplePlugin; extern SamplePlugin g_SamplePlugin;