From ed8d48cac3689205e95a462f438e3a8afe218041 Mon Sep 17 00:00:00 2001 From: Zack Middleton Date: Sun, 21 Jan 2018 19:49:16 -0600 Subject: [PATCH] Fix VMs forcing engine latch cvar to update to latched value A few commits ago I stopped VM's Cvar_Set() from instantly updating latched values. Now VM can't call Cvar_Register() afterword to force latched value to be used. Reported by Noah Metzger (Chomenor). --- code/qcommon/cvar.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/code/qcommon/cvar.c b/code/qcommon/cvar.c index 6f1ca432..f12eb7d7 100644 --- a/code/qcommon/cvar.c +++ b/code/qcommon/cvar.c @@ -1376,7 +1376,13 @@ void Cvar_Register(vmCvar_t *vmCvar, const char *varName, const char *defaultVal if ( cv && ( cv->flags & CVAR_PROTECTED ) ) { Com_DPrintf( S_COLOR_YELLOW "WARNING: VM tried to register protected cvar '%s' with value '%s'%s\n", varName, defaultValue, ( flags & ~cv->flags ) != 0 ? " and new flags" : "" ); - } else { + } + // Don't set engine latch cvar to latched value. + else if ( cv && ( cv->flags & CVAR_LATCH ) && !( cv->flags & CVAR_VM_CREATED ) ) { + cv->flags |= flags; + cvar_modifiedFlags |= flags; + } + else { cv = Cvar_Get(varName, defaultValue, flags | CVAR_VM_CREATED); }