From 9f4f8b1d2b905febb6bbb6fe1ad0079e0b1ee9d1 Mon Sep 17 00:00:00 2001 From: Vivek Singh Date: Thu, 20 Nov 2025 11:34:50 +0530 Subject: [PATCH] Fix: Reset per-game cvar overrides (ResetGameConfigValue + ResetGameConfigValues) --- src/xenia/base/cvar.h | 9 +++++++++ src/xenia/config.cc | 12 ++++++++++++ 2 files changed, 21 insertions(+) diff --git a/src/xenia/base/cvar.h b/src/xenia/base/cvar.h index 61b8faf113e..88301a117bb 100644 --- a/src/xenia/base/cvar.h +++ b/src/xenia/base/cvar.h @@ -50,6 +50,7 @@ class IConfigVar : virtual public ICommandVar { virtual std::string config_value() const = 0; virtual void LoadConfigValue(std::shared_ptr result) = 0; virtual void LoadGameConfigValue(std::shared_ptr result) = 0; + virtual void ResetGameConfigValue() = 0; virtual void ResetConfigValueToDefault() = 0; }; @@ -95,6 +96,7 @@ class ConfigVar : public CommandVar, virtual public IConfigVar { // one that will be stored when the global config is written next time. After // overriding, however, the next game config loaded may still change it. void OverrideConfigValue(T val); + void ResetGameConfigValue() override; private: std::string category_; @@ -278,6 +280,13 @@ void ConfigVar::OverrideConfigValue(T val) { this->commandline_value_.reset(); UpdateValue(); } + +template +void ConfigVar::ResetGameConfigValue() { + game_config_value_.reset(); + UpdateValue(); +} + template void ConfigVar::ResetConfigValueToDefault() { SetConfigValue(this->default_value_); diff --git a/src/xenia/config.cc b/src/xenia/config.cc index dcdc5ac2b58..72ce84e409d 100644 --- a/src/xenia/config.cc +++ b/src/xenia/config.cc @@ -104,6 +104,16 @@ void ReadGameConfig(const std::filesystem::path& file_path) { XELOGI("Loaded game config: {}", xe::path_to_utf8(file_path)); } +void ResetGameConfigValues() { + if (!cvar::ConfigVars) { + return; + } + for (auto& it : *cvar::ConfigVars) { + auto config_var = static_cast(it.second); + config_var->ResetGameConfigValue(); + } +} + void SaveConfig() { if (config_path.empty()) { return; @@ -238,6 +248,8 @@ void SetupConfig(const std::filesystem::path& config_folder) { } void LoadGameConfig(const std::string_view title_id) { + ResetGameConfigValues(); + const auto game_config_folder = config_folder / "config"; const auto game_config_path = game_config_folder / (std::string(title_id) + game_config_suffix);