diff -r 0adfab7ecca7 -r 81b14823a2c3 sourcemm/sourcemm.cpp --- a/sourcemm/sourcemm.cpp Sat Jun 25 12:55:26 2005 +0000 +++ b/sourcemm/sourcemm.cpp Sun Jun 26 19:15:24 2005 +0000 @@ -256,6 +256,18 @@ return false; } +void Shutdown() +{ + //Unload plugins + g_PluginMngr.UnloadAll(); + + // Shutdown sourcehook now + g_SourceHook.CompleteShutdown(); + + // Add the FCVAR_GAMEDLL flag to our cvars so the engine removes them properly + g_SMConVarAccessor.MarkCommandsAsGameDLL(); +} + // The engine uses the DLL even after it has call DLLShutdown, so we unload it // when it unloads us #if defined _WIN32 @@ -267,6 +279,8 @@ { if (fdwReason == DLL_PROCESS_DETACH) { + if (!bInShutdown) + Shutdown(); if (g_GameDll.lib && g_GameDll.loaded) dlclose(g_GameDll.lib); memset(&g_GameDll, 0, sizeof(GameDllInfo)); @@ -276,6 +290,8 @@ #elif defined __linux__ void __attribute__ ((destructor)) app_fini(void) { + if (!bInShutdown()) + Shutdown(); if (g_GameDll.lib && g_GameDll.loaded) dlclose(g_GameDll.lib); memset(&g_GameDll, 0, sizeof(GameDllInfo)); @@ -284,17 +300,12 @@ void CServerGameDLL::DLLShutdown() { + Shutdown(); + //Call the original function m_pOrig->DLLShutdown(); - //Unload plugins - g_PluginMngr.UnloadAll(); - - // Shutdown sourcehook now - g_SourceHook.CompleteShutdown(); - - // Add the FCVAR_GAMEDLL flag to our cvars so the engine removes them properly - g_SMConVarAccessor.MarkCommandsAsGameDLL(); + bInShutdown = true; } int LoadPluginsFromFile(const char *file)