2
0
mirror of https://github.com/rehlds/metamod-r.git synced 2025-03-03 17:15:26 +03:00

UNDONE: Gracefully shutdown metamod plugins for dedicated server (amxx modules unload unstable)

This commit is contained in:
s1lentq 2024-01-16 00:35:31 +07:00
parent 265a818856
commit 096f4383b0
3 changed files with 5 additions and 1 deletions

View File

@ -16,7 +16,8 @@ NEW_DLL_FUNCTIONS *pHookedNewDllFunctions = &sNewFunctionTable;
void MM_POST_HOOK EXT_FUNC mm_GameShutdown() void MM_POST_HOOK EXT_FUNC mm_GameShutdown()
{ {
g_metamod_active = false; 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_meta_extdll.unload();
g_GameDLL.sys_module.unload(); g_GameDLL.sys_module.unload();
g_engine.sys_module.unload(); g_engine.sys_module.unload();

View File

@ -35,6 +35,7 @@ unsigned int g_CALL_API_count = 0;
int g_requestid_counter = 0; int g_requestid_counter = 0;
bool g_metamod_active = false; bool g_metamod_active = false;
bool g_dedicated_server = false;
// Very first metamod function that's run. // Very first metamod function that's run.
// Do startup operations... // Do startup operations...
@ -166,6 +167,7 @@ void metamod_startup()
g_engine.pl_funcs.pfnCVarRegister = meta_CVarRegister; g_engine.pl_funcs.pfnCVarRegister = meta_CVarRegister;
g_engine.pl_funcs.pfnCvar_RegisterVariable = meta_CVarRegister; g_engine.pl_funcs.pfnCvar_RegisterVariable = meta_CVarRegister;
g_engine.pl_funcs.pfnRegUserMsg = meta_RegUserMsg; g_engine.pl_funcs.pfnRegUserMsg = meta_RegUserMsg;
g_dedicated_server = g_engine.pl_funcs.pfnIsDedicatedServer() ? true : false;
if (g_engine.pl_funcs.pfnQueryClientCvarValue) if (g_engine.pl_funcs.pfnQueryClientCvarValue)
g_engine.pl_funcs.pfnQueryClientCvarValue = meta_QueryClientCvarValue; g_engine.pl_funcs.pfnQueryClientCvarValue = meta_QueryClientCvarValue;

View File

@ -78,6 +78,7 @@ extern unsigned int g_CALL_API_count;
extern int g_requestid_counter; extern int g_requestid_counter;
extern bool g_metamod_active; extern bool g_metamod_active;
extern bool g_dedicated_server;
// (patch by BAILOPAN) // (patch by BAILOPAN)
// Holds cached player info, right now only things for querying cvars // Holds cached player info, right now only things for querying cvars