Fixed bug where a unit auto-exploring ancient ruins would in some cases disappear after upgrading (#5285)

This commit is contained in:
Xander Lenstra
2021-09-21 19:18:02 +02:00
committed by GitHub
parent eedfbe0235
commit 7a59cbcbe8

View File

@ -24,7 +24,7 @@ object UnitAutomation {
} }
internal fun tryExplore(unit: MapUnit): Boolean { internal fun tryExplore(unit: MapUnit): Boolean {
if (tryGoToRuinAndEncampment(unit) && unit.currentMovement == 0f) return true if (tryGoToRuinAndEncampment(unit) && (unit.currentMovement == 0f || unit.isDestroyed)) return true
val explorableTilesThisTurn = val explorableTilesThisTurn =
unit.movement.getDistanceToTiles().keys.filter { isGoodTileToExplore(unit, it) } unit.movement.getDistanceToTiles().keys.filter { isGoodTileToExplore(unit, it) }
@ -503,8 +503,7 @@ object UnitAutomation {
/** This is what a unit with the 'explore' action does. /** This is what a unit with the 'explore' action does.
It also explores, but also has other functions, like healing if necessary. */ It also explores, but also has other functions, like healing if necessary. */
fun automatedExplore(unit: MapUnit) { fun automatedExplore(unit: MapUnit) {
if (tryGoToRuinAndEncampment(unit) && unit.currentMovement == 0f) return if (tryGoToRuinAndEncampment(unit) && (unit.currentMovement == 0f || unit.isDestroyed)) return
if (unit.isDestroyed) return // Opening ruins _might_ have upgraded us to another unit
if (unit.health < 80 && tryHealUnit(unit)) return if (unit.health < 80 && tryHealUnit(unit)) return
if (tryExplore(unit)) return if (tryExplore(unit)) return
unit.civInfo.addNotification("${unit.shortDisplayName()} finished exploring.", unit.currentTile.position, unit.name, "OtherIcons/Sleep") unit.civInfo.addNotification("${unit.shortDisplayName()} finished exploring.", unit.currentTile.position, unit.name, "OtherIcons/Sleep")