1.1 --- a/core/sourcemod.cpp Fri Jan 19 23:30:22 2007 +0000
1.2 +++ b/core/sourcemod.cpp Sat Jan 20 02:12:53 2007 +0000
1.3 @@ -10,6 +10,7 @@
1.4 #include "ExtensionSys.h"
1.5
1.6 SH_DECL_HOOK6(IServerGameDLL, LevelInit, SH_NOATTRIB, false, bool, const char *, const char *, const char *, const char *, bool, bool);
1.7 +SH_DECL_HOOK0_void(IServerGameDLL, LevelShutdown, SH_NOATTRIB, false);
1.8
1.9 SourcePawnEngine g_SourcePawn;
1.10 SourceModBase g_SourceMod;
1.11 @@ -39,6 +40,7 @@
1.12 SourceModBase::SourceModBase()
1.13 {
1.14 m_IsMapLoading = false;
1.15 + m_ExecPluginReload = false;
1.16 }
1.17
1.18 bool SourceModBase::InitializeSourceMod(char *error, size_t err_max, bool late)
1.19 @@ -131,6 +133,7 @@
1.20 {
1.21 /* First initialize the global hooks we need */
1.22 SH_ADD_HOOK_MEMFUNC(IServerGameDLL, LevelInit, gamedll, this, &SourceModBase::LevelInit, false);
1.23 + SH_ADD_HOOK_MEMFUNC(IServerGameDLL, LevelShutdown, gamedll, this, &SourceModBase::LevelShutdown, false);
1.24
1.25 /* Notify! */
1.26 SMGlobalClass *pBase = SMGlobalClass::head;
1.27 @@ -158,6 +161,7 @@
1.28 bool SourceModBase::LevelInit(char const *pMapName, char const *pMapEntities, char const *pOldLevel, char const *pLandmarkName, bool loadGame, bool background)
1.29 {
1.30 m_IsMapLoading = true;
1.31 + m_ExecPluginReload = true;
1.32
1.33 g_Logger.MapChange(pMapName);
1.34
1.35 @@ -168,6 +172,15 @@
1.36 RETURN_META_VALUE(MRES_IGNORED, true);
1.37 }
1.38
1.39 +void SourceModBase::LevelShutdown()
1.40 +{
1.41 + if (m_ExecPluginReload)
1.42 + {
1.43 + g_PluginSys.ReloadOrUnloadPlugins();
1.44 + m_ExecPluginReload = false;
1.45 + }
1.46 +}
1.47 +
1.48 bool SourceModBase::IsMapLoading()
1.49 {
1.50 return m_IsMapLoading;
1.51 @@ -241,6 +254,9 @@
1.52 pBase = pBase->m_pGlobalClassNext;
1.53 }
1.54
1.55 + SH_REMOVE_HOOK_MEMFUNC(IServerGameDLL, LevelInit, gamedll, this, &SourceModBase::LevelInit, false);
1.56 + SH_REMOVE_HOOK_MEMFUNC(IServerGameDLL, LevelShutdown, gamedll, this, &SourceModBase::LevelShutdown, false);
1.57 +
1.58 /* Rest In Peace */
1.59 ShutdownJIT();
1.60 }