mirror of
https://github.com/yairm210/Unciv.git
synced 2025-09-29 15:01:09 -04:00
Catch for bug in new movement algorithm when you can't move to a unknown tile, but CAN pass through (but not move to) intermediate tiles.
This commit is contained in:
parent
9fd06638a3
commit
8a9301f4d7
@ -285,7 +285,7 @@ class UnitMovementAlgorithms(val unit:MapUnit) {
|
|||||||
unit.putInTile(allowedTile)
|
unit.putInTile(allowedTile)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun moveToTileIncludingUnknownImpassibles(destination: TileInfo){
|
fun moveToTileIncludingUnknownImpassibles(destination: TileInfo) {
|
||||||
if (destination == unit.getTile()) return // already here!
|
if (destination == unit.getTile()) return // already here!
|
||||||
|
|
||||||
if (unit.type.isAirUnit()) { // they move differently from all other units
|
if (unit.type.isAirUnit()) { // they move differently from all other units
|
||||||
@ -299,8 +299,10 @@ class UnitMovementAlgorithms(val unit:MapUnit) {
|
|||||||
|
|
||||||
val distanceToTiles = getDistanceToTiles()
|
val distanceToTiles = getDistanceToTiles()
|
||||||
val pathToDestination = distanceToTiles.getPathToTile(destination)
|
val pathToDestination = distanceToTiles.getPathToTile(destination)
|
||||||
val movableTiles = pathToDestination.takeWhile { canPassThrough(it) }
|
val movableTiles = pathToDestination.takeWhile { canPassThrough(it) }
|
||||||
val lastReachableTile = movableTiles.last { canMoveTo(it) }
|
val lastReachableTile = movableTiles.lastOrNull { canMoveTo(it) }
|
||||||
|
if (lastReachableTile == null) // no tiles can pass though/can move to
|
||||||
|
return
|
||||||
val pathToLastReachableTile = distanceToTiles.getPathToTile(lastReachableTile)
|
val pathToLastReachableTile = distanceToTiles.getPathToTile(lastReachableTile)
|
||||||
|
|
||||||
if (!unit.civInfo.gameInfo.gameParameters.godMode) {
|
if (!unit.civInfo.gameInfo.gameParameters.godMode) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user