From bb4007f16aa3e6a56694aa634961b17c8c036fde Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 17 Nov 2018 15:23:57 +0100 Subject: [PATCH] - fixed: CVar.ResetToDefault was missing a check for use outside of menus. --- src/c_cvars.cpp | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/c_cvars.cpp b/src/c_cvars.cpp index 5be8a28a74..43572fe77d 100644 --- a/src/c_cvars.cpp +++ b/src/c_cvars.cpp @@ -225,7 +225,7 @@ DEFINE_ACTION_FUNCTION(_CVar, SetInt) // Only menus are allowed to change non-mod CVARs. if (DMenu::InMenu == 0) { - I_FatalError("Attempt to change CVAR '%s' outside of menu code", self->GetName()); + ThrowAbortException(X_OTHER, "Attempt to change CVAR '%s' outside of menu code", self->GetName()); } } PARAM_INT(val); @@ -243,7 +243,7 @@ DEFINE_ACTION_FUNCTION(_CVar, SetFloat) // Only menus are allowed to change non-mod CVARs. if (DMenu::InMenu == 0) { - I_FatalError("Attempt to change CVAR '%s' outside of menu code", self->GetName()); + ThrowAbortException(X_OTHER, "Attempt to change CVAR '%s' outside of menu code", self->GetName()); } } PARAM_FLOAT(val); @@ -262,7 +262,7 @@ DEFINE_ACTION_FUNCTION(_CVar, SetString) // Only menus are allowed to change non-mod CVARs. if (DMenu::InMenu == 0) { - I_FatalError("Attempt to change CVAR '%s' outside of menu code", self->GetName()); + ThrowAbortException(X_OTHER, "Attempt to change CVAR '%s' outside of menu code", self->GetName()); } } PARAM_STRING(val); @@ -1161,6 +1161,15 @@ void FBaseCVar::ResetToDefault () DEFINE_ACTION_FUNCTION(_CVar, ResetToDefault) { PARAM_SELF_STRUCT_PROLOGUE(FBaseCVar); + if (!(self->GetFlags() & CVAR_MOD)) + { + // Only menus are allowed to change non-mod CVARs. + if (DMenu::InMenu == 0) + { + ThrowAbortException(X_OTHER, "Attempt to change CVAR '%s' outside of menu code", self->GetName()); + } + } + self->ResetToDefault(); return 0; }