mirror of
https://github.com/yairm210/Unciv.git
synced 2025-09-27 05:46:43 -04:00
Fixed bug where 'remove road' would also remove other improvements under specific circumstances (#4583)
This commit is contained in:
parent
70a18de7cc
commit
605581c78b
@ -452,20 +452,22 @@ class MapUnit {
|
|||||||
if (civInfo.isCurrentPlayer())
|
if (civInfo.isCurrentPlayer())
|
||||||
UncivGame.Current.settings.addCompletedTutorialTask("Construct an improvement")
|
UncivGame.Current.settings.addCompletedTutorialTask("Construct an improvement")
|
||||||
when {
|
when {
|
||||||
tile.improvementInProgress!!.startsWith("Remove") -> {
|
tile.improvementInProgress!!.startsWith("Remove ") -> {
|
||||||
|
val removedFeatureName = tile.improvementInProgress!!.removePrefix("Remove ")
|
||||||
val tileImprovement = tile.getTileImprovement()
|
val tileImprovement = tile.getTileImprovement()
|
||||||
if (tileImprovement != null
|
if (tileImprovement != null
|
||||||
&& tile.terrainFeatures.any { tileImprovement.terrainsCanBeBuiltOn.contains(it) }
|
&& tile.terrainFeatures.any {
|
||||||
|
tileImprovement.terrainsCanBeBuiltOn.contains(it) && it == removedFeatureName
|
||||||
|
}
|
||||||
&& !tileImprovement.terrainsCanBeBuiltOn.contains(tile.baseTerrain)
|
&& !tileImprovement.terrainsCanBeBuiltOn.contains(tile.baseTerrain)
|
||||||
) {
|
) {
|
||||||
tile.improvement =
|
// We removed a terrain (e.g. Forest) and the improvement (e.g. Lumber mill) requires it!
|
||||||
null // We removed a terrain (e.g. Forest) and the improvement (e.g. Lumber mill) requires it!
|
tile.improvement = null
|
||||||
if (tile.resource != null) civInfo.updateDetailedCivResources() // unlikely, but maybe a mod makes a resource improvement dependent on a terrain feature
|
if (tile.resource != null) civInfo.updateDetailedCivResources() // unlikely, but maybe a mod makes a resource improvement dependent on a terrain feature
|
||||||
}
|
}
|
||||||
if (tile.improvementInProgress == "Remove Road" || tile.improvementInProgress == "Remove Railroad")
|
if (tile.improvementInProgress == "Remove Road" || tile.improvementInProgress == "Remove Railroad") {
|
||||||
tile.roadStatus = RoadStatus.None
|
tile.roadStatus = RoadStatus.None
|
||||||
else {
|
} else {
|
||||||
val removedFeatureName = tile.improvementInProgress!!.removePrefix("Remove ")
|
|
||||||
val removedFeatureObject = tile.ruleset.terrains[removedFeatureName]
|
val removedFeatureObject = tile.ruleset.terrains[removedFeatureName]
|
||||||
if (removedFeatureObject != null && removedFeatureObject.uniques
|
if (removedFeatureObject != null && removedFeatureObject.uniques
|
||||||
.contains("Provides a one-time Production bonus to the closest city when cut down")
|
.contains("Provides a one-time Production bonus to the closest city when cut down")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user