From 301cd899b2790f86c33b2577cece98353320df80 Mon Sep 17 00:00:00 2001 From: nacro711072 Date: Wed, 28 Dec 2022 20:55:44 +0800 Subject: [PATCH] Some tile still has owner after city has been razed. (#8252) * resolve: the tile still has owner after city has been razed. * working city null check. * avoid concurrent modification. --- core/src/com/unciv/logic/civilization/CivilizationInfo.kt | 6 +++++- core/src/com/unciv/ui/cityscreen/CityScreenTileTable.kt | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/core/src/com/unciv/logic/civilization/CivilizationInfo.kt b/core/src/com/unciv/logic/civilization/CivilizationInfo.kt index 73dba40188437..8bd00fd311741 100644 --- a/core/src/com/unciv/logic/civilization/CivilizationInfo.kt +++ b/core/src/com/unciv/logic/civilization/CivilizationInfo.kt @@ -1002,7 +1002,11 @@ class CivilizationInfo : IsPartOfGameInfoSerialization { if (isMajorCiv()) greatPeople.addGreatPersonPoints(getGreatPersonPointsForNextTurn()) // City-states don't get great people! - for (city in cities.toList()) { // a city can be removed while iterating (if it's being razed) so we need to iterate over a copy + // To handle tile's owner issue (#8246), we need to run being razed city first. + for (city in sequence { + yieldAll(cities.filter { it.isBeingRazed }) + yieldAll(cities.filterNot { it.isBeingRazed }) + }.toList()) { // a city can be removed while iterating (if it's being razed) so we need to iterate over a copy city.endTurn() } diff --git a/core/src/com/unciv/ui/cityscreen/CityScreenTileTable.kt b/core/src/com/unciv/ui/cityscreen/CityScreenTileTable.kt index 4e782faf93813..fe18973627c44 100644 --- a/core/src/com/unciv/ui/cityscreen/CityScreenTileTable.kt +++ b/core/src/com/unciv/ui/cityscreen/CityScreenTileTable.kt @@ -74,7 +74,7 @@ class CityScreenTileTable(private val cityScreen: CityScreen): Table() { if (selectedTile.owningCity != null) innerTable.add("Owned by [${selectedTile.owningCity!!.name}]".toLabel()).row() - if (city.civInfo.cities.filterNot { it == city }.any { it.isWorked(selectedTile) }) + if (selectedTile.getWorkingCity() != null) innerTable.add("Worked by [${selectedTile.getWorkingCity()!!.name}]".toLabel()).row() if (city.isWorked(selectedTile)) {