Global forwards created after all plugins have been loaded now properly get filled with IPluginFunction pointers.
authorScott Ehlert <ds@alliedmods.net>
Wed Mar 14 07:54:54 2007 +0000 (2007-03-14)
changeset 6119921680863d4
parent 610 2fe5613a35e3
child 612 e000559527a3
Global forwards created after all plugins have been loaded now properly get filled with IPluginFunction pointers.
Added CPluginManager::AddFunctionsToForward() to help do this...
core/systems/ForwardSys.cpp
core/systems/PluginSys.cpp
core/systems/PluginSys.h
     1.1 --- a/core/systems/ForwardSys.cpp	Wed Mar 14 04:08:59 2007 +0000
     1.2 +++ b/core/systems/ForwardSys.cpp	Wed Mar 14 07:54:54 2007 +0000
     1.3 @@ -55,6 +55,8 @@
     1.4  
     1.5  	if (fwd)
     1.6  	{
     1.7 +		g_PluginSys.AddFunctionsToForward(name, fwd);
     1.8 +
     1.9  		m_managed.push_back(fwd);
    1.10  	}
    1.11  
     2.1 --- a/core/systems/PluginSys.cpp	Wed Mar 14 04:08:59 2007 +0000
     2.2 +++ b/core/systems/PluginSys.cpp	Wed Mar 14 07:54:54 2007 +0000
     2.3 @@ -16,6 +16,7 @@
     2.4  #include "ShareSys.h"
     2.5  #include "LibrarySys.h"
     2.6  #include "HandleSys.h"
     2.7 +#include "ForwardSys.h"
     2.8  #include "sourcemm_api.h"
     2.9  #include "sourcemod.h"
    2.10  #include "TextParsers.h"
    2.11 @@ -1879,3 +1880,25 @@
    2.12  
    2.13  	return true;
    2.14  }
    2.15 +
    2.16 +void CPluginManager::AddFunctionsToForward(const char *name, IChangeableForward *pForward)
    2.17 +{
    2.18 +	List<CPlugin *>::iterator iter;
    2.19 +	CPlugin *pPlugin;
    2.20 +	IPluginFunction *pFunction;
    2.21 +
    2.22 +	for (iter = m_plugins.begin(); iter != m_plugins.end(); iter++)
    2.23 +	{
    2.24 +		pPlugin = (*iter);
    2.25 +
    2.26 +		if (pPlugin->GetStatus() <= Plugin_Paused)
    2.27 +		{
    2.28 +			pFunction = pPlugin->GetBaseContext()->GetFunctionByName(name);
    2.29 +
    2.30 +			if (pFunction)
    2.31 +			{
    2.32 +				pForward->AddFunction(pFunction);
    2.33 +			}
    2.34 +		}
    2.35 +	}
    2.36 +}
     3.1 --- a/core/systems/PluginSys.h	Wed Mar 14 04:08:59 2007 +0000
     3.2 +++ b/core/systems/PluginSys.h	Wed Mar 14 07:54:54 2007 +0000
     3.3 @@ -19,6 +19,7 @@
     3.4  #include <sys/stat.h>
     3.5  #include <IPluginSys.h>
     3.6  #include <IHandleSys.h>
     3.7 +#include <IForwardSys.h>
     3.8  #include <sh_list.h>
     3.9  #include <sh_stack.h>
    3.10  #include <sh_vector.h>
    3.11 @@ -354,6 +355,12 @@
    3.12  	*/
    3.13  	void ReloadOrUnloadPlugins();
    3.14  
    3.15 +	/**
    3.16 +	 * Add public functions from all running or paused
    3.17 +	 * plugins to the specified forward if the names match.
    3.18 +	 */
    3.19 +	void AddFunctionsToForward(const char *name, IChangeableForward *pForward);
    3.20 +
    3.21  private:
    3.22  	LoadRes _LoadPlugin(CPlugin **pPlugin, const char *path, bool debug, PluginType type, char error[], size_t err_max);
    3.23