From 50838f24bf956ed93623890253b54f523834fb64 Mon Sep 17 00:00:00 2001 From: Ivan Savenko Date: Sun, 15 Dec 2024 19:43:43 +0000 Subject: [PATCH] Auto-recover from cases when active preset is invalid --- lib/modding/ModManager.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/modding/ModManager.cpp b/lib/modding/ModManager.cpp index a117eff2c..20dcc9fc6 100644 --- a/lib/modding/ModManager.cpp +++ b/lib/modding/ModManager.cpp @@ -163,7 +163,7 @@ ModsPresetState::ModsPresetState() CResourceHandler::get("local")->createResource(settingsPath.getOriginalName() + ".json"); } - if(modConfig["presets"].isNull()) + if(modConfig["presets"].isNull() || modConfig["presets"].Struct().empty()) { modConfig["activePreset"] = JsonNode("default"); if(modConfig["activeMods"].isNull()) @@ -171,6 +171,10 @@ ModsPresetState::ModsPresetState() else importInitialPreset(); // 1.5 format import } + + auto allPresets = getAllPresets(); + if (!vstd::contains(allPresets, modConfig["activePreset"].String())) + modConfig["activePreset"] = JsonNode(allPresets.front()); } void ModsPresetState::createInitialPreset()