diff --git a/core/src/com/unciv/logic/map/UnitMovementAlgorithms.kt b/core/src/com/unciv/logic/map/UnitMovementAlgorithms.kt index 819d58ee8a..a268b0677b 100644 --- a/core/src/com/unciv/logic/map/UnitMovementAlgorithms.kt +++ b/core/src/com/unciv/logic/map/UnitMovementAlgorithms.kt @@ -146,6 +146,8 @@ class UnitMovementAlgorithms(val unit:MapUnit) { } } else { // If the tile is far away, we need to build a path how to get there, and then take the first step val path = getShortestPath(destination) + class UnreachableDestinationException:Exception() + if(path.isEmpty()) throw UnreachableDestinationException() destinationTileThisTurn = path.first() } diff --git a/core/src/com/unciv/ui/worldscreen/TileMapHolder.kt b/core/src/com/unciv/ui/worldscreen/TileMapHolder.kt index d7b615b2ef..a8c500d7af 100644 --- a/core/src/com/unciv/ui/worldscreen/TileMapHolder.kt +++ b/core/src/com/unciv/ui/worldscreen/TileMapHolder.kt @@ -61,9 +61,11 @@ class TileMapHolder(internal val worldScreen: WorldScreen, internal val tileMap: if(selectedUnit.currentMovement>0) moveHereGroup.onClick { - selectedUnit.movementAlgs().headTowards(tileInfo) - if(selectedUnit.currentTile != tileInfo) - selectedUnit.action = "moveTo " + tileInfo.position.x.toInt() + "," + tileInfo.position.y.toInt() + if(selectedUnit.movementAlgs().canReach(tileInfo)) { + selectedUnit.movementAlgs().headTowards(tileInfo) + if (selectedUnit.currentTile != tileInfo) + selectedUnit.action = "moveTo " + tileInfo.position.x.toInt() + "," + tileInfo.position.y.toInt() + } worldScreen.update() overlayActor!!.remove()