diff --git a/core/src/com/unciv/logic/city/IConstruction.kt b/core/src/com/unciv/logic/city/IConstruction.kt index 739edc2ec9..ecb0eac16f 100644 --- a/core/src/com/unciv/logic/city/IConstruction.kt +++ b/core/src/com/unciv/logic/city/IConstruction.kt @@ -129,7 +129,8 @@ class RejectionReasons: HashSet() { RejectionReason.PopulationRequirement, RejectionReason.ConsumesResources, RejectionReason.CanOnlyBePurchased, - RejectionReason.MaxNumberBuildable + RejectionReason.MaxNumberBuildable, + RejectionReason.NoPlaceToPutUnit ) } } @@ -184,7 +185,8 @@ enum class RejectionReason(val shouldShow: Boolean, val errorMessage: String) { PopulationRequirement(true, "Requires more population"), - NoSettlerForOneCityPlayers(false, "No settlers for city-states or one-city challengers"); + NoSettlerForOneCityPlayers(false, "No settlers for city-states or one-city challengers"), + NoPlaceToPutUnit(true, "No space to place this unit"); fun toInstance(errorMessage: String = this.errorMessage, shouldShow: Boolean = this.shouldShow): RejectionReasonInstance { diff --git a/core/src/com/unciv/logic/map/MapUnit.kt b/core/src/com/unciv/logic/map/MapUnit.kt index 5345d44bcb..5a8662f4aa 100644 --- a/core/src/com/unciv/logic/map/MapUnit.kt +++ b/core/src/com/unciv/logic/map/MapUnit.kt @@ -1008,7 +1008,7 @@ class MapUnit { fun canTransport(unit: MapUnit): Boolean { if (owner != unit.owner) return false if (!isTransportTypeOf(unit)) return false - if (unit.getMatchingUniques(UniqueType.CannotBeCarriedBy).any{matchesFilter(it.params[0])}) return false + if (unit.getMatchingUniques(UniqueType.CannotBeCarriedBy).any { matchesFilter(it.params[0]) }) return false if (currentTile.airUnits.count { it.isTransported } >= carryCapacity(unit)) return false return true } diff --git a/core/src/com/unciv/models/ruleset/unit/BaseUnit.kt b/core/src/com/unciv/models/ruleset/unit/BaseUnit.kt index a34261bc19..fa3fc6dbbf 100644 --- a/core/src/com/unciv/models/ruleset/unit/BaseUnit.kt +++ b/core/src/com/unciv/models/ruleset/unit/BaseUnit.kt @@ -351,6 +351,12 @@ class BaseUnit : RulesetObject(), INonPerpetualConstruction { val rejectionReasons = RejectionReasons() if (isWaterUnit() && !cityConstructions.cityInfo.isCoastal()) rejectionReasons.add(RejectionReason.WaterUnitsInCoastalCities) + if (isAirUnit()) { + val fakeUnit = getMapUnit(cityConstructions.cityInfo.civInfo) + val canUnitEnterTile = fakeUnit.movement.canMoveTo(cityConstructions.cityInfo.getCenterTile()) + if (!canUnitEnterTile) + rejectionReasons.add(RejectionReason.NoPlaceToPutUnit) + } val civInfo = cityConstructions.cityInfo.civInfo for (unique in uniqueObjects) { @Suppress("NON_EXHAUSTIVE_WHEN")