Cleanly remove all hooks on extension unload

Allows to e.g. reload sdktools during runtime without crashing. Useful for fast development cycles.
This commit is contained in:
Peace-Maker
2020-12-16 15:52:48 +01:00
committed by peace-maker
parent e59fd9de96
commit ba8753836e
8 changed files with 109 additions and 14 deletions
-8
View File
@@ -63,11 +63,7 @@ bool g_forcedChange = false;
void NextMapManager::OnSourceModAllInitialized_Post()
{
#if SOURCE_ENGINE >= SE_ORANGEBOX
SH_ADD_HOOK(IVEngineServer, ChangeLevel, engine, SH_MEMBER(this, &NextMapManager::HookChangeLevel), false);
#else
SH_ADD_HOOK(IVEngineServer, ChangeLevel, engine, SH_MEMBER(this, &NextMapManager::HookChangeLevel), false);
#endif
ConCommand *pCmd = FindCommand("changelevel");
if (pCmd != NULL)
@@ -79,11 +75,7 @@ void NextMapManager::OnSourceModAllInitialized_Post()
void NextMapManager::OnSourceModShutdown()
{
#if SOURCE_ENGINE >= SE_ORANGEBOX
SH_REMOVE_HOOK(IVEngineServer, ChangeLevel, engine, SH_MEMBER(this, &NextMapManager::HookChangeLevel), false);
#else
SH_REMOVE_HOOK(IVEngineServer, ChangeLevel, engine, SH_MEMBER(this, &NextMapManager::HookChangeLevel), false);
#endif
if (changeLevelCmd != NULL)
{
+1 -6
View File
@@ -846,11 +846,7 @@ CPluginManager::~CPluginManager()
void CPluginManager::Shutdown()
{
List<CPlugin *>::iterator iter;
for (PluginIter iter(m_plugins); !iter.done(); iter.next()) {
UnloadPlugin(*iter);
}
UnloadAll();
}
void CPluginManager::LoadAll(const char *config_path, const char *plugins_path)
@@ -2208,7 +2204,6 @@ void CPluginManager::UnloadAll()
int CPluginManager::GetOrderOfPlugin(IPlugin *pl)
{
int id = 1;
List<CPlugin *>::iterator iter;
for (PluginIter iter(m_plugins); !iter.done(); iter.next()) {
if ((*iter) == pl)