mirror of
https://github.com/yairm210/Unciv.git
synced 2025-07-04 23:40:01 +07:00
Fixed naval units not tp-ing out of razed cities (#4238)
This commit is contained in:

committed by
GitHub

parent
f745ca9421
commit
cf9e00c589
@ -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())
|
||||
}
|
||||
|
Reference in New Issue
Block a user