by mh » Sun Aug 12, 2012 10:28 am
DirectQ puts them all (cmds, cvars, aliases) into individual lists, then builds a master list containing pointers to the originals. This is sorted alphabetically (also using qsort) and then is searched using a binary search at runtime. There's a more elegant way of doing the original lists using C++ inheritance, and an STL container would be a nicer way of managing the whole thing, but right now it's not that big a problem.
The runtime binary search is actually important - otherwise executing the command buffer involves a lot of linear array walking and string comparison. With id1 this isn't so bad, but when you start adding a heap more cmds and cvars and when you run a mod that's stuffcmd-happy it can become a slightly noticeable problem.
Autocompletion is a bit of a nuisance; having it added to map, save, load, playdemo, timedemo and game is nice for the player, but it involves a lot of opening files, parsing them to get info out, validation, autocomplete list building, and other crap when a game is loaded - one of the reasons why DirectQ's game changing code is painfully slow compared to other engines. (Quakespasm has it on maps but it doesn't validate the map, so ammo box models get included in the list.)