Bug 3546 - cvars with the same names as commands cannot be read
Status: RESOLVED FIXED
Alias: None
Product: ioquake3
Classification: Unclassified
Component: Misc
Version: unspecified
Hardware: PC All
: P3 minor
Assignee: Zachary J. Slater
QA Contact: ioquake3 bugzilla mailing list
URL:
Depends on:
Blocks:
 
Reported: 2008-02-17 21:17 EST by Ben Millwood
Modified: 2008-03-25 12:22:17 EDT
0 users

See Also:


Attachments
cvar.c refactoring (3.74 KB, patch)
2008-02-17 22:06 EST, Ben Millwood
Cmd_Read_f (1.94 KB, patch)
2008-03-08 11:29 EST, Ben Millwood

Description Ben Millwood 2008-02-17 21:17:21 EST
It's possible to set a user-created cvar with the same name as a client command. E.g.
]/set reset "echo Cancelled; bind HOME vstr fullscreen; bind END vstr windowed"
The content of the cvar, normally referenced through /cvarname in the console, now cannot be read:
]/reset
usage: reset <variable>

Reserving some names is not an option for two reasons: one, it restricts the user unnecessarily, and two, it does not account for possible server-added commands, etc.
A much better solution would be to create a new command (or use /set with no value argument) that printed the contents of the given cvar.
Comment 1 Ben Millwood 2008-02-17 22:06:26 EST
Created attachment 1677 [details]
cvar.c refactoring

It occurred to me that I still hadn't submitted a bug report for this patch, which simplifies code/qcommon/cvar.c and coincidentally fixes the issue I described (/set cvar now prints the relevant value).

If the other parts of this bug are too much, I'll separate out the relevant parts tomorrow sometime.
Comment 2 Ben Millwood 2008-03-08 11:29:43 EST
Created attachment 1700 [details]
Cmd_Read_f

Creates a command /read cvar to print its contents.
Comment 3 Thilo Schulz 2008-03-25 12:22:17 EDT
The patch seems reasonably clean, and your command for reading cvars is useful and probably more intuitive than just calling /set without arguments. I renamed the "read" command to "print" though, as this is what the command is actually doing.