From 096f4383b0146218ec4b1be0cb515b54af76e356 Mon Sep 17 00:00:00 2001 From: s1lentq Date: Tue, 16 Jan 2024 00:35:31 +0700 Subject: [PATCH] UNDONE: Gracefully shutdown metamod plugins for dedicated server (amxx modules unload unstable) --- metamod/src/dllapi.cpp | 3 ++- metamod/src/metamod.cpp | 2 ++ metamod/src/metamod.h | 1 + 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/metamod/src/dllapi.cpp b/metamod/src/dllapi.cpp index 94e726e..ea3bc80 100644 --- a/metamod/src/dllapi.cpp +++ b/metamod/src/dllapi.cpp @@ -16,7 +16,8 @@ NEW_DLL_FUNCTIONS *pHookedNewDllFunctions = &sNewFunctionTable; void MM_POST_HOOK EXT_FUNC mm_GameShutdown() { g_metamod_active = false; - if (g_plugins) g_plugins->unload_all(); + if (g_plugins && !g_dedicated_server) g_plugins->unload_all(); + g_meta_extdll.unload(); g_GameDLL.sys_module.unload(); g_engine.sys_module.unload(); diff --git a/metamod/src/metamod.cpp b/metamod/src/metamod.cpp index 6d9d188..02eeff8 100644 --- a/metamod/src/metamod.cpp +++ b/metamod/src/metamod.cpp @@ -35,6 +35,7 @@ unsigned int g_CALL_API_count = 0; int g_requestid_counter = 0; bool g_metamod_active = false; +bool g_dedicated_server = false; // Very first metamod function that's run. // Do startup operations... @@ -166,6 +167,7 @@ void metamod_startup() g_engine.pl_funcs.pfnCVarRegister = meta_CVarRegister; g_engine.pl_funcs.pfnCvar_RegisterVariable = meta_CVarRegister; g_engine.pl_funcs.pfnRegUserMsg = meta_RegUserMsg; + g_dedicated_server = g_engine.pl_funcs.pfnIsDedicatedServer() ? true : false; if (g_engine.pl_funcs.pfnQueryClientCvarValue) g_engine.pl_funcs.pfnQueryClientCvarValue = meta_QueryClientCvarValue; diff --git a/metamod/src/metamod.h b/metamod/src/metamod.h index 49f755e..cee2e4e 100644 --- a/metamod/src/metamod.h +++ b/metamod/src/metamod.h @@ -78,6 +78,7 @@ extern unsigned int g_CALL_API_count; extern int g_requestid_counter; extern bool g_metamod_active; +extern bool g_dedicated_server; // (patch by BAILOPAN) // Holds cached player info, right now only things for querying cvars