From 784389e8238c35c7ba6b599a802c9ab5f3a88396 Mon Sep 17 00:00:00 2001 From: slipher Date: Sun, 7 Dec 2025 06:13:39 -0600 Subject: [PATCH 1/2] Cleanup: InternalSetValue flags argument always 0 Remove the pointless `int flags` argument to Cvar::InternalSetValue which is always 0. --- src/engine/framework/CvarSystem.cpp | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/engine/framework/CvarSystem.cpp b/src/engine/framework/CvarSystem.cpp index 26de06368e..010e91382e 100644 --- a/src/engine/framework/CvarSystem.cpp +++ b/src/engine/framework/CvarSystem.cpp @@ -223,7 +223,7 @@ namespace Cvar { cvar->description = std::move(realDescription); } - void InternalSetValue(const std::string& cvarName, std::string value, int flags, bool rom, bool warnRom) { + void InternalSetValue(const std::string& cvarName, std::string value, bool rom, bool warnRom) { CvarMap& cvars = GetCvarMap(); auto it = cvars.find(cvarName); @@ -235,7 +235,7 @@ namespace Cvar { } //The user creates a new cvar through a command. - cvars[cvarName] = new cvarRecord_t{value, value, Util::nullopt, flags | CVAR_USER_CREATED, "user created", nullptr, {}}; + cvars[cvarName] = new cvarRecord_t{value, value, Util::nullopt, CVAR_USER_CREATED, "user created", nullptr, {}}; Cmd::AddCommand(cvarName, cvarCommand, "cvar - user created"); GetCCvar(cvarName, *cvars[cvarName]); @@ -263,8 +263,6 @@ namespace Cvar { } } - cvar->flags |= flags; - // mark for archival if flagged as archive-on-change if (cvar->flags & ARCHIVE) { cvar->flags |= USER_ARCHIVE; @@ -302,11 +300,11 @@ namespace Cvar { // Simple proxies for InternalSetValue void SetValue(const std::string& cvarName, const std::string& value) { - InternalSetValue(cvarName, value, 0, false, true); + InternalSetValue(cvarName, value, false, true); } void SetValueForce(const std::string& cvarName, const std::string& value) { - InternalSetValue(cvarName, value, 0, true, true); + InternalSetValue(cvarName, value, true, true); } std::string GetValue(const std::string& cvarName) { @@ -578,7 +576,7 @@ namespace Cvar { } void SetValueCProxy(const std::string& cvarName, const std::string& value) { - InternalSetValue(cvarName, value, 0, true, false); + InternalSetValue(cvarName, value, true, false); } /* From 2fbecd51a3b23cdfe784728a107b783fd8e0618f Mon Sep 17 00:00:00 2001 From: slipher Date: Sun, 7 Dec 2025 06:29:12 -0600 Subject: [PATCH 2/2] Fix cvar changes sometimes not writing autogen A command such as /set common.framerate.max 99, when the cvar was previously marked as archive, could fail to cause the configuration file to be written out. This happened because the code relied on the flags field of the C API cvar_t object to detect updates, but Cvar::AddFlags failed to update cvar_t. Note that setting cvars in the UI was not affected because the UI re-adds the archive flag every time and the act of adding the flag triggers an update. --- src/engine/framework/CvarSystem.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/engine/framework/CvarSystem.cpp b/src/engine/framework/CvarSystem.cpp index 010e91382e..e9b2acb717 100644 --- a/src/engine/framework/CvarSystem.cpp +++ b/src/engine/framework/CvarSystem.cpp @@ -416,8 +416,8 @@ namespace Cvar { } cvar->flags |= flags; + cvar->ccvar.flags |= flags; - //TODO: remove it, overkill ? //Make sure to trigger the event as if this variable was changed cvar_modifiedFlags |= flags; return true; // success