Fixed naval units not tp-ing out of razed cities (#4238)

This commit is contained in:
Arthur van der Staaij
2021-06-23 08:40:32 +02:00
committed by GitHub
parent f745ca9421
commit cf9e00c589

View File

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