Modded "Remove" commands to nonexistant features no longer crashes the game

This commit is contained in:
Yair Morgenstern
2021-03-28 21:59:57 +03:00
parent 1f057831d8
commit 63e10dde71

View File

@ -411,12 +411,13 @@ class MapUnit {
if (tile.improvementInProgress == "Remove Road" || tile.improvementInProgress == "Remove Railroad")
tile.roadStatus = RoadStatus.None
else {
val removedFeature = tile.improvementInProgress!!.removePrefix("Remove ")
if (tile.ruleset.terrains[removedFeature]!!.uniques
val removedFeatureName = tile.improvementInProgress!!.removePrefix("Remove ")
val removedFeatureObject = tile.ruleset.terrains[removedFeatureName]
if (removedFeatureObject!=null && removedFeatureObject.uniques
.contains("Provides a one-time Production bonus to the closest city when cut down")) {
tryProvideProductionToClosestCity(removedFeature)
tryProvideProductionToClosestCity(removedFeatureName)
}
tile.terrainFeatures.remove(removedFeature)
tile.terrainFeatures.remove(removedFeatureName)
}
}
tile.improvementInProgress == "Road" -> tile.roadStatus = RoadStatus.Road