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.
This commit is contained in:
nacro711072
2022-12-28 20:55:44 +08:00
committed by GitHub
parent 0519b92671
commit 301cd899b2
2 changed files with 6 additions and 2 deletions

View File

@ -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()
}

View File

@ -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)) {