1.1 --- a/sourcemm/sourcemm.cpp Sat Jun 25 12:55:26 2005 +0000
1.2 +++ b/sourcemm/sourcemm.cpp Sun Jun 26 19:15:24 2005 +0000
1.3 @@ -256,6 +256,18 @@
1.4 return false;
1.5 }
1.6
1.7 +void Shutdown()
1.8 +{
1.9 + //Unload plugins
1.10 + g_PluginMngr.UnloadAll();
1.11 +
1.12 + // Shutdown sourcehook now
1.13 + g_SourceHook.CompleteShutdown();
1.14 +
1.15 + // Add the FCVAR_GAMEDLL flag to our cvars so the engine removes them properly
1.16 + g_SMConVarAccessor.MarkCommandsAsGameDLL();
1.17 +}
1.18 +
1.19 // The engine uses the DLL even after it has call DLLShutdown, so we unload it
1.20 // when it unloads us
1.21 #if defined _WIN32
1.22 @@ -267,6 +279,8 @@
1.23 {
1.24 if (fdwReason == DLL_PROCESS_DETACH)
1.25 {
1.26 + if (!bInShutdown)
1.27 + Shutdown();
1.28 if (g_GameDll.lib && g_GameDll.loaded)
1.29 dlclose(g_GameDll.lib);
1.30 memset(&g_GameDll, 0, sizeof(GameDllInfo));
1.31 @@ -276,6 +290,8 @@
1.32 #elif defined __linux__
1.33 void __attribute__ ((destructor)) app_fini(void)
1.34 {
1.35 + if (!bInShutdown())
1.36 + Shutdown();
1.37 if (g_GameDll.lib && g_GameDll.loaded)
1.38 dlclose(g_GameDll.lib);
1.39 memset(&g_GameDll, 0, sizeof(GameDllInfo));
1.40 @@ -284,17 +300,12 @@
1.41
1.42 void CServerGameDLL::DLLShutdown()
1.43 {
1.44 + Shutdown();
1.45 +
1.46 //Call the original function
1.47 m_pOrig->DLLShutdown();
1.48
1.49 - //Unload plugins
1.50 - g_PluginMngr.UnloadAll();
1.51 -
1.52 - // Shutdown sourcehook now
1.53 - g_SourceHook.CompleteShutdown();
1.54 -
1.55 - // Add the FCVAR_GAMEDLL flag to our cvars so the engine removes them properly
1.56 - g_SMConVarAccessor.MarkCommandsAsGameDLL();
1.57 + bInShutdown = true;
1.58 }
1.59
1.60 int LoadPluginsFromFile(const char *file)