From 75130322a8d59d2932cbec7b64666de6af2a9027 Mon Sep 17 00:00:00 2001 From: Yair Morgenstern Date: Sun, 8 Jan 2023 15:04:36 +0200 Subject: [PATCH] Resolved #8337 - Fixed crash on one city challenge when conquering capital and enemy has only puppeted cities left --- core/src/com/unciv/logic/city/CityInfo.kt | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/core/src/com/unciv/logic/city/CityInfo.kt b/core/src/com/unciv/logic/city/CityInfo.kt index 9126549046..c6c0ec82eb 100644 --- a/core/src/com/unciv/logic/city/CityInfo.kt +++ b/core/src/com/unciv/logic/city/CityInfo.kt @@ -779,6 +779,13 @@ class CityInfo : IsPartOfGameInfoSerialization { for (tile in getTiles()) { expansion.relinquishOwnership(tile) } + + // Move the capital if destroyed (by a nuke or by razing) + // Must be before removing existing capital because we may be annexing a puppet which means city stats update - see #8337 + if (isCapital() && civInfo.cities.size > 1) { + civInfo.moveCapitalToNextLargest() + } + civInfo.cities = civInfo.cities.toMutableList().apply { remove(this@CityInfo) } getCenterTile().changeImprovement("City ruins") @@ -789,9 +796,6 @@ class CityInfo : IsPartOfGameInfoSerialization { unit.movement.teleportToClosestMoveableTile() } - if (isCapital() && civInfo.cities.isNotEmpty()) { // Move the capital if destroyed (by a nuke or by razing) - civInfo.moveCapitalToNextLargest() - } // Update proximity rankings for all civs for (otherCiv in civInfo.gameInfo.getAliveMajorCivs()) {