From 4d0f66e159782ed46ec781a35cf30a44c0313701 Mon Sep 17 00:00:00 2001 From: Yair Morgenstern Date: Sat, 6 Feb 2021 19:41:51 +0200 Subject: [PATCH] Solved "quantum tunneling" bug for new movement algorithm --- core/src/com/unciv/logic/map/UnitMovementAlgorithms.kt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/core/src/com/unciv/logic/map/UnitMovementAlgorithms.kt b/core/src/com/unciv/logic/map/UnitMovementAlgorithms.kt index 791d5d276e..b0cf61ae26 100644 --- a/core/src/com/unciv/logic/map/UnitMovementAlgorithms.kt +++ b/core/src/com/unciv/logic/map/UnitMovementAlgorithms.kt @@ -299,7 +299,8 @@ class UnitMovementAlgorithms(val unit:MapUnit) { val distanceToTiles = getDistanceToTiles() val pathToDestination = distanceToTiles.getPathToTile(destination) - val lastReachableTile = pathToDestination.last { canMoveTo(it) } + val movableTiles = pathToDestination.takeWhile { canPassThrough(it) } + val lastReachableTile = movableTiles.last { canMoveTo(it) } val pathToLastReachableTile = distanceToTiles.getPathToTile(lastReachableTile) if (!unit.civInfo.gameInfo.gameParameters.godMode) { @@ -419,7 +420,7 @@ class UnitMovementAlgorithms(val unit:MapUnit) { if (!canPassThrough(tile)) return false - if(tile.isCityCenter() && tile.getOwner()!=unit.civInfo) return false // even if they'll let us pass through, we can't enter their city + if (tile.isCityCenter() && tile.getOwner() != unit.civInfo) return false // even if they'll let us pass through, we can't enter their city if (unit.type.isCivilian()) return tile.civilianUnit == null && (tile.militaryUnit == null || tile.militaryUnit!!.owner == unit.owner)