diff --git a/core/sourcemod.cpp b/core/sourcemod.cpp index 5ef27d6c..738253cf 100644 --- a/core/sourcemod.cpp +++ b/core/sourcemod.cpp @@ -50,6 +50,7 @@ #include "MenuStyle_Radio.h" #include "Database.h" #include "HalfLife2.h" +#include "GameConfigs.h" SH_DECL_HOOK6(IServerGameDLL, LevelInit, SH_NOATTRIB, false, bool, const char *, const char *, const char *, const char *, bool, bool); SH_DECL_HOOK0_void(IServerGameDLL, LevelShutdown, SH_NOATTRIB, false); @@ -72,6 +73,7 @@ IForward *g_pOnMapEnd = NULL; bool g_Loaded = false; int g_StillFrames = 0; float g_StillTime = 0.0f; +IExtension *g_pGameExt = NULL; typedef int (*GIVEENGINEPOINTER)(ISourcePawnEngine *); typedef int (*GIVEENGINEPOINTER2)(ISourcePawnEngine *, unsigned int api_version); @@ -518,6 +520,15 @@ void SourceModBase::DoGlobalPluginLoads() /* Load any auto extensions */ g_Extensions.TryAutoload(); + /* Load any game extension */ + const char *game_ext; + if ((game_ext = g_pGameConf->GetKeyValue("GameExtension")) != NULL) + { + char path[PLATFORM_MAX_PATH]; + UTIL_Format(path, sizeof(path), "%s.ext." PLATFORM_LIB_EXT, game_ext); + g_pGameExt = g_Extensions.LoadAutoExtension(path); + } + /* Run the first pass */ g_PluginSys.LoadAll_FirstPass(config_path, plugins_path); diff --git a/core/sourcemod.h b/core/sourcemod.h index f00e7068..53a4e01b 100644 --- a/core/sourcemod.h +++ b/core/sourcemod.h @@ -142,5 +142,6 @@ private: extern SourceModBase g_SourceMod; extern HandleType_t g_WrBitBufType; //:TODO: find a better place for this extern HandleType_t g_RdBitBufType; //:TODO: find a better place for this +extern IExtension *g_pGameExt; #endif //_INCLUDE_SOURCEMOD_GLOBALHEADER_H_ diff --git a/core/systems/ExtensionSys.cpp b/core/systems/ExtensionSys.cpp index 90217fd8..57376cf1 100644 --- a/core/systems/ExtensionSys.cpp +++ b/core/systems/ExtensionSys.cpp @@ -720,6 +720,12 @@ bool CExtensionManager::UnloadExtension(IExtension *_pExt) } } + /* :HACKHACK: make sure g_pGameExt gets cleared */ + if (pExt == g_pGameExt) + { + g_pGameExt = NULL; + } + delete pExt; List<CExtension *>::iterator iter; @@ -904,6 +910,12 @@ void CExtensionManager::OnRootConsoleCommand(const char *cmd, unsigned int argco return; } + if (pExt == g_pGameExt) + { + g_RootMenu.ConsolePrint("[SM] Game extensions cannot be unloaded at this time."); + return; + } + if (argcount > 4 && pExt->unload_code) { const char *unload = g_RootMenu.GetArgument(4);