mirror of
https://github.com/yairm210/Unciv.git
synced 2025-02-01 02:14:51 +07:00
Resolved #9058 - Mods that remove 'repair' improvement no longer cause crashes down the line
This commit is contained in:
parent
6000232eac
commit
d3305e680a
@ -1,10 +1,12 @@
|
||||
package com.unciv.logic
|
||||
|
||||
import com.unciv.Constants
|
||||
import com.unciv.logic.city.CityConstructions
|
||||
import com.unciv.logic.city.PerpetualConstruction
|
||||
import com.unciv.logic.civilization.diplomacy.DiplomacyFlags
|
||||
import com.unciv.logic.civilization.diplomacy.DiplomacyManager
|
||||
import com.unciv.logic.civilization.managers.TechManager
|
||||
import com.unciv.logic.map.tile.RoadStatus
|
||||
import com.unciv.models.ruleset.ModOptions
|
||||
import com.unciv.models.ruleset.Ruleset
|
||||
|
||||
@ -35,6 +37,20 @@ object BackwardCompatibility {
|
||||
}
|
||||
}
|
||||
|
||||
// Mod decided you can't repair things anymore - get rid of old pillaged improvements
|
||||
if (!ruleset.tileImprovements.containsKey(Constants.repair))
|
||||
for (tile in tileMap.values) {
|
||||
if (tile.roadIsPillaged) {
|
||||
tile.roadStatus = RoadStatus.None
|
||||
tile.roadIsPillaged = false
|
||||
}
|
||||
if (tile.improvementIsPillaged){
|
||||
tile.improvement = null
|
||||
tile.improvementIsPillaged = false
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
for (city in civilizations.asSequence().flatMap { it.cities.asSequence() }) {
|
||||
|
||||
changeBuildingNameIfNotInRuleset(ruleset, city.cityConstructions, "Hanse", "Bank")
|
||||
|
@ -883,11 +883,10 @@ open class Tile : IsPartOfGameInfoSerialization {
|
||||
removeRoad()
|
||||
} else {
|
||||
// otherwise use pillage/repair systems
|
||||
if (canPillageTileImprovement()) {
|
||||
if (canPillageTileImprovement())
|
||||
improvementIsPillaged = true
|
||||
} else {
|
||||
else
|
||||
roadIsPillaged = true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -412,7 +412,7 @@ object UnitActions {
|
||||
}
|
||||
|
||||
private fun addRepairAction(unit: MapUnit, actionList: ArrayList<UnitAction>) {
|
||||
if (unit.currentTile.ruleset.tileImprovements[Constants.repair] == null) return
|
||||
if (!unit.currentTile.ruleset.tileImprovements.containsKey(Constants.repair)) return
|
||||
if (!unit.cache.hasUniqueToBuildImprovements) return
|
||||
if (unit.isEmbarked()) return
|
||||
val tile = unit.getTile()
|
||||
|
Loading…
Reference in New Issue
Block a user