1.1 --- a/core/ConCmdManager.cpp Sat Jun 18 14:36:20 2011 -0400
1.2 +++ b/core/ConCmdManager.cpp Mon Jun 20 13:30:14 2011 -0400
1.3 @@ -226,30 +226,38 @@
1.4 m_CmdClient = client + 1;
1.5 }
1.6
1.7 +ConCmdInfo *ConCmdManager::FindInTrie(const char *name)
1.8 +{
1.9 + ConCmdInfo *pInfo;
1.10 + if (!sm_trie_retrieve(m_pCmds, name, (void **)&pInfo))
1.11 + return NULL;
1.12 + return pInfo;
1.13 +}
1.14 +
1.15 +ConCmdList::iterator ConCmdManager::FindInList(const char *cmd)
1.16 +{
1.17 + List<ConCmdInfo *>::iterator iter = m_CmdList.begin();
1.18 +
1.19 + while (iter != m_CmdList.end())
1.20 + {
1.21 + if (strcasecmp((*iter)->pCmd->GetName(), cmd) == 0)
1.22 + break;
1.23 + iter++;
1.24 + }
1.25 +
1.26 + return iter;
1.27 +}
1.28 +
1.29 ResultType ConCmdManager::DispatchClientCommand(int client, const char *cmd, int args, ResultType type)
1.30 {
1.31 ConCmdInfo *pInfo;
1.32
1.33 - if (!sm_trie_retrieve(m_pCmds, cmd, (void **)&pInfo))
1.34 + if ((pInfo = FindInTrie(cmd)) == NULL)
1.35 {
1.36 - List<ConCmdInfo *>::iterator iter;
1.37 -
1.38 - pInfo = NULL;
1.39 - iter = m_CmdList.begin();
1.40 - while (iter != m_CmdList.end())
1.41 - {
1.42 - if (strcasecmp((*iter)->pCmd->GetName(), cmd) == 0)
1.43 - {
1.44 - pInfo = (*iter);
1.45 - break;
1.46 - }
1.47 - iter++;
1.48 - }
1.49 -
1.50 - if (pInfo == NULL)
1.51 - {
1.52 + ConCmdList::iterator item = FindInList(cmd);
1.53 + if (item == m_CmdList.end())
1.54 return type;
1.55 - }
1.56 + pInfo = *item;
1.57 }
1.58
1.59 cell_t result = type;
1.60 @@ -314,35 +322,20 @@
1.61 */
1.62 const char *cmd = g_HL2.CurrentCommandName();
1.63
1.64 - ConCmdInfo *pInfo;
1.65 - if (!sm_trie_retrieve(m_pCmds, cmd, (void **)&pInfo))
1.66 + ConCmdInfo *pInfo = FindInTrie(cmd);
1.67 + if (pInfo == NULL)
1.68 {
1.69 /* Unfortunately, we now have to do a slow lookup because Valve made client commands
1.70 * case-insensitive. We can't even use our sortedness.
1.71 */
1.72 if (client == 0 && !engine->IsDedicatedServer())
1.73 - {
1.74 return;
1.75 - }
1.76 -
1.77 - List<ConCmdInfo *>::iterator iter;
1.78
1.79 - pInfo = NULL;
1.80 - iter = m_CmdList.begin();
1.81 - while (iter != m_CmdList.end())
1.82 - {
1.83 - if (strcasecmp((*iter)->pCmd->GetName(), cmd) == 0)
1.84 - {
1.85 - pInfo = (*iter);
1.86 - break;
1.87 - }
1.88 - iter++;
1.89 - }
1.90 -
1.91 - if (pInfo == NULL)
1.92 - {
1.93 - return;
1.94 - }
1.95 + ConCmdList::iterator item = FindInList(cmd);
1.96 + if (item == m_CmdList.end())
1.97 + return;
1.98 +
1.99 + pInfo = *item;
1.100 }
1.101
1.102 /* This is a hack to prevent say triggers from firing on messages that were
1.103 @@ -916,6 +909,10 @@
1.104 ConCmdInfo *pInfo;
1.105 if (!sm_trie_retrieve(m_pCmds, name, (void **)&pInfo))
1.106 {
1.107 + ConCmdList::iterator item = FindInList(name);
1.108 + if (item != m_CmdList.end())
1.109 + return *item;
1.110 +
1.111 pInfo = new ConCmdInfo();
1.112 /* Find the commandopan */
1.113 ConCommand *pCmd = FindCommand(name);