From 088c716321e068e92bfa9bfe0ec1f3e227e5faf2 Mon Sep 17 00:00:00 2001 From: Yair Morgenstern Date: Tue, 12 Jan 2021 18:10:41 +0200 Subject: [PATCH] Game can handle ongoing constructions "disappearing" between mod versions --- core/src/com/unciv/logic/GameInfo.kt | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/core/src/com/unciv/logic/GameInfo.kt b/core/src/com/unciv/logic/GameInfo.kt index 8835abd1f3..724277607f 100644 --- a/core/src/com/unciv/logic/GameInfo.kt +++ b/core/src/com/unciv/logic/GameInfo.kt @@ -347,12 +347,18 @@ class GameInfo { if (!ruleSet.buildings.containsKey(building)) city.cityConstructions.builtBuildings.remove(building) + fun isInvalidConstruction(construction: String) = !ruleSet.buildings.containsKey(construction) && !ruleSet.units.containsKey(construction) + && !PerpetualConstruction.perpetualConstructionsMap.containsKey(construction) + // Remove invalid buildings or units from the queue - don't just check buildings and units because it might be a special construction as well for (construction in city.cityConstructions.constructionQueue.toList()) { - if (!ruleSet.buildings.containsKey(construction) && !ruleSet.units.containsKey(construction) - && !PerpetualConstruction.perpetualConstructionsMap.containsKey(construction)) + if (isInvalidConstruction(construction)) city.cityConstructions.constructionQueue.remove(construction) } + // And from being in progess + for (construction in city.cityConstructions.inProgressConstructions.keys.toList()) + if (isInvalidConstruction(construction)) + city.cityConstructions.inProgressConstructions.remove(construction) } for (civinfo in civilizations) { for (tech in civinfo.tech.techsResearched.toList())