From b364544776771e233e11f94efa2118c44ef84fe4 Mon Sep 17 00:00:00 2001 From: David Anderson Date: Tue, 2 Sep 2008 03:58:23 +0000 Subject: [PATCH] Fixed amb1927 - client command case sensitivity did not match the server's logic. --HG-- branch : sourcemod-1.0.x extra : convert_revision : svn%3A39bc706e-5318-0410-9160-8a85361fbb7c/branches/sourcemod-1.0.x%402482 --- core/ConCmdManager.cpp | 27 ++++++++++++++++++++++++++- plugins/include/console.inc | 10 +++++++++- 2 files changed, 35 insertions(+), 2 deletions(-) diff --git a/core/ConCmdManager.cpp b/core/ConCmdManager.cpp index f177dd54..20f47a3a 100644 --- a/core/ConCmdManager.cpp +++ b/core/ConCmdManager.cpp @@ -296,7 +296,32 @@ void ConCmdManager::InternalDispatch(const CCommand &command) ConCmdInfo *pInfo; if (!sm_trie_retrieve(m_pCmds, cmd, (void **)&pInfo)) { - return; + /* Unfortunately, we now have to do a slow lookup because Valve made client commands + * case-insensitive. We can't even use our sortedness. + */ + if (client == 0 && !engine->IsDedicatedServer()) + { + return; + } + + List::iterator iter; + + pInfo = NULL; + iter = m_CmdList.begin(); + while (iter != m_CmdList.end()) + { + if (strcasecmp((*iter)->pCmd->GetName(), cmd) == 0) + { + pInfo = (*iter); + break; + } + iter++; + } + + if (pInfo == NULL) + { + return; + } } /* This is a hack to prevent say triggers from firing on messages that were diff --git a/plugins/include/console.inc b/plugins/include/console.inc index 39122a27..9b450f12 100644 --- a/plugins/include/console.inc +++ b/plugins/include/console.inc @@ -1,7 +1,7 @@ /** * vim: set ts=4 : * ============================================================================= - * SourceMod (C)2004-2007 AlliedModders LLC. All rights reserved. + * SourceMod (C)2004-2008 AlliedModders LLC. All rights reserved. * ============================================================================= * * This file is part of the SourceMod/SourcePawn SDK. @@ -298,6 +298,8 @@ functag SrvCmd Action:public(args); /** * Creates a server-only console command, or hooks an already existing one. * + * Server commands are case sensitive. + * * @param cmd Name of the command to hook or create. * @param callback A function to use as a callback for when the command is invoked. * @param description Optional description to use for command creation. @@ -320,6 +322,10 @@ functag ConCmd Action:public(client, args); /** * Creates a console command, or hooks an already existing one. * + * Console commands are case sensitive. However, if the command already exists in the game, + * the a client may enter the command in any case. SourceMod corrects for this automatically, + * and you should only hook the "real" version of the command. + * * @param cmd Name of the command to hook or create. * @param callback A function to use as a callback for when the command is invoked. * @param description Optional description to use for command creation. @@ -334,6 +340,8 @@ native RegConsoleCmd(const String:cmd[], ConCmd:callback, const String:descripti * it is created. When this command is invoked, the access rights of the player are * automatically checked before allowing it to continue. * + * Admin commands are case sensitive from both the client and server. + * * @param cmd String containing command to register. * @param callback A function to use as a callback for when the command is invoked. * @param adminflags Administrative flags (bitstring) to use for permissions.