From 7ab88f2020c90b1d1835a954906ad112e77ecafd Mon Sep 17 00:00:00 2001 From: David Anderson Date: Wed, 6 Jun 2007 22:31:54 +0000 Subject: [PATCH] added config options for chat triggers --HG-- extra : convert_revision : svn%3A39bc706e-5318-0410-9160-8a85361fbb7c/trunk%40902 --- configs/core.cfg | 10 ++++++++++ core/ChatTriggers.cpp | 23 +++++++++++++++++++++++ core/ChatTriggers.h | 5 +++++ 3 files changed, 38 insertions(+) diff --git a/configs/core.cfg b/configs/core.cfg index 43e0fb45..c6507415 100644 --- a/configs/core.cfg +++ b/configs/core.cfg @@ -36,4 +36,14 @@ * The default value is "en" */ "ServerLang" "en" + + /** + * String to use as the public chat trigger. Set an empty string to disable. + */ + "PublicChatTrigger" "!" + + /** + * String to use as the silent chat trigger. Set an empty string to disable. + */ + "SilentChatTrigger" "/" } diff --git a/core/ChatTriggers.cpp b/core/ChatTriggers.cpp index 65b5660a..5a9260a4 100644 --- a/core/ChatTriggers.cpp +++ b/core/ChatTriggers.cpp @@ -18,6 +18,29 @@ ChatTriggers::ChatTriggers() : m_pSayCmd(NULL), m_bWillProcessInPost(false), m_PrivTriggerSize = 1; } + +ConfigResult ChatTriggers::OnSourceModConfigChanged(const char *key, + const char *value, + ConfigSource source, + char *error, + size_t maxlength) +{ + if (strcmp(key, "PublicChatTrigger") == 0) + { + delete [] m_PubTrigger; + m_PubTrigger = sm_strdup(value); + m_PubTriggerSize = strlen(m_PubTrigger); + return ConfigResult_Accept; + } else if (strcmp(key, "SilentChatTrigger") == 0) { + delete [] m_PrivTrigger; + m_PrivTrigger = sm_strdup(value); + m_PrivTriggerSize = strlen(m_PrivTrigger); + return ConfigResult_Accept; + } + + return ConfigResult_Ignore; +} + void ChatTriggers::OnSourceModGameInitialized() { ConCommandBase *pCmd = icvar->GetCommands(); diff --git a/core/ChatTriggers.h b/core/ChatTriggers.h index 8000b947..b47a1eb6 100644 --- a/core/ChatTriggers.h +++ b/core/ChatTriggers.h @@ -14,6 +14,11 @@ public: public: //SMGlobalClass void OnSourceModGameInitialized(); void OnSourceModShutdown(); + ConfigResult OnSourceModConfigChanged(const char *key, + const char *value, + ConfigSource source, + char *error, + size_t maxlength); private: //ConCommand void OnSayCommand_Pre(); void OnSayCommand_Post();