diff --git a/code/qcommon/cvar.c b/code/qcommon/cvar.c index bb036435..53a36845 100644 --- a/code/qcommon/cvar.c +++ b/code/qcommon/cvar.c @@ -334,6 +334,18 @@ cvar_t *Cvar_Get( const char *var_name, const char *var_value, int flags ) { { var_value = Cvar_Validate(var, var_value, qfalse); + // Make sure the game code cannot mark engine-added variables as gamecode vars + if(var->flags & CVAR_VM_CREATED) + { + if(!(flags & CVAR_VM_CREATED)) + var->flags &= ~CVAR_VM_CREATED; + } + else if (!(var->flags & CVAR_USER_CREATED)) + { + if(flags & CVAR_VM_CREATED) + flags &= ~CVAR_VM_CREATED; + } + // if the C code is now specifying a variable that the user already // set a value for, take the new value as the reset value if(var->flags & CVAR_USER_CREATED) @@ -354,18 +366,6 @@ cvar_t *Cvar_Get( const char *var_name, const char *var_value, int flags ) { } } - // Make sure the game code cannot mark engine-added variables as gamecode vars - if(var->flags & CVAR_VM_CREATED) - { - if(!(flags & CVAR_VM_CREATED)) - var->flags &= ~CVAR_VM_CREATED; - } - else - { - if(flags & CVAR_VM_CREATED) - flags &= ~CVAR_VM_CREATED; - } - // Make sure servers cannot mark engine-added variables as SERVER_CREATED if(var->flags & CVAR_SERVER_CREATED) {