From 6048144310303d7c239ba43c5755c7da9986e042 Mon Sep 17 00:00:00 2001 From: David Anderson Date: Sun, 1 Feb 2009 02:13:17 -0500 Subject: [PATCH] RegConsoleCmd is now case insensitive for client-only commands (bug 3602, r=ds). --- core/ConCmdManager.cpp | 79 ++++++++++++++++++++++++++---------------- 1 file changed, 50 insertions(+), 29 deletions(-) diff --git a/core/ConCmdManager.cpp b/core/ConCmdManager.cpp index aaf33a1d..119f2fd1 100644 --- a/core/ConCmdManager.cpp +++ b/core/ConCmdManager.cpp @@ -229,46 +229,67 @@ void ConCmdManager::SetCommandClient(int client) ResultType ConCmdManager::DispatchClientCommand(int client, const char *cmd, int args, ResultType type) { ConCmdInfo *pInfo; - if (sm_trie_retrieve(m_pCmds, cmd, (void **)&pInfo)) + + if (!sm_trie_retrieve(m_pCmds, cmd, (void **)&pInfo)) { - cell_t result = type; - cell_t tempres = result; - List::iterator iter; - CmdHook *pHook; - for (iter=pInfo->conhooks.begin(); - iter!=pInfo->conhooks.end(); - iter++) + List::iterator iter; + + pInfo = NULL; + iter = m_CmdList.begin(); + while (iter != m_CmdList.end()) { - pHook = (*iter); - if (!pHook->pf->IsRunnable()) + if (strcasecmp((*iter)->pCmd->GetName(), cmd) == 0) { - continue; + pInfo = (*iter); + break; } - if (pHook->pAdmin && !CheckAccess(client, cmd, pHook->pAdmin)) + iter++; + } + + if (pInfo == NULL) + { + return type; + } + } + + cell_t result = type; + cell_t tempres = result; + List::iterator iter; + CmdHook *pHook; + for (iter=pInfo->conhooks.begin(); + iter!=pInfo->conhooks.end(); + iter++) + { + pHook = (*iter); + if (!pHook->pf->IsRunnable()) + { + continue; + } + if (pHook->pAdmin && !CheckAccess(client, cmd, pHook->pAdmin)) + { + if (result < Pl_Handled) { - if (result < Pl_Handled) - { - result = Pl_Handled; - } - continue; + result = Pl_Handled; } - pHook->pf->PushCell(client); - pHook->pf->PushCell(args); - if (pHook->pf->Execute(&tempres) == SP_ERROR_NONE) + continue; + } + pHook->pf->PushCell(client); + pHook->pf->PushCell(args); + if (pHook->pf->Execute(&tempres) == SP_ERROR_NONE) + { + if (tempres > result) { - if (tempres > result) - { - result = tempres; - } - if (result == Pl_Stop) - { - break; - } + result = tempres; + } + if (result == Pl_Stop) + { + break; } } - type = (ResultType)result; } + type = (ResultType)result; + return type; }