From cf9e00c58977482279b9c355f97168ff3930b8bb Mon Sep 17 00:00:00 2001 From: Arthur van der Staaij <32672293+avdstaaij@users.noreply.github.com> Date: Wed, 23 Jun 2021 08:40:32 +0200 Subject: [PATCH] Fixed naval units not tp-ing out of razed cities (#4238) --- core/src/com/unciv/logic/city/CityInfo.kt | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/core/src/com/unciv/logic/city/CityInfo.kt b/core/src/com/unciv/logic/city/CityInfo.kt index e1e530b4fe..15d6472ec2 100644 --- a/core/src/com/unciv/logic/city/CityInfo.kt +++ b/core/src/com/unciv/logic/city/CityInfo.kt @@ -383,6 +383,12 @@ class CityInfo { fun destroyCity() { for (airUnit in getCenterTile().airUnits.toList()) airUnit.destroy() //Destroy planes stationed in city + // The relinquish ownership MUST come before removing the city, + // because it updates the city stats which assumes there is a capital, so if you remove the capital it crashes + getTiles().forEach { expansion.relinquishOwnership(it) } + civInfo.cities = civInfo.cities.toMutableList().apply { remove(this@CityInfo) } + getCenterTile().improvement = "City ruins" + // Edge case! What if a water unit is in a city, and you raze the city? // Well, the water unit has to return to the water! for (unit in getCenterTile().getUnits()) { @@ -390,12 +396,6 @@ class CityInfo { unit.movement.teleportToClosestMoveableTile() } - // The relinquish ownership MUST come before removing the city, - // because it updates the city stats which assumes there is a capital, so if you remove the capital it crashes - getTiles().forEach { expansion.relinquishOwnership(it) } - civInfo.cities = civInfo.cities.toMutableList().apply { remove(this@CityInfo) } - getCenterTile().improvement = "City ruins" - if (isCapital() && civInfo.cities.isNotEmpty()) { // Move the capital if destroyed (by a nuke or by razing) civInfo.cities.first().cityConstructions.addBuilding(capitalCityIndicator()) }