Call OnLibraryAdded for all available librarys (bug 5925, pull request #4)

commit c1b064c9232553045f6f5bfaf7df0feb6ceb4571
Author: Peace-Maker <peace-maker@wcfan.de>
Date:   Wed May 28 03:16:22 2014 +0200

    Coding style adjustments

commit 37a16dbba24cc2035fb8838be8729067cb9bc13a
Author: Peace-Maker <peace-maker@wcfan.de>
Date:   Wed May 28 03:03:25 2014 +0200

    Load core.phrases before calling OnLibraryAdded

commit 676ac951111c7e8f565debbd4316850a4c4a8d00
Author: 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:
David Anderson 2014-05-27 19:24:33 -07:00
parent 84de0f6b85
commit ac11eb8910
2 changed files with 37 additions and 0 deletions

View File

@ -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;
@ -1404,6 +1422,20 @@ bool CPluginManager::RunSecondPass(CPlugin *pPlugin, char *error, size_t maxleng
/* :TODO: optimize? does this even matter? */
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;
}

View File

@ -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.
*/