From 5beac5cd03b0be515cf6aa7bdaf09f1c4562ba99 Mon Sep 17 00:00:00 2001 From: Yair Morgenstern Date: Tue, 2 Oct 2018 00:00:33 +0300 Subject: [PATCH] Minor bugfix --- core/src/com/unciv/logic/map/UnitMovementAlgorithms.kt | 2 ++ core/src/com/unciv/ui/worldscreen/TileMapHolder.kt | 8 +++++--- 2 files changed, 7 insertions(+), 3 deletions(-) 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()