mirror of
https://github.com/yairm210/Unciv.git
synced 2025-02-01 02:14:51 +07:00
Fixed units not teleporting out of sold city tiles (#4161)
Fixed a bug where units were not immediately teleported out of the territory of a city when the owner of the city accepted a trade to sell it in their turn. This bug also used to crash the game if one of the units that were not teleported out was selected and they were able to reach a tile with a same-type unit of their own civ that could also reach them, since the unit swapping eligibility checking code would try to remove the unit and then place them back on an illegal tile.
This commit is contained in:
parent
b3f5820cb4
commit
6a713deeea
@ -88,7 +88,14 @@ class TradeLogic(val ourCivilization:CivilizationInfo, val otherCivilization: Ci
|
||||
if (offer.type == TradeType.City) {
|
||||
val city = from.cities.first { it.id == offer.name }
|
||||
city.moveToCiv(to)
|
||||
city.getCenterTile().getUnits().toList().forEach { it.movement.teleportToClosestMoveableTile() }
|
||||
city.getCenterTile().getUnits().forEach { it.movement.teleportToClosestMoveableTile() }
|
||||
city.getTiles().forEach{ tile ->
|
||||
tile.getUnits().forEach{ unit ->
|
||||
if (!unit.civInfo.canEnterTiles(to)) {
|
||||
unit.movement.teleportToClosestMoveableTile()
|
||||
}
|
||||
}
|
||||
}
|
||||
to.updateViewableTiles()
|
||||
from.updateViewableTiles()
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user