[openjk] 04/14: Shared: Add cvar_usercreated and unset_usercreated commands
Simon McVittie
smcv at debian.org
Mon Nov 6 11:42:12 UTC 2017
This is an automated email from the git hooks/post-receive script.
smcv pushed a commit to branch debian/master
in repository openjk.
commit 28c72736b22bc2858ad2063828a0a3b616c0ac42
Author: Ensiform <ensiform at gmail.com>
Date: Sun Jul 30 16:31:43 2017 -0500
Shared: Add cvar_usercreated and unset_usercreated commands
cvar_usercreated - Lists all user created cvars.
unset_usercreated - Destroys all user created cvars. (USE with caution because it will unset valid cvars that are not currently valid)
Scenarios where valid cvars that might be unset:
At main menu and your cg_ g_ ui_ cvars might be not yet active.
---
code/qcommon/cvar.cpp | 50 +++++++++++++++++++++++++++++++++++++++++++++++++
codemp/qcommon/cvar.cpp | 50 +++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 100 insertions(+)
diff --git a/code/qcommon/cvar.cpp b/code/qcommon/cvar.cpp
index 078b36a..77d8e4b 100644
--- a/code/qcommon/cvar.cpp
+++ b/code/qcommon/cvar.cpp
@@ -1063,6 +1063,31 @@ void Cvar_ListModified_f( void ) {
}
}
+void Cvar_ListUserCreated_f( void ) {
+ cvar_t *var = NULL;
+ uint32_t count = 0;
+
+ // build a list of cvars that are modified
+ for ( var=cvar_vars;
+ var;
+ var=var->next )
+ {
+ char *value = var->latchedString ? var->latchedString : var->string;
+ if ( !(var->flags & CVAR_USER_CREATED) )
+ continue;
+
+ Com_Printf( S_COLOR_GREY "Cvar "
+ S_COLOR_WHITE "%s = " S_COLOR_GREY "\"" S_COLOR_WHITE "%s" S_COLOR_GREY "\"" S_COLOR_WHITE "\n",
+ var->name, value );
+ count++;
+ }
+
+ if ( count > 0 )
+ Com_Printf( S_COLOR_GREY "Showing " S_COLOR_WHITE "%u" S_COLOR_GREY " user created cvars" S_COLOR_WHITE "\n", count );
+ else
+ Com_Printf( S_COLOR_GREY "No user created cvars" S_COLOR_WHITE "\n" );
+}
+
/*
============
Cvar_Unset
@@ -1135,6 +1160,29 @@ void Cvar_Unset_f(void)
Com_Printf("Error: %s: Variable %s is not user created.\n", Cmd_Argv(0), cv->name);
}
+void Cvar_UnsetUserCreated_f(void)
+{
+ cvar_t *curvar = cvar_vars;
+ uint32_t count = 0;
+
+ while ( curvar )
+ {
+ if ( ( curvar->flags & CVAR_USER_CREATED ) )
+ {
+ // throw out any variables the user created
+ curvar = Cvar_Unset( curvar );
+ count++;
+ continue;
+ }
+ curvar = curvar->next;
+ }
+
+ if ( count > 0 )
+ Com_Printf( S_COLOR_GREY "Removed " S_COLOR_WHITE "%u" S_COLOR_GREY " user created cvars" S_COLOR_WHITE "\n", count );
+ else
+ Com_Printf( S_COLOR_GREY "No user created cvars to remove" S_COLOR_WHITE "\n" );
+}
+
/*
============
Cvar_Restart
@@ -1334,7 +1382,9 @@ void Cvar_Init (void) {
Cmd_SetCommandCompletionFunc( "reset", Cvar_CompleteCvarName );
Cmd_AddCommand( "unset", Cvar_Unset_f );
Cmd_SetCommandCompletionFunc( "unset", Cvar_CompleteCvarName );
+ Cmd_AddCommand( "unset_usercreated", Cvar_UnsetUserCreated_f );
Cmd_AddCommand( "cvarlist", Cvar_List_f );
+ Cmd_AddCommand( "cvar_usercreated", Cvar_ListUserCreated_f );
Cmd_AddCommand( "cvar_modified", Cvar_ListModified_f );
Cmd_AddCommand( "cvar_restart", Cvar_Restart_f );
}
diff --git a/codemp/qcommon/cvar.cpp b/codemp/qcommon/cvar.cpp
index b3b26c1..157cdde 100644
--- a/codemp/qcommon/cvar.cpp
+++ b/codemp/qcommon/cvar.cpp
@@ -1256,6 +1256,31 @@ void Cvar_ListModified_f( void ) {
}
}
+void Cvar_ListUserCreated_f( void ) {
+ cvar_t *var = NULL;
+ uint32_t count = 0;
+
+ // build a list of cvars that are modified
+ for ( var=cvar_vars;
+ var;
+ var=var->next )
+ {
+ char *value = var->latchedString ? var->latchedString : var->string;
+ if ( !(var->flags & CVAR_USER_CREATED) )
+ continue;
+
+ Com_Printf( S_COLOR_GREY "Cvar "
+ S_COLOR_WHITE "%s = " S_COLOR_GREY "\"" S_COLOR_WHITE "%s" S_COLOR_GREY "\"" S_COLOR_WHITE "\n",
+ var->name, value );
+ count++;
+ }
+
+ if ( count > 0 )
+ Com_Printf( S_COLOR_GREY "Showing " S_COLOR_WHITE "%u" S_COLOR_GREY " user created cvars" S_COLOR_WHITE "\n", count );
+ else
+ Com_Printf( S_COLOR_GREY "No user created cvars" S_COLOR_WHITE "\n" );
+}
+
/*
============
Cvar_Unset
@@ -1330,6 +1355,29 @@ void Cvar_Unset_f(void)
Com_Printf("Error: %s: Variable %s is not user created.\n", Cmd_Argv(0), cv->name);
}
+void Cvar_UnsetUserCreated_f(void)
+{
+ cvar_t *curvar = cvar_vars;
+ uint32_t count = 0;
+
+ while ( curvar )
+ {
+ if ( ( curvar->flags & CVAR_USER_CREATED ) )
+ {
+ // throw out any variables the user created
+ curvar = Cvar_Unset( curvar );
+ count++;
+ continue;
+ }
+ curvar = curvar->next;
+ }
+
+ if ( count > 0 )
+ Com_Printf( S_COLOR_GREY "Removed " S_COLOR_WHITE "%u" S_COLOR_GREY " user created cvars" S_COLOR_WHITE "\n", count );
+ else
+ Com_Printf( S_COLOR_GREY "No user created cvars to remove" S_COLOR_WHITE "\n" );
+}
+
/*
============
Cvar_Restart
@@ -1564,7 +1612,9 @@ void Cvar_Init (void) {
Cmd_SetCommandCompletionFunc( "reset", Cvar_CompleteCvarName );
Cmd_AddCommand( "unset", Cvar_Unset_f, "Unset a user generated cvar" );
Cmd_SetCommandCompletionFunc( "unset", Cvar_CompleteCvarName );
+ Cmd_AddCommand( "unset_usercreated", Cvar_UnsetUserCreated_f, "Unset all user generated cvars " S_COLOR_RED "Use with caution!" S_COLOR_WHITE );
Cmd_AddCommand( "cvarlist", Cvar_List_f, "Show all cvars" );
+ Cmd_AddCommand( "cvar_usercreated", Cvar_ListUserCreated_f, "Show all user created cvars" );
Cmd_AddCommand( "cvar_modified", Cvar_ListModified_f, "Show all modified cvars" );
Cmd_AddCommand( "cvar_restart", Cvar_Restart_f, "Resetart the cvar sub-system" );
}
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-games/openjk.git
More information about the Pkg-games-commits
mailing list