From fa9d7e1ca7d647e86da93c3f1b6d692a43fca72d Mon Sep 17 00:00:00 2001 From: Oskar Niesen Date: Thu, 4 Jan 2024 01:04:05 -0600 Subject: [PATCH] Fixed crash when a worker tries to build a cached improvement that it can't build (#10854) * Worker won't try to build the cached improvement that it can't build * Accounted for the repair case as well --- core/src/com/unciv/logic/automation/unit/WorkerAutomation.kt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/core/src/com/unciv/logic/automation/unit/WorkerAutomation.kt b/core/src/com/unciv/logic/automation/unit/WorkerAutomation.kt index 4f9f1ab215..5ffff0d5c0 100644 --- a/core/src/com/unciv/logic/automation/unit/WorkerAutomation.kt +++ b/core/src/com/unciv/logic/automation/unit/WorkerAutomation.kt @@ -564,7 +564,9 @@ class WorkerAutomation( } } } - + // A better tile than this unit can build might have been stored in the cache + if (!rank.repairImprovment!! && (rank.bestImprovement == null || + !unit.canBuildImprovement(rank.bestImprovement!!, tile))) return -100f return rank.improvementPriority!! }