From 78ca670d4f89ffa7f887f8f32d6d6e39bd9c78c3 Mon Sep 17 00:00:00 2001 From: Zack Middleton Date: Sun, 21 Jan 2018 03:50:43 -0600 Subject: [PATCH] Don't let VMs change engine latch cvars immediately If a VM increases sv_maxclients while a server is running the engine will crash. The value should be latched until engine decides to update the cvar; the same as when a user sets it. --- code/qcommon/cvar.c | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/code/qcommon/cvar.c b/code/qcommon/cvar.c index 5a0e6906..6f1ca432 100644 --- a/code/qcommon/cvar.c +++ b/code/qcommon/cvar.c @@ -638,18 +638,29 @@ Cvar_SetSafe void Cvar_SetSafe( const char *var_name, const char *value ) { int flags = Cvar_Flags( var_name ); + qboolean force = qtrue; - if((flags != CVAR_NONEXISTENT) && (flags & CVAR_PROTECTED)) + if ( flags != CVAR_NONEXISTENT ) { - if( value ) - Com_Error( ERR_DROP, "Restricted source tried to set " - "\"%s\" to \"%s\"", var_name, value ); - else - Com_Error( ERR_DROP, "Restricted source tried to " - "modify \"%s\"", var_name ); - return; + if ( flags & CVAR_PROTECTED ) + { + if( value ) + Com_Error( ERR_DROP, "Restricted source tried to set " + "\"%s\" to \"%s\"", var_name, value ); + else + Com_Error( ERR_DROP, "Restricted source tried to " + "modify \"%s\"", var_name ); + return; + } + + // don't let VMs or server change engine latched cvars instantly + if ( ( flags & CVAR_LATCH ) && !( flags & CVAR_VM_CREATED ) ) + { + force = qfalse; + } } - Cvar_Set( var_name, value ); + + Cvar_Set2 (var_name, value, force); } /*