From d22da73636821c1684483d6b77b80da7a509c937 Mon Sep 17 00:00:00 2001 From: Yair Morgenstern Date: Tue, 25 Sep 2018 09:15:36 +0300 Subject: [PATCH] Fixed stack overflow exception that happened when an automated worker tried to move to a neighboring tile and coudn't get there. --- core/src/com/unciv/logic/automation/WorkerAutomation.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/src/com/unciv/logic/automation/WorkerAutomation.kt b/core/src/com/unciv/logic/automation/WorkerAutomation.kt index ddc4e0f78c..8b1df35141 100644 --- a/core/src/com/unciv/logic/automation/WorkerAutomation.kt +++ b/core/src/com/unciv/logic/automation/WorkerAutomation.kt @@ -25,8 +25,8 @@ class WorkerAutomation(val unit: MapUnit) { } if (tileToWork != tile) { - unit.movementAlgs().headTowards(tileToWork) - unit.doPreTurnAction() + val reachedTile = unit.movementAlgs().headTowards(tileToWork) + if(reachedTile!=tile) unit.doPreTurnAction() // otherwise, we get a situation where the worker is automated, so it tries to move but doesn't, then tries to automate, then move, etc, forever. Stack overflow exception! return } if (tile.improvementInProgress == null) {