From c9a9826989cf5310cd1b9bea405584609ab3b1de Mon Sep 17 00:00:00 2001 From: David Anderson Date: Fri, 14 Dec 2007 06:42:40 +0000 Subject: [PATCH] added amb968 - setting for suppressing potential chat triggers from admins --HG-- extra : convert_revision : svn%3A39bc706e-5318-0410-9160-8a85361fbb7c/trunk%401800 --- configs/core.cfg | 9 +++++++++ core/ChatTriggers.cpp | 21 +++++++++++++++++++-- 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/configs/core.cfg b/configs/core.cfg index c0d83e91..bafb12b9 100644 --- a/configs/core.cfg +++ b/configs/core.cfg @@ -47,6 +47,15 @@ */ "SilentChatTrigger" "/" + /** + * If a say command is a silent chat trigger, and is used by an admin, + * but it does not evaluate to an actual command, it will be displayed + * publicly. This setting allows you to suppress accidental typings. + * + * The default value is "no". A value of "yes" will supress. + */ + "SilentFailSuppress" "no" + /** * Password setinfo key that clients must set. You must change this in order for * passwords to work, for security reasons. diff --git a/core/ChatTriggers.cpp b/core/ChatTriggers.cpp index e3841ee1..e7526b94 100644 --- a/core/ChatTriggers.cpp +++ b/core/ChatTriggers.cpp @@ -33,7 +33,7 @@ #include "ChatTriggers.h" #include "sm_stringutil.h" #include "ConCmdManager.h" -#include +#include "PlayerManager.h" /* :HACKHACK: We can't SH_DECL here because ConCmdManager.cpp does. * While the OB build only runs on MM:S 1.6.0+ (SH 5+), the older one @@ -54,6 +54,7 @@ extern bool __SourceHook_FHAddConCommandDispatch(void *, bool, class fastdelegat #endif //ORANGEBOX_BUILD ChatTriggers g_ChatTriggers; +bool g_bSupressSilentFails = false; ChatTriggers::ChatTriggers() : m_pSayCmd(NULL), m_bWillProcessInPost(false), m_bTriggerWasSilent(false), m_ReplyTo(SM_REPLY_CONSOLE) @@ -85,12 +86,19 @@ ConfigResult ChatTriggers::OnSourceModConfigChanged(const char *key, m_PubTrigger = sm_strdup(value); m_PubTriggerSize = strlen(m_PubTrigger); return ConfigResult_Accept; - } else if (strcmp(key, "SilentChatTrigger") == 0) { + } + else if (strcmp(key, "SilentChatTrigger") == 0) + { delete [] m_PrivTrigger; m_PrivTrigger = sm_strdup(value); m_PrivTriggerSize = strlen(m_PrivTrigger); return ConfigResult_Accept; } + else if (strcmp(key, "SilentFailSuppress") == 0) + { + g_bSupressSilentFails = strcmp(value, "yes") == 0; + return ConfigResult_Accept; + } return ConfigResult_Ignore; } @@ -205,6 +213,15 @@ void ChatTriggers::OnSayCommand_Pre() */ if (!PreProcessTrigger(engine->PEntityOfEntIndex(client), args, is_quoted)) { + CPlayer *pPlayer; + if (is_silent + && g_bSupressSilentFails + && client != 0 + && (pPlayer = g_Players.GetPlayerByIndex(client)) != NULL + && pPlayer->GetAdminId() != INVALID_ADMIN_ID) + { + RETURN_META(MRES_SUPERCEDE); + } RETURN_META(MRES_IGNORED); }