Commit Graph

27 Commits

Author SHA1 Message Date
Asher Baker
2d241316c7
Make all command lookups case-insensitive (#1542)
SM internally maintained both a case-sensitive and a case-insensitive
lookup method for commands, where the case-sensitive hashmap was used as
a fast path, and case-insensitive iteration over a list used as the slow
path if a command was not found in the hashmap. But only command
dispatch handling used this dual path approach, chat triggers for
example only did a loopup in the hashmap.

Over the years Valve has made more and more of the command dispatch
logic case-insensitive to the point where all console commands are now
case-insensitive, so maintaining case sensitivity when using chat
triggers does not make a lot of sense. There are somewhat popular
plugins that attempt to "correct" this behaviour - but at least one is
having issues after the previous case-sensitivity fixes for commands -
see #1480.

We still have to keep the list around for the sorted help use case and
command iteration, but this PR changes the hashmap to use a
case-insensitive hashing policy (as previously done for convars, and
more recently for game command lookup) and changes all by-name lookup to
exclusively use the hashmap (as there is no need to fall back to the
list any more).

Tested a bunch in TF2, I don't know of any games that still have a
case-sensitive command dispatch pipeline to test. I think the worst case
would be that we'd accept a chat command in the "wrong" case then fail
to execute the underlying command. If that turns out to be an issue in
practice, we should be able to fix it easily enough by replacing the
command name in the buffer with the correct casing of the command we
looked up.

Also fixed a couple of very minor Lookup vs. Key issues in NameHashSet
(noted in #1529) that were being masked due to CharsAndLength's
converting constructor. I tried to make the constructor explicit to
avoid this happening in the future but HashTable's add function relies
on being able to do an implicit conversion so that wasn't possible. We
might want to just rely on the implicit conversion up here as well, but
it doesn't really matter either way.

Fixes #1480, #1529
2021-07-18 19:05:06 +01:00
Headline
99c39b1d57
Update IPlugin reference on cmd hook removal (#1439) 2021-03-10 15:21:57 -08:00
David Anderson
80acff8d7d Replace ke::LinkedList with std::list. 2020-05-31 23:19:41 -07:00
David Anderson
b725196a26 Replace AString with std::string. 2020-05-20 17:57:18 -07:00
David Anderson
7d7253c9cc Update AMTL; replace AutoPtr/UniquePtr with STL. 2020-05-18 18:19:16 -07:00
Michael Flaherty
28f1ea82b6 Add base CommandIterator implementation (#819)
* Add base CommandIterator implementation

* Add check for invalid pos & finalize pr
2018-07-10 17:39:31 -04:00
David Anderson
25b3d8f354 Update AMTL. 2018-05-31 21:23:59 -07:00
David Anderson
e2b399b8d3 Update to the latest AMTL - Rename Ref to RefPtr. 2015-11-08 13:14:57 -08:00
David Anderson
c66d14605a Merge pull request #397 from alliedmodders/rm-old-mms
Remove code that handles long-dead Metamod:Source versions.
2015-09-18 14:38:52 -07:00
David Anderson
fe16e8e47c Move the SetCommandClient hook into GameHooks. 2015-09-09 20:03:23 -07:00
David Anderson
b548ba7b58 Remove bad-console-read protection logic for Metamod:Source 1.7 and earlier. 2015-09-09 18:59:31 -07:00
David Anderson
5757b729ac Hide MRES_SUPERCEDE from command hook callbacks. 2015-09-09 18:45:20 -07:00
David Anderson
b048dc7b10 Move ConCommand hooks into GameHooks and switch callbacks to ICommandArgs. 2015-09-09 18:40:04 -07:00
David Anderson
9d805ea9fb Replace the AddRootConsoleCommand API to not expose internal structures. 2015-08-30 21:01:03 -07:00
Nicholas Hastings
35784c018d Move adminsys and more natives from core to logic. 2014-05-29 13:31:12 -04:00
Nicholas Hastings
1ba6b2653a Move ForwardSys from core to logic (bug 5953, r=fyren).
--HG--
rename : core/ForwardSys.cpp => core/logic/ForwardSys.cpp
rename : core/ForwardSys.h => core/logic/ForwardSys.h
2013-10-09 08:43:08 -04:00
David Anderson
67ce8aff61 Remove memtables from ConCmdManager (bug 5899 part 3, r=fyren). 2013-08-31 19:50:15 -07:00
David Anderson
ba927964c8 Clean up ConCmdManager (bug 5900, r=fyren). 2013-08-31 11:51:23 -07:00
David Anderson
bc51c3e5b1 Switch ConCmdManager off KTrie (bug 5884 part 14, r=ds). 2013-08-25 12:18:25 -07:00
Nicholas Hastings
c230cf5aab Updated for latest hl2sdk-dota changes. 2013-07-12 02:31:41 -04:00
Nicholas Hastings
369e141ea8 Build fixes for recent hl2sdk-dota updates. 2013-04-23 07:11:49 -04:00
Asher Baker
247fabaaf0 Added the ability to override RegConsoleCommand-created commands (bug 5199, r=psychonic). 2012-11-15 17:53:11 +00:00
Nicholas Hastings
f136f2dcaf Added CheckAccess native to check cmd/override access of AdminId (bug 5083, r=fyren). 2011-09-10 12:08:38 -04:00
David Anderson
859678536f Fixed crash on plugin unload when two cmds exist with same name, different casing (bug 4698, r=Fyren). 2011-06-20 13:30:14 -04:00
David Anderson
d8474cfafa Added generic command hooking mechanism, to replace Reg*Cmd which is intended for command creation (bug 4015, r=pred). 2009-09-26 17:12:23 -04:00
Scott Ehlert
ff7a2c6b73 Added preliminary support for Left 4 Dead; some things may not yet work. 2008-11-14 09:18:30 -06:00
Scott Ehlert
251cced1f8 Spring Cleaning, Part Ichi (1)
Various minor things done to project files
Updated sample extension project file and updated makefile to the new unified version (more changes likely on the way)
Updated regex project file and makefile

--HG--
extra : convert_revision : svn%3A39bc706e-5318-0410-9160-8a85361fbb7c/trunk%401971
2008-03-30 07:00:22 +00:00