diff --git a/README.md b/README.md index e0f138ad..071c46b8 100644 --- a/README.md +++ b/README.md @@ -319,6 +319,9 @@ The defaults for these variables differ depending on the target platform. all bots even if someone is named "allbots") tell - send message to a single client (new to server) + + cvar_modified [filter] - list modified cvars, can filter results (such as "r*" + for renderer cvars) like cvarlist which lists all cvars ``` diff --git a/code/qcommon/cvar.c b/code/qcommon/cvar.c index 88d2e891..0b21fa71 100644 --- a/code/qcommon/cvar.c +++ b/code/qcommon/cvar.c @@ -1021,6 +1021,90 @@ void Cvar_List_f( void ) { Com_Printf ("%i cvar indexes\n", cvar_numIndexes); } +/* +============ +Cvar_ListModified_f +============ +*/ +void Cvar_ListModified_f( void ) { + cvar_t *var; + int totalModified; + char *value; + char *match; + + if ( Cmd_Argc() > 1 ) { + match = Cmd_Argv( 1 ); + } else { + match = NULL; + } + + totalModified = 0; + for (var = cvar_vars ; var ; var = var->next) + { + if ( !var->name || !var->modificationCount ) + continue; + + value = var->latchedString ? var->latchedString : var->string; + if ( !strcmp( value, var->resetString ) ) + continue; + + totalModified++; + + if (match && !Com_Filter(match, var->name, qfalse)) + continue; + + if (var->flags & CVAR_SERVERINFO) { + Com_Printf("S"); + } else { + Com_Printf(" "); + } + if (var->flags & CVAR_SYSTEMINFO) { + Com_Printf("s"); + } else { + Com_Printf(" "); + } + if (var->flags & CVAR_USERINFO) { + Com_Printf("U"); + } else { + Com_Printf(" "); + } + if (var->flags & CVAR_ROM) { + Com_Printf("R"); + } else { + Com_Printf(" "); + } + if (var->flags & CVAR_INIT) { + Com_Printf("I"); + } else { + Com_Printf(" "); + } + if (var->flags & CVAR_ARCHIVE) { + Com_Printf("A"); + } else { + Com_Printf(" "); + } + if (var->flags & CVAR_LATCH) { + Com_Printf("L"); + } else { + Com_Printf(" "); + } + if (var->flags & CVAR_CHEAT) { + Com_Printf("C"); + } else { + Com_Printf(" "); + } + if (var->flags & CVAR_USER_CREATED) { + Com_Printf("?"); + } else { + Com_Printf(" "); + } + + Com_Printf (" %s \"%s\", default \"%s\"\n", var->name, value, var->resetString); + } + + Com_Printf ("\n%i total modified cvars\n", totalModified); +} + /* ============ Cvar_Unset @@ -1343,5 +1427,6 @@ void Cvar_Init (void) Cmd_SetCommandCompletionFunc("unset", Cvar_CompleteCvarName); Cmd_AddCommand ("cvarlist", Cvar_List_f); + Cmd_AddCommand ("cvar_modified", Cvar_ListModified_f); Cmd_AddCommand ("cvar_restart", Cvar_Restart_f); }