From ea51c7155b32e0421cd8de6c23b3d0793a98d2ed Mon Sep 17 00:00:00 2001 From: Xander Lenstra <71121390+xlenstra@users.noreply.github.com> Date: Sat, 25 Dec 2021 16:53:10 +0100 Subject: [PATCH] Fixed a bug where an empty improvement picker screen could open (#5815) * Fixed a bug where an empty improvement picker screen could open * Moved the check for constructing instead of building to the unit --- core/src/com/unciv/logic/map/MapUnit.kt | 2 ++ core/src/com/unciv/ui/worldscreen/unit/UnitActions.kt | 8 ++++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/core/src/com/unciv/logic/map/MapUnit.kt b/core/src/com/unciv/logic/map/MapUnit.kt index 23666ef750..c51c0be136 100644 --- a/core/src/com/unciv/logic/map/MapUnit.kt +++ b/core/src/com/unciv/logic/map/MapUnit.kt @@ -1050,6 +1050,8 @@ class MapUnit { } fun canBuildImprovement(improvement: TileImprovement, tile: TileInfo = currentTile): Boolean { + // Workers (and similar) should never be able to (instantly) construct things, only build them + if (improvement.turnsToBuild == 0 && improvement.name != Constants.cancelImprovementOrder) return false val matchingUniques = getMatchingUniques(UniqueType.BuildImprovements) return matchingUniques.any { improvement.matchesFilter(it.params[0]) || tile.matchesTerrainFilter(it.params[0]) } } diff --git a/core/src/com/unciv/ui/worldscreen/unit/UnitActions.kt b/core/src/com/unciv/ui/worldscreen/unit/UnitActions.kt index 480e0d6f1b..d45abdde62 100644 --- a/core/src/com/unciv/ui/worldscreen/unit/UnitActions.kt +++ b/core/src/com/unciv/ui/worldscreen/unit/UnitActions.kt @@ -377,8 +377,12 @@ object UnitActions { if (unit.isEmbarked()) return val canConstruct = unit.currentMovement > 0 - && !tile.isCityCenter() - && unit.civInfo.gameInfo.ruleSet.tileImprovements.values.any { tile.canBuildImprovement(it, unit.civInfo) && unit.canBuildImprovement(it) } + && !tile.isCityCenter() + && unit.civInfo.gameInfo.ruleSet.tileImprovements.values.any { + tile.canBuildImprovement(it, unit.civInfo) + && unit.canBuildImprovement(it) + } + actionList += UnitAction(UnitActionType.ConstructImprovement, isCurrentAction = unit.currentTile.hasImprovementInProgress(),