diff --git a/core/logic/ExtensionSys.cpp b/core/logic/ExtensionSys.cpp index 4406a7943a..d53309463a 100644 --- a/core/logic/ExtensionSys.cpp +++ b/core/logic/ExtensionSys.cpp @@ -1286,6 +1286,24 @@ bool CExtensionManager::LibraryExists(const char *library) return false; } +void CExtensionManager::ForEachLibrary(ke::Function callback) +{ + for (List::iterator iter = m_Libs.begin(); + iter != m_Libs.end(); + iter++) + { + CExtension *pExt = (*iter); + if (!pExt->IsLoaded()) + continue; + for (List::iterator s_iter = pExt->m_Libraries.begin(); + s_iter != pExt->m_Libraries.end(); + s_iter++) + { + callback((*s_iter).c_str()); + } + } +} + IExtension *CExtensionManager::LoadExternal(IExtensionInterface *pInterface, const char *filepath, const char *filename, diff --git a/core/logic/ExtensionSys.h b/core/logic/ExtensionSys.h index 6687057cc0..b579987b17 100644 --- a/core/logic/ExtensionSys.h +++ b/core/logic/ExtensionSys.h @@ -42,6 +42,7 @@ #include "NativeOwner.h" #include "ShareSys.h" #include +#include class CPlayer; @@ -175,6 +176,7 @@ class CExtensionManager : void TryAutoload(); void AddLibrary(IExtension *pSource, const char *library); bool LibraryExists(const char *library); + void ForEachLibrary(ke::Function callback); void CallOnCoreMapStart(edict_t *pEdictList, int edictCount, int clientMax); void CallOnCoreMapEnd(); void AddRawDependency(IExtension *ext, IdentityToken_t *other, void *iface); diff --git a/core/logic/PluginSys.cpp b/core/logic/PluginSys.cpp index 74d4161dc3..753c4cfd72 100644 --- a/core/logic/PluginSys.cpp +++ b/core/logic/PluginSys.cpp @@ -1394,6 +1394,11 @@ bool CPluginManager::RunSecondPass(CPlugin *pPlugin) }); } + // Go through all loaded extension libraries and tell this plugin they're loaded. + g_Extensions.ForEachLibrary([pPlugin] (const char *lib) -> void { + pPlugin->Call_OnLibraryAdded(lib); + }); + return true; }