Skip to content

Commit

Permalink
UNDONE: Gracefully shutdown metamod plugins for dedicated server (amx…
Browse files Browse the repository at this point in the history
…x modules unload unstable)
  • Loading branch information
s1lentq committed Jan 15, 2024
1 parent 265a818 commit 096f438
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 1 deletion.
3 changes: 2 additions & 1 deletion metamod/src/dllapi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 2 additions & 0 deletions metamod/src/metamod.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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...
Expand Down Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions metamod/src/metamod.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 096f438

Please sign in to comment.