From 7c26daaed2f363dfe1901953cf40a43e9bcedc9c Mon Sep 17 00:00:00 2001 From: Yair Morgenstern Date: Tue, 19 Jun 2018 19:33:26 +0300 Subject: [PATCH] Fixed edge-case bug where a tile that a unit was headed towards becomes unreachable afterwards --- core/src/com/unciv/logic/map/MapUnit.kt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/core/src/com/unciv/logic/map/MapUnit.kt b/core/src/com/unciv/logic/map/MapUnit.kt index 5ed38afce5..9a92f58ae1 100644 --- a/core/src/com/unciv/logic/map/MapUnit.kt +++ b/core/src/com/unciv/logic/map/MapUnit.kt @@ -43,7 +43,9 @@ class MapUnit { if (action != null && action!!.startsWith("moveTo")) { val destination = action!!.replace("moveTo ", "").split(",").dropLastWhile { it.isEmpty() }.toTypedArray() val destinationVector = Vector2(Integer.parseInt(destination[0]).toFloat(), Integer.parseInt(destination[1]).toFloat()) - val gotTo = movementAlgs().headTowards(currentTile.tileMap[destinationVector]) + val destinationTile = currentTile.tileMap[destinationVector] + if(!movementAlgs().canReach(destinationTile)) return // That tile that we were moving towards is now unreachable + val gotTo = movementAlgs().headTowards(destinationTile) if(gotTo==currentTile) // We didn't move at all return if (gotTo.position == destinationVector) action = null