Skip to content

Commit

Permalink
Fix worker improvement crash
Browse files Browse the repository at this point in the history
  • Loading branch information
yairm210 committed Jan 13, 2025
1 parent 5a159ff commit 82cfbe9
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions core/src/com/unciv/logic/automation/unit/WorkerAutomation.kt
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ class WorkerAutomation(
val tileToWork = findTileToWork(unit, dangerousTiles, localUniqueCache)

if (tileToWork != currentTile && tileToWork != null) {
headTowardsTileToWork(unit, tileToWork)
headTowardsTileToWork(unit, tileToWork, localUniqueCache)
return
}

Expand Down Expand Up @@ -160,6 +160,7 @@ class WorkerAutomation(
private fun headTowardsTileToWork(
unit: MapUnit,
tileToWork: Tile,
localUniqueCache: LocalUniqueCache
) {
debug("WorkerAutomation: %s -> head towards %s", unit.toString(), tileToWork)
val currentTile = unit.getTile()
Expand Down Expand Up @@ -194,7 +195,8 @@ class WorkerAutomation(

// tileRankings is updated in getBasePriority, which is only called if isAutomationWorkableTile is true
// Meaning, there are tiles we can't/shouldn't work, and they won't even be in tileRankings
if (unit.currentTile in tileRankings) startWorkOnCurrentTile(unit)
if (tileHasWorkToDo(unit.currentTile, unit, localUniqueCache))
startWorkOnCurrentTile(unit)
}


Expand Down

0 comments on commit 82cfbe9

Please sign in to comment.