Skip to content

Commit

Permalink
Some tile still has owner after city has been razed. (#8252)
Browse files Browse the repository at this point in the history
* resolve: the tile still has owner after city has been razed.

* working city null check.

* avoid concurrent modification.
  • Loading branch information
nacro711072 authored Dec 28, 2022
1 parent 0519b92 commit 301cd89
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
6 changes: 5 additions & 1 deletion core/src/com/unciv/logic/civilization/CivilizationInfo.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}

Expand Down
2 changes: 1 addition & 1 deletion core/src/com/unciv/ui/cityscreen/CityScreenTileTable.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down

0 comments on commit 301cd89

Please sign in to comment.