mirror of
https://github.com/yairm210/Unciv.git
synced 2025-09-28 22:37:02 -04:00
Solved crashing 'head towards sieged city' bug
This commit is contained in:
parent
4d16b3fcf8
commit
d3f639e29c
@ -298,7 +298,7 @@ object UnitAutomation {
|
|||||||
val reachableTileNearSiegedCity = siegedCities
|
val reachableTileNearSiegedCity = siegedCities
|
||||||
.flatMap { it.getCenterTile().getTilesAtDistance(2) }
|
.flatMap { it.getCenterTile().getTilesAtDistance(2) }
|
||||||
.sortedBy { it.aerialDistanceTo(unit.currentTile) }
|
.sortedBy { it.aerialDistanceTo(unit.currentTile) }
|
||||||
.firstOrNull { unit.movement.canReach(it) }
|
.firstOrNull { unit.movement.canMoveTo(it) && unit.movement.canReach(it) }
|
||||||
|
|
||||||
if (reachableTileNearSiegedCity != null) {
|
if (reachableTileNearSiegedCity != null) {
|
||||||
unit.movement.headTowards(reachableTileNearSiegedCity)
|
unit.movement.headTowards(reachableTileNearSiegedCity)
|
||||||
|
@ -215,7 +215,8 @@ class UnitMovementAlgorithms(val unit:MapUnit) {
|
|||||||
return unit.currentTile
|
return unit.currentTile
|
||||||
}
|
}
|
||||||
|
|
||||||
/** This is performance-heavy - use as last resort, only after checking everything else! */
|
/** This is performance-heavy - use as last resort, only after checking everything else!
|
||||||
|
* Also note that REACHABLE tiles are not necessarily tiles that the unit CAN ENTER */
|
||||||
fun canReach(destination: TileInfo): Boolean {
|
fun canReach(destination: TileInfo): Boolean {
|
||||||
if (unit.type.isAirUnit() || unit.type.isMissile() || unit.action == Constants.unitActionParadrop)
|
if (unit.type.isAirUnit() || unit.type.isMissile() || unit.action == Constants.unitActionParadrop)
|
||||||
return canReachInCurrentTurn(destination)
|
return canReachInCurrentTurn(destination)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user