From e13c228c5a95dfeba4fc6fe052ae8aed000aa313 Mon Sep 17 00:00:00 2001 From: Borja Ferrer Date: Sat, 13 Jan 2007 04:28:13 +0000 Subject: [PATCH] SMGlobalClass unloads now --HG-- extra : convert_revision : svn%3A39bc706e-5318-0410-9160-8a85361fbb7c/trunk%40294 --- TODO.txt | 2 +- core/sourcemm_api.cpp | 1 + core/sourcemod.cpp | 22 ++++++++++++++++++++++ core/sourcemod.h | 5 +++++ 4 files changed, 29 insertions(+), 1 deletion(-) 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 */