From 62aa55b23bf414afd5f4bbb648f145f80bb1a3fc Mon Sep 17 00:00:00 2001 From: Scott Ehlert Date: Wed, 14 Mar 2007 07:54:54 +0000 Subject: [PATCH] Global forwards created after all plugins have been loaded now properly get filled with IPluginFunction pointers. Added CPluginManager::AddFunctionsToForward() to help do this... --HG-- extra : convert_revision : svn%3A39bc706e-5318-0410-9160-8a85361fbb7c/trunk%40617 --- core/systems/ForwardSys.cpp | 2 ++ core/systems/PluginSys.cpp | 23 +++++++++++++++++++++++ core/systems/PluginSys.h | 7 +++++++ 3 files changed, 32 insertions(+) diff --git a/core/systems/ForwardSys.cpp b/core/systems/ForwardSys.cpp index bbbee3f5..1cbcccd9 100644 --- a/core/systems/ForwardSys.cpp +++ b/core/systems/ForwardSys.cpp @@ -55,6 +55,8 @@ IForward *CForwardManager::CreateForward(const char *name, ExecType et, unsigned if (fwd) { + g_PluginSys.AddFunctionsToForward(name, fwd); + m_managed.push_back(fwd); } diff --git a/core/systems/PluginSys.cpp b/core/systems/PluginSys.cpp index e380377a..235d6499 100644 --- a/core/systems/PluginSys.cpp +++ b/core/systems/PluginSys.cpp @@ -16,6 +16,7 @@ #include "ShareSys.h" #include "LibrarySys.h" #include "HandleSys.h" +#include "ForwardSys.h" #include "sourcemm_api.h" #include "sourcemod.h" #include "TextParsers.h" @@ -1879,3 +1880,25 @@ bool CPluginManager::AddFakeNative(IPluginFunction *pFunction, const char *name, return true; } + +void CPluginManager::AddFunctionsToForward(const char *name, IChangeableForward *pForward) +{ + List::iterator iter; + CPlugin *pPlugin; + IPluginFunction *pFunction; + + for (iter = m_plugins.begin(); iter != m_plugins.end(); iter++) + { + pPlugin = (*iter); + + if (pPlugin->GetStatus() <= Plugin_Paused) + { + pFunction = pPlugin->GetBaseContext()->GetFunctionByName(name); + + if (pFunction) + { + pForward->AddFunction(pFunction); + } + } + } +} diff --git a/core/systems/PluginSys.h b/core/systems/PluginSys.h index f9bda46a..39634ac2 100644 --- a/core/systems/PluginSys.h +++ b/core/systems/PluginSys.h @@ -19,6 +19,7 @@ #include #include #include +#include #include #include #include @@ -354,6 +355,12 @@ public: */ void ReloadOrUnloadPlugins(); + /** + * Add public functions from all running or paused + * plugins to the specified forward if the names match. + */ + void AddFunctionsToForward(const char *name, IChangeableForward *pForward); + private: LoadRes _LoadPlugin(CPlugin **pPlugin, const char *path, bool debug, PluginType type, char error[], size_t err_max);