Fixed a bug where maps created before the split PR could no longer be opened after (#5651)

This commit is contained in:
Xander Lenstra 2021-11-09 05:20:27 +01:00 committed by GitHub
parent ac2bc3a404
commit 5cf5e13ffb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 2 deletions

View File

@ -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<String>()
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 = ""

View File

@ -68,6 +68,11 @@ class SaveAndLoadMapScreen(mapToSave: TileMap?, save:Boolean = false, previousSc
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()) {