From 29b0f402f197c8d986720755c749c5f56b193b98 Mon Sep 17 00:00:00 2001 From: asmodai Date: Sat, 11 Mar 2017 19:12:09 +0300 Subject: [PATCH] Added clientmeta option --- metamod/src/conf_meta.h | 1 + metamod/src/dllapi.cpp | 6 ++++++ metamod/src/dllapi.h | 1 + metamod/src/metamod.cpp | 16 +++++++++++++--- 4 files changed, 21 insertions(+), 3 deletions(-) diff --git a/metamod/src/conf_meta.h b/metamod/src/conf_meta.h index 30da64f..6540fcb 100644 --- a/metamod/src/conf_meta.h +++ b/metamod/src/conf_meta.h @@ -36,6 +36,7 @@ public: int m_debuglevel; // to use for meta_debug char *m_gamedll; // string if specified in config.ini char *m_exec_cfg; // ie exec.cfg + int m_clientmeta; private: option_t *m_list; diff --git a/metamod/src/dllapi.cpp b/metamod/src/dllapi.cpp index 65f2d9e..0a80724 100644 --- a/metamod/src/dllapi.cpp +++ b/metamod/src/dllapi.cpp @@ -22,6 +22,7 @@ void MM_PRE_HOOK EXT_FUNC mm_ClientDisconnect(edict_t *pEntity) g_players.clear_player_cvar_query(pEntity); } +// this forward can be disabled from metamod.cpp void MM_PRE_HOOK mm_ClientCommand(edict_t *pEntity) { if (!strcmp(CMD_ARGV(0), "meta")) { @@ -281,3 +282,8 @@ void compile_gamedll_callbacks() compile_dllfunc_callbacks(); compile_newdllfunc_callbacks(); } + +void disable_clientcommand_fwd() +{ + g_dllfunc_cdata[offsetof(DLL_FUNCTIONS, pfnClientCommand) / sizeof(int)].mm_hook = 0; +} diff --git a/metamod/src/dllapi.h b/metamod/src/dllapi.h index 2b23a63..edbf9de 100644 --- a/metamod/src/dllapi.h +++ b/metamod/src/dllapi.h @@ -14,4 +14,5 @@ C_DLLEXPORT int GetNewDLLFunctions(NEW_DLL_FUNCTIONS *pNewFunctionTable, int *in #ifdef METAMOD_CORE void compile_gamedll_callbacks(); +void disable_clientcommand_fwd(); #endif diff --git a/metamod/src/metamod.cpp b/metamod/src/metamod.cpp index 83fdd7a..bc3cbb9 100644 --- a/metamod/src/metamod.cpp +++ b/metamod/src/metamod.cpp @@ -7,11 +7,12 @@ MConfig *g_config = &g_static_config; option_t g_global_options[] = { { "debuglevel", CF_INT, &g_config->m_debuglevel, "0" }, - { "gamedll", CF_PATH, &g_config->m_gamedll, NULL }, - { "exec_cfg", CF_STR, &g_config->m_exec_cfg, NULL }, + { "gamedll", CF_PATH, &g_config->m_gamedll, nullptr }, + { "exec_cfg", CF_STR, &g_config->m_exec_cfg, nullptr }, + { "clientmeta", CF_BOOL, &g_config->m_clientmeta, false }, // list terminator - { NULL, CF_NONE, NULL, NULL } + { nullptr, CF_NONE, nullptr, nullptr } }; gamedll_t g_GameDLL; @@ -139,11 +140,20 @@ void metamod_startup() g_config->set("exec_cfg", cp); } + if ((cp = LOCALINFO("mm_clientmeta")) && *cp != '\0') + { + META_LOG("Clientmeta specified via localinfo: %s", cp); + g_config->set("clientmeta", cp); + } + // Check for an initial debug level, since cfg files don't get exec'd // until later. if (g_config->m_debuglevel != 0) CVAR_SET_FLOAT("meta_debug", g_config->m_debuglevel); + if (!g_config->m_clientmeta) + disable_clientcommand_fwd(); + // Prepare for registered commands from plugins. g_regCmds = new MRegCmdList(); g_regCvars = new MRegCvarList();