mirror of
https://github.com/alliedmodders/metamod-source.git
synced 2025-12-06 18:08:31 +00:00
Move Source-engine provider to templated SourceHook
This commit is contained in:
parent
aa88f23880
commit
11df174ab7
@ -44,14 +44,14 @@ static SourceProvider g_SourceProvider;
|
|||||||
|
|
||||||
IMetamodSourceProvider* provider = &g_SourceProvider;
|
IMetamodSourceProvider* provider = &g_SourceProvider;
|
||||||
|
|
||||||
SH_DECL_HOOK0(IServerGameDLL, GameInit, SH_NOATTRIB, 0, bool);
|
auto OnGameInit = SourceHook::Hook<&g_SHPtr, IServerGameDLL, &IServerGameDLL::GameInit, bool>::Make();
|
||||||
SH_DECL_HOOK6(IServerGameDLL, LevelInit, SH_NOATTRIB, 0, bool, const char*, const char*, const char*, const char*, bool, bool);
|
auto OnLevelInit = SourceHook::Hook<&g_SHPtr, IServerGameDLL, &IServerGameDLL::LevelInit, bool, const char*, const char*, const char*, const char*, bool, bool>::Make();
|
||||||
SH_DECL_HOOK0_void(IServerGameDLL, LevelShutdown, SH_NOATTRIB, 0);
|
auto OnLevelShutdown = SourceHook::Hook<&g_SHPtr, IServerGameDLL, &IServerGameDLL::LevelShutdown, void>::Make();
|
||||||
|
|
||||||
#if SOURCE_ENGINE >= SE_ORANGEBOX
|
#if SOURCE_ENGINE >= SE_ORANGEBOX
|
||||||
SH_DECL_HOOK2_void(IServerGameClients, ClientCommand, SH_NOATTRIB, 0, edict_t*, const CCommand&);
|
auto OnClientCommand = SourceHook::Hook<&g_SHPtr, IServerGameClients, &IServerGameClients::ClientCommand, void, edict_t*, const CCommand&>::Make();
|
||||||
#else
|
#else
|
||||||
SH_DECL_HOOK1_void(IServerGameClients, ClientCommand, SH_NOATTRIB, 0, edict_t*);
|
auto OnClientCommand = SourceHook::Hook<&g_SHPtr, IServerGameClients, &IServerGameClients::ClientCommand, void, edict_t*>::Make();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void SourceProvider::Notify_DLLInit_Pre(CreateInterfaceFn engineFactory,
|
void SourceProvider::Notify_DLLInit_Pre(CreateInterfaceFn engineFactory,
|
||||||
@ -69,34 +69,30 @@ void SourceProvider::Notify_DLLInit_Pre(CreateInterfaceFn engineFactory,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
engine = (IVEngineServer*)((engineFactory)(INTERFACEVERSION_VENGINESERVER, NULL));
|
engine = (IVEngineServer *) ((engineFactory)(INTERFACEVERSION_VENGINESERVER, NULL));
|
||||||
#endif
|
#endif
|
||||||
if (!engine)
|
if (!engine) {
|
||||||
{
|
|
||||||
DisplayError("Could not find IVEngineServer! Metamod cannot load.");
|
DisplayError("Could not find IVEngineServer! Metamod cannot load.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if SOURCE_ENGINE >= SE_ORANGEBOX
|
#if SOURCE_ENGINE >= SE_ORANGEBOX
|
||||||
icvar = (ICvar*)((engineFactory)(CVAR_INTERFACE_VERSION, NULL));
|
icvar = (ICvar *) ((engineFactory)(CVAR_INTERFACE_VERSION, NULL));
|
||||||
#else
|
#else
|
||||||
icvar = (ICvar*)((engineFactory)(VENGINE_CVAR_INTERFACE_VERSION, NULL));
|
icvar = (ICvar*)((engineFactory)(VENGINE_CVAR_INTERFACE_VERSION, NULL));
|
||||||
#endif
|
#endif
|
||||||
if (!icvar)
|
if (!icvar) {
|
||||||
{
|
|
||||||
DisplayError("Could not find ICvar! Metamod cannot load.");
|
DisplayError("Could not find ICvar! Metamod cannot load.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((gameclients = (IServerGameClients*)(serverFactory("ServerGameClients003", NULL)))
|
if ((gameclients = (IServerGameClients *) (serverFactory("ServerGameClients003", NULL)))
|
||||||
== NULL)
|
== NULL) {
|
||||||
{
|
gameclients = (IServerGameClients *) (serverFactory("ServerGameClients004", NULL));
|
||||||
gameclients = (IServerGameClients*)(serverFactory("ServerGameClients004", NULL));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
baseFs = (IFileSystem*)((engineFactory)(FILESYSTEM_INTERFACE_VERSION, NULL));
|
baseFs = (IFileSystem *) ((engineFactory)(FILESYSTEM_INTERFACE_VERSION, NULL));
|
||||||
if (baseFs == NULL)
|
if (baseFs == NULL) {
|
||||||
{
|
|
||||||
mm_LogMessage("Unable to find \"%s\": .vdf files will not be parsed", FILESYSTEM_INTERFACE_VERSION);
|
mm_LogMessage("Unable to find \"%s\": .vdf files will not be parsed", FILESYSTEM_INTERFACE_VERSION);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -122,21 +118,20 @@ void SourceProvider::Notify_DLLInit_Pre(CreateInterfaceFn engineFactory,
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (gameclients)
|
if (gameclients) {
|
||||||
{
|
OnClientCommand->Add(g_PLID, gameclients, false, SH_MEMBER(this, &SourceProvider::Hook_ClientCommand));
|
||||||
SH_ADD_HOOK(IServerGameClients, ClientCommand, gameclients, SH_MEMBER(this, &SourceProvider::Hook_ClientCommand), false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SH_ADD_HOOK(IServerGameDLL, GameInit, server, SH_MEMBER(this, &SourceProvider::Hook_GameInit), false);
|
OnGameInit->Add(g_PLID, server, false, SH_MEMBER(this, &SourceProvider::Hook_GameInit));
|
||||||
SH_ADD_HOOK(IServerGameDLL, LevelInit, server, SH_MEMBER(this, &SourceProvider::Hook_LevelInit), true);
|
OnLevelInit->Add(g_PLID, server, true, SH_MEMBER(this, &SourceProvider::Hook_LevelInit));
|
||||||
SH_ADD_HOOK(IServerGameDLL, LevelShutdown, server, SH_MEMBER(this, &SourceProvider::Hook_LevelShutdown), true);
|
OnLevelShutdown->Add(g_PLID, server, true, SH_MEMBER(this, &SourceProvider::Hook_LevelShutdown));
|
||||||
}
|
}
|
||||||
|
|
||||||
void SourceProvider::Notify_DLLShutdown_Pre()
|
void SourceProvider::Notify_DLLShutdown_Pre()
|
||||||
{
|
{
|
||||||
SH_REMOVE_HOOK(IServerGameDLL, GameInit, server, SH_MEMBER(this, &SourceProvider::Hook_GameInit), false);
|
OnGameInit->Remove(g_PLID, server, false, SH_MEMBER(this, &SourceProvider::Hook_GameInit));
|
||||||
SH_REMOVE_HOOK(IServerGameDLL, LevelInit, server, SH_MEMBER(this, &SourceProvider::Hook_LevelInit), true);
|
OnLevelInit->Remove(g_PLID, server, true, SH_MEMBER(this, &SourceProvider::Hook_LevelInit));
|
||||||
SH_REMOVE_HOOK(IServerGameDLL, LevelShutdown, server, SH_MEMBER(this, &SourceProvider::Hook_LevelShutdown), true);
|
OnLevelShutdown->Remove(g_PLID, server, true, SH_MEMBER(this, &SourceProvider::Hook_LevelShutdown));
|
||||||
|
|
||||||
m_ConVarAccessor.RemoveMetamodCommands();
|
m_ConVarAccessor.RemoveMetamodCommands();
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user