Remove "last seen improvements" that are no longer valid improvements in mods

This commit is contained in:
yairm210 2025-01-11 21:52:30 +02:00
parent bfbd0ced32
commit 9b9f31995a

View File

@ -30,6 +30,7 @@ object BackwardCompatibility {
// Mod decided you can't repair things anymore - get rid of old pillaged improvements // Mod decided you can't repair things anymore - get rid of old pillaged improvements
removeOldPillagedImprovements() removeOldPillagedImprovements()
removeMissingLastSeenImprovements()
handleMissingReferencesForEachCity() handleMissingReferencesForEachCity()
@ -69,6 +70,13 @@ object BackwardCompatibility {
} }
} }
private fun GameInfo.removeMissingLastSeenImprovements() {
for (civ in civilizations)
for ((vector,improvementName) in civ.lastSeenImprovement.toList())
if (!ruleset.tileImprovements.containsKey(improvementName))
civ.lastSeenImprovement.remove(vector)
}
private fun GameInfo.handleMissingReferencesForEachCity() { private fun GameInfo.handleMissingReferencesForEachCity() {
for (city in civilizations.asSequence().flatMap { it.cities.asSequence() }) { for (city in civilizations.asSequence().flatMap { it.cities.asSequence() }) {