mirror of
https://github.com/alliedmodders/sourcemod.git
synced 2025-12-06 18:08:36 +00:00
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
676ac95111
@ -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()
|
||||
{
|
||||
return NULL;
|
||||
@ -1402,6 +1420,22 @@ bool CPluginManager::RunSecondPass(CPlugin *pPlugin, char *error, size_t maxleng
|
||||
OnLibraryAction((*s_iter).c_str(), LibraryAction_Added);
|
||||
}
|
||||
|
||||
/* Go through all other already loaded plugins and tell this plugin, that their libraries are loaded */
|
||||
List<CPlugin *>::iterator pl_iter;
|
||||
CPlugin *pl;
|
||||
for (pl_iter=m_plugins.begin(); pl_iter!=m_plugins.end(); pl_iter++)
|
||||
{
|
||||
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());
|
||||
}
|
||||
}
|
||||
|
||||
/* :TODO: optimize? does this even matter? */
|
||||
pPlugin->GetPhrases()->AddPhraseFile("core.phrases");
|
||||
|
||||
|
||||
@ -204,6 +204,11 @@ public:
|
||||
*/
|
||||
void Call_OnAllPluginsLoaded();
|
||||
|
||||
/**
|
||||
* Calls the OnLibraryAdded function.
|
||||
*/
|
||||
void Call_OnLibraryAdded(const char *lib);
|
||||
|
||||
/**
|
||||
* Returns true if a plugin is usable.
|
||||
*/
|
||||
|
||||
Loading…
Reference in New Issue
Block a user