diff --git a/TODO.txt b/TODO.txt index e1049ca0..73923ed6 100644 --- a/TODO.txt +++ b/TODO.txt @@ -7,5 +7,5 @@ things to do for a release, in priority X add debugging output to logger - finish ML api, expose through interface X add error messages to format routine - - finish global unloading + X finish global unloading - add hex format specifier diff --git a/core/sourcemm_api.cpp b/core/sourcemm_api.cpp index 1b593456..bf2f884c 100644 --- a/core/sourcemm_api.cpp +++ b/core/sourcemm_api.cpp @@ -23,6 +23,7 @@ bool SourceMod_Core::Load(PluginId id, ISmmAPI *ismm, char *error, size_t maxlen bool SourceMod_Core::Unload(char *error, size_t maxlen) { + g_SourceMod.CloseSourceMod(); return true; } diff --git a/core/sourcemod.cpp b/core/sourcemod.cpp index b0cf9650..11ea03d1 100644 --- a/core/sourcemod.cpp +++ b/core/sourcemod.cpp @@ -187,6 +187,28 @@ void SourceModBase::DoGlobalPluginLoads() g_PluginSys.LoadAll_SecondPass(); } +void SourceModBase::CloseSourceMod() +{ + /* Notify! */ + SMGlobalClass *pBase = SMGlobalClass::head; + while (pBase) + { + pBase->OnSourceModShutdown(); + pBase = pBase->m_pGlobalClassNext; + } + + /* Notify! */ + pBase = SMGlobalClass::head; + while (pBase) + { + pBase->OnSourceModAllShutdown(); + pBase = pBase->m_pGlobalClassNext; + } + + /* Rest In Peace */ + ShutdownJIT(); +} + bool SourceModBase::IsLateLoadInMap() { return m_IsLateLoadInMap; diff --git a/core/sourcemod.h b/core/sourcemod.h index 1dcec7c3..38a3d217 100644 --- a/core/sourcemod.h +++ b/core/sourcemod.h @@ -22,6 +22,11 @@ public: */ void StartSourceMod(bool late); + /** + * @brief Shuts down all SourceMod components + */ + void CloseSourceMod(); + /** * @brief Map change hook */