diff --git a/src/common/config.cpp b/src/common/config.cpp index 695e52980..12f95777e 100644 --- a/src/common/config.cpp +++ b/src/common/config.cpp @@ -107,8 +107,8 @@ u32 m_language = 1; // english // Keys static std::string trophyKey = ""; -// Expected number of items in the config file -static constexpr u64 total_entries = 55; +// Config version, used to determine if a user's config file is outdated. +static std::string config_version = Common::g_scm_rev; int getVolumeSlider() { return volumeSlider; @@ -623,8 +623,6 @@ void load(const std::filesystem::path& path) { return; } - u64 entry_count = 0; - if (data.contains("General")) { const toml::value& general = data.at("General"); @@ -646,8 +644,6 @@ void load(const std::filesystem::path& path) { checkCompatibilityOnStartup = toml::find_or(general, "checkCompatibilityOnStartup", checkCompatibilityOnStartup); chooseHomeTab = toml::find_or(general, "chooseHomeTab", chooseHomeTab); - - entry_count += general.size(); } if (data.contains("Input")) { @@ -662,8 +658,6 @@ void load(const std::filesystem::path& path) { useUnifiedInputConfig = toml::find_or(input, "useUnifiedInputConfig", useUnifiedInputConfig); micDevice = toml::find_or(input, "micDevice", micDevice); - - entry_count += input.size(); } if (data.contains("GPU")) { @@ -687,8 +681,6 @@ void load(const std::filesystem::path& path) { isFullscreen = toml::find_or(gpu, "Fullscreen", isFullscreen); fullscreenMode = toml::find_or(gpu, "FullscreenMode", fullscreenMode); isHDRAllowed = toml::find_or(gpu, "allowHDR", isHDRAllowed); - - entry_count += gpu.size(); } if (data.contains("Vulkan")) { @@ -702,10 +694,9 @@ void load(const std::filesystem::path& path) { vkHostMarkers = toml::find_or(vk, "hostMarkers", vkHostMarkers); vkGuestMarkers = toml::find_or(vk, "guestMarkers", vkGuestMarkers); rdocEnable = toml::find_or(vk, "rdocEnable", rdocEnable); - - entry_count += vk.size(); } + std::string current_version = {}; if (data.contains("Debug")) { const toml::value& debug = data.at("Debug"); @@ -714,8 +705,7 @@ void load(const std::filesystem::path& path) { toml::find_or(debug, "isSeparateLogFilesEnabled", isSeparateLogFilesEnabled); isShaderDebug = toml::find_or(debug, "CollectShader", isShaderDebug); isFpsColor = toml::find_or(debug, "FPSColor", isFpsColor); - - entry_count += debug.size(); + current_version = toml::find_or(debug, "ConfigVersion", current_version); } if (data.contains("GUI")) { @@ -747,26 +737,20 @@ void load(const std::filesystem::path& path) { settings_addon_install_dir = toml::find_fs_path_or(gui, "addonInstallDir", settings_addon_install_dir); - - entry_count += gui.size(); } if (data.contains("Settings")) { const toml::value& settings = data.at("Settings"); m_language = toml::find_or(settings, "consoleLanguage", m_language); - - entry_count += settings.size(); } if (data.contains("Keys")) { const toml::value& keys = data.at("Keys"); trophyKey = toml::find_or(keys, "TrophyKey", trophyKey); - - entry_count += keys.size(); } // Run save after loading to generate any missing fields with default values. - if (entry_count != total_entries) { + if (config_version != current_version) { fmt::print("Outdated config detected, updating config file.\n"); save(path); } @@ -874,6 +858,7 @@ void save(const std::filesystem::path& path) { data["Debug"]["CollectShader"] = isShaderDebug; data["Debug"]["isSeparateLogFilesEnabled"] = isSeparateLogFilesEnabled; data["Debug"]["FPSColor"] = isFpsColor; + data["Debug"]["ConfigVersion"] = config_version; data["Keys"]["TrophyKey"] = trophyKey; std::vector install_dirs;