From f686b0c6d1f9e9e16bd2c74743ca8f368ba4f160 Mon Sep 17 00:00:00 2001 From: Yair Morgenstern Date: Fri, 31 Jul 2020 10:35:42 +0300 Subject: [PATCH] Units can pass through cities of other friendly civs --- core/src/com/unciv/logic/map/UnitMovementAlgorithms.kt | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/core/src/com/unciv/logic/map/UnitMovementAlgorithms.kt b/core/src/com/unciv/logic/map/UnitMovementAlgorithms.kt index b7453e1be1..78e90b11c0 100644 --- a/core/src/com/unciv/logic/map/UnitMovementAlgorithms.kt +++ b/core/src/com/unciv/logic/map/UnitMovementAlgorithms.kt @@ -303,6 +303,8 @@ class UnitMovementAlgorithms(val unit:MapUnit) { if (!canPassThrough(tile)) return false + if(tile.isCityCenter() && tile.getOwner()!=unit.civInfo) return false // even if they'll let us pass through, we can't enter their city + if (unit.type.isCivilian()) return tile.civilianUnit == null && (tile.militaryUnit == null || tile.militaryUnit!!.owner == unit.owner) else return tile.militaryUnit == null && (tile.civilianUnit == null || tile.civilianUnit!!.owner == unit.owner) @@ -353,8 +355,9 @@ class UnitMovementAlgorithms(val unit:MapUnit) { if (tile.naturalWonder != null) return false val tileOwner = tile.getOwner() - if (tileOwner != null && tileOwner != unit.civInfo) { // comparing the CivInfo objects is cheaper than comparing strings? - if (tile.isCityCenter() && !tile.getCity()!!.hasJustBeenConquered) return false + if (tileOwner != null && tileOwner != unit.civInfo) { // comparing the CivInfo objects is cheaper than comparing strings + if (tile.isCityCenter() && unit.civInfo.isAtWarWith(tileOwner) + && !tile.getCity()!!.hasJustBeenConquered) return false if (!unit.civInfo.canEnterTiles(tileOwner) && !(unit.civInfo.isPlayerCivilization() && tileOwner.isCityState())) return false // AIs won't enter city-state's border.