diff --git a/sourcemm/CSmmAPI.cpp b/sourcemm/CSmmAPI.cpp index a475dae..4437fe7 100644 --- a/sourcemm/CSmmAPI.cpp +++ b/sourcemm/CSmmAPI.cpp @@ -454,39 +454,15 @@ void CSmmAPI::ClientConPrintf(edict_t *client, const char *fmt, ...) void CSmmAPI::LoadAsVSP() { - g_Engine.engine->ServerCommand("plugin_load \n"); - g_Engine.engine->ServerExecute(); - - IServerPluginCallbacks *iface = NULL; - if (g_VspListener.IsLoaded()) + char path[260]; + if (!GetFileOfAddress(CreateInterface, path, sizeof(path))) { - iface = &g_VspListener; - } - - PluginIter iter; - CPluginManager::CPlugin *pPlugin; - SourceHook::List::iterator event; - IMetamodListener *pML; - for (iter=g_PluginMngr._begin(); iter!=g_PluginMngr._end(); iter++) - { - pPlugin = (*iter); - if (pPlugin->m_Status < Pl_Paused) - { - continue; - } - /* Only valid for plugins >= 10 (v1:5, SourceMM 1.4) */ - if (pPlugin->m_API->GetApiVersion() < 10) - { - continue; - } - for (event=pPlugin->m_Events.begin(); - event!=pPlugin->m_Events.end(); - event++) - { - pML = (*event); - pML->OnVSPListening(iface); - } + /* Failed! */ } + char command[350]; + g_VspListener.SetLoadable(true); + UTIL_Format(command, sizeof(command), "plugin_load \"%s\"\n", path); + g_Engine.engine->ServerCommand(command); } void CSmmAPI::EnableVSPListener() diff --git a/sourcemm/sourcemm.cpp b/sourcemm/sourcemm.cpp index bedead1..4fbe007 100644 --- a/sourcemm/sourcemm.cpp +++ b/sourcemm/sourcemm.cpp @@ -57,7 +57,7 @@ bool bGameInit = false; SourceHook::List gamedll_list; SourceHook::CallClass *g_GameDllPatch; int g_GameDllVersion = 0; -const char VSPIFACE[] = "ISERVERPLUGINS"; +const char VSPIFACE[] = "ISERVERPLUGINCALLBACKS"; const char GAMEINFO_PATH[] = "|gameinfo_path|"; void ClearGamedllList(); @@ -225,7 +225,7 @@ SMM_API void *CreateInterface(const char *iface, int *ret) return NULL; } - if (strncmp(iface, VSPIFACE, sizeof(VSPIFACE) - 1) == 0) + if (strncmp(iface, VSPIFACE, 22) == 0) { if (ret) { diff --git a/sourcemm/vsp_listener.cpp b/sourcemm/vsp_listener.cpp index adc2695..c02a230 100644 --- a/sourcemm/vsp_listener.cpp +++ b/sourcemm/vsp_listener.cpp @@ -9,6 +9,9 @@ */ #include "vsp_listener.h" +#include "CPlugin.h" + +using namespace SourceMM; VSPListener g_VspListener; @@ -118,6 +121,32 @@ bool VSPListener::Load(CreateInterfaceFn interfaceFactory, CreateInterfaceFn gam } m_Loaded = true; + SetLoadable(false); + + PluginIter iter; + CPluginManager::CPlugin *pPlugin; + SourceHook::List::iterator event; + IMetamodListener *pML; + for (iter=g_PluginMngr._begin(); iter!=g_PluginMngr._end(); iter++) + { + pPlugin = (*iter); + if (pPlugin->m_Status < Pl_Paused) + { + continue; + } + /* Only valid for plugins >= 10 (v1:5, SourceMM 1.4) */ + if (pPlugin->m_API->GetApiVersion() < 10) + { + continue; + } + for (event=pPlugin->m_Events.begin(); + event!=pPlugin->m_Events.end(); + event++) + { + pML = (*event); + pML->OnVSPListening(this); + } + } return true; }