mirror of
https://github.com/yairm210/Unciv.git
synced 2025-07-04 07:17:50 +07:00
Fix rare case where ruins would delete an AI unit while trying to upgrade it (#7084)
* Fix rare case where ruins could delete AI units when upgrading the unit * Don't moveToTile if the unit is destroyed * Update comment * Forgot to uncomment line * Move currentMovement = 0f to destroy()
This commit is contained in:

committed by
GitHub

parent
f5317eb53b
commit
c40b25a73b
@ -924,6 +924,7 @@ class MapUnit {
|
||||
fun destroy() {
|
||||
val currentPosition = Vector2(getTile().position)
|
||||
civInfo.attacksSinceTurnStart.addAll(attacksSinceTurnStart.asSequence().map { CivilizationInfo.HistoricalAttackMemory(this.name, currentPosition, it) })
|
||||
currentMovement = 0f
|
||||
removeFromTile()
|
||||
civInfo.removeUnit(this)
|
||||
civInfo.updateViewableTiles()
|
||||
|
@ -1104,7 +1104,7 @@ open class TileInfo {
|
||||
when {
|
||||
airUnits.contains(mapUnit) -> airUnits.remove(mapUnit)
|
||||
civilianUnit == mapUnit -> civilianUnit = null
|
||||
else -> militaryUnit = null
|
||||
militaryUnit == mapUnit -> militaryUnit = null
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -417,7 +417,7 @@ class UnitMovementAlgorithms(val unit: MapUnit) {
|
||||
}
|
||||
|
||||
fun moveToTile(destination: TileInfo, considerZoneOfControl: Boolean = true) {
|
||||
if (destination == unit.getTile()) return // already here!
|
||||
if (destination == unit.getTile() || unit.isDestroyed) return // already here (or dead)!
|
||||
|
||||
|
||||
if (unit.baseUnit.movesLikeAirUnits()) { // air units move differently from all other units
|
||||
|
Reference in New Issue
Block a user