From 5cf5e13ffb0bd340a2284badb5043bd8fd1927ca Mon Sep 17 00:00:00 2001 From: Xander Lenstra <71121390+xlenstra@users.noreply.github.com> Date: Tue, 9 Nov 2021 05:20:27 +0100 Subject: [PATCH] Fixed a bug where maps created before the split PR could no longer be opened after (#5651) --- core/src/com/unciv/logic/map/MapParameters.kt | 2 +- core/src/com/unciv/ui/mapeditor/SaveAndLoadMapScreen.kt | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/core/src/com/unciv/logic/map/MapParameters.kt b/core/src/com/unciv/logic/map/MapParameters.kt index f02e69ab3f..b978285c06 100644 --- a/core/src/com/unciv/logic/map/MapParameters.kt +++ b/core/src/com/unciv/logic/map/MapParameters.kt @@ -142,7 +142,7 @@ class MapParameters { /** This is used mainly for the map editor, so you can continue editing a map under the same ruleset you started with */ var mods = LinkedHashSet() - var baseRuleset = BaseRuleset.Civ_V_Vanilla.name // Hardcoded as the Rulesetcache is not yet initialized when starting up + var baseRuleset = BaseRuleset.Civ_V_GnK.fullName // Hardcoded as the Rulesetcache is not yet initialized when starting up /** Unciv Version of creation for support cases */ var createdWithVersion = "" diff --git a/core/src/com/unciv/ui/mapeditor/SaveAndLoadMapScreen.kt b/core/src/com/unciv/ui/mapeditor/SaveAndLoadMapScreen.kt index 488d22f17c..ec692b856f 100644 --- a/core/src/com/unciv/ui/mapeditor/SaveAndLoadMapScreen.kt +++ b/core/src/com/unciv/ui/mapeditor/SaveAndLoadMapScreen.kt @@ -66,8 +66,13 @@ class SaveAndLoadMapScreen(mapToSave: TileMap?, save:Boolean = false, previousSc } try { val map = MapSaver.loadMap(chosenMap!!, checkSizeErrors = false) - + val missingMods = map.mapParameters.mods.filter { it !in RulesetCache }.toMutableList() + // [TEMPORARY] conversion of old maps with a base ruleset contained in the mods + val newBaseRuleset = map.mapParameters.mods.filter { it !in missingMods }.firstOrNull { RulesetCache[it]!!.modOptions.isBaseRuleset } + if (newBaseRuleset != null) map.mapParameters.baseRuleset = newBaseRuleset + // + if (map.mapParameters.baseRuleset !in RulesetCache) missingMods += map.mapParameters.baseRuleset if (missingMods.isNotEmpty()) {