mirror of
https://github.com/alliedmodders/sourcemod.git
synced 2025-12-07 18:38:37 +00:00
Call OnLibraryAdded for all available librarys (bug 5925, pull request #4)
commitc1b064c923Author: Peace-Maker <peace-maker@wcfan.de> Date: Wed May 28 03:16:22 2014 +0200 Coding style adjustments commit37a16dbba2Author: Peace-Maker <peace-maker@wcfan.de> Date: Wed May 28 03:03:25 2014 +0200 Load core.phrases before calling OnLibraryAdded commit676ac95111Author: Peace-Maker <peace-maker@wcfan.de> Date: Tue May 27 13:18:48 2014 +0200 Call OnLibraryAdded for all available librarys (bug 5925) When loading multiple plugins at once (on server start or mapchange) OnLibraryAdded is only called for libraries which are loaded after the current plugin. The plugin isn't informed about the libraries that were added before its OnPluginStart forward was called. This patch calls OnLibraryAdded for all already registered libraries the current plugin has missed.
This commit is contained in:
parent
84de0f6b85
commit
ac11eb8910
@ -427,6 +427,24 @@ APLRes CPlugin::Call_AskPluginLoad(char *error, size_t maxlength)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CPlugin::Call_OnLibraryAdded(const char *lib)
|
||||||
|
{
|
||||||
|
if (m_status > Plugin_Paused)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
cell_t result;
|
||||||
|
IPluginFunction *pFunction = m_pRuntime->GetFunctionByName("OnLibraryAdded");
|
||||||
|
if (!pFunction)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
pFunction->PushString(lib);
|
||||||
|
pFunction->Execute(&result);
|
||||||
|
}
|
||||||
|
|
||||||
void *CPlugin::GetPluginStructure()
|
void *CPlugin::GetPluginStructure()
|
||||||
{
|
{
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -1404,6 +1422,20 @@ bool CPluginManager::RunSecondPass(CPlugin *pPlugin, char *error, size_t maxleng
|
|||||||
|
|
||||||
/* :TODO: optimize? does this even matter? */
|
/* :TODO: optimize? does this even matter? */
|
||||||
pPlugin->GetPhrases()->AddPhraseFile("core.phrases");
|
pPlugin->GetPhrases()->AddPhraseFile("core.phrases");
|
||||||
|
|
||||||
|
/* Go through all other already loaded plugins and tell this plugin, that their libraries are loaded */
|
||||||
|
for (List<CPlugin *>::iterator pl_iter = m_plugins.begin(); pl_iter != m_plugins.end(); pl_iter++)
|
||||||
|
{
|
||||||
|
CPlugin *pl = (*pl_iter);
|
||||||
|
/* Don't call our own libraries again and only care for already loaded plugins */
|
||||||
|
if (pl == pPlugin || pl->GetStatus() != Plugin_Running)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
for (s_iter=pl->m_Libraries.begin(); s_iter!=pl->m_Libraries.end(); s_iter++)
|
||||||
|
{
|
||||||
|
pPlugin->Call_OnLibraryAdded((*s_iter).c_str());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -204,6 +204,11 @@ public:
|
|||||||
*/
|
*/
|
||||||
void Call_OnAllPluginsLoaded();
|
void Call_OnAllPluginsLoaded();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Calls the OnLibraryAdded function.
|
||||||
|
*/
|
||||||
|
void Call_OnLibraryAdded(const char *lib);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns true if a plugin is usable.
|
* Returns true if a plugin is usable.
|
||||||
*/
|
*/
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user