added a layer for autoloading per-game extensions

--HG--
extra : convert_revision : svn%3A39bc706e-5318-0410-9160-8a85361fbb7c/trunk%401386
This commit is contained in:
David Anderson 2007-08-29 00:27:54 +00:00
parent 437f6543d7
commit 6bb7b3a1f8
3 changed files with 24 additions and 0 deletions

View File

@ -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);

View File

@ -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_

View File

@ -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);