I just love Q3's cvarlist... I can find any cvar I want by just guessing the name and applying it to a wildcard.... But what about Q2!? It just spews them forth which is fairly worthless unless you want to view a console log. Well, there's a solution! First, you'll need wildcard matching in your source code. I dug up some GPL code by Florian Schintke. It's split in to 2 files. The first is wildcard.h, which contains the following code... /* Copyright (C) 1996, 1997, 1998, 1999, 2000 Florian Schintke This is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. This is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License with the c2html, java2html, pas2html or perl2html source package as the file COPYING. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #ifndef WILDCARDS_H #define WILDCARDS_H extern int wildcardfit (char *wildcard, char *test); /* this function implements the UN*X wildcards and returns */ /* 0 if *wildcard does not match *test */ /* 1 if *wildcard matches *test */ #endif The second is wildcard.c, which contains this code: /* Copyright (C) 1996, 1997, 1998, 1999, 2000 Florian Schintke This is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. This is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License with the c2html, java2html, pas2html or perl2html source package as the file COPYING. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ /* Documenttitle and purpose: */ /* Implementation of the UN*X wildcards in C. So they are */ /* available in a portable way and can be used whereever */ /* needed. */ /* */ /* Version: */ /* 1.2 */ /* */ /* Test cases: */ /* Please look into the Shellscript testwildcards.main */ /* */ /* Author(s): */ /* Florian Schintke (schintke@gmx.de) */ /* */ /* Tester: */ /* Florian Schintke (schintke@gmx.de) */ /* */ /* Testing state: */ /* tested with the atac tool */ /* Latest test state is documented in testwildcards.report */ /* The program that tested this functions is available as */ /* testwildcards.c */ /* */ /* Dates: */ /* First editing: unknown, but before 04/02/1997 */ /* Last Change : 04/07/2000 */ /* */ /* Known Bugs: */ /* */ #include Now that wildcard matching works, open cvar.c. Add to the top of the file: #include "wildcard.h" Now, replace the entire Cvar_List_f function with this: /* ============ Cvar_List_f ============ */ void Cvar_List_f (void) { cvar_t *var; int i,j,c; char *wc; // RIOT - Quake 3-style cvarlist c = Cmd_Argc(); if(c != 1 && c != 2) { Com_Printf ("usage: cvarlist [wildcard]\n"); return; } if(c == 2) wc = Cmd_Argv(1); else wc = "*"; i = 0; j=0; for (var = cvar_vars ; var ; var = var->next, i++) { if(wildcardfit(wc, var->name)) { j++; if (var->flags & CVAR_ARCHIVE) Com_Printf ("*"); else Com_Printf (" "); if (var->flags & CVAR_USERINFO) Com_Printf ("U"); else Com_Printf (" "); if (var->flags & CVAR_SERVERINFO) Com_Printf ("S"); else Com_Printf (" "); if (var->flags & CVAR_NOSET) Com_Printf ("-"); else if (var->flags & CVAR_LATCH) Com_Printf ("L"); else Com_Printf (" "); Com_Printf (" %s \"%s\"\n", var->name, var->string); } } Com_Printf ("%i cvars %i matching\n", i, j); } |