mirror of
https://github.com/yairm210/Unciv.git
synced 2025-07-13 17:28:57 +07:00
Fixed bug that occured when city was being razed and managed to reach -1 population somehow
This commit is contained in:
@ -161,7 +161,7 @@ class CityInfo {
|
|||||||
expansion.nextTurn(stats.culture)
|
expansion.nextTurn(stats.culture)
|
||||||
if(isBeingRazed){
|
if(isBeingRazed){
|
||||||
population.population--
|
population.population--
|
||||||
if(population.population==0){
|
if(population.population<=0){ // there are strange cases where we geet to -1
|
||||||
civInfo.addNotification("$name {has been razed to the ground}!",location, Color.RED)
|
civInfo.addNotification("$name {has been razed to the ground}!",location, Color.RED)
|
||||||
destroyCity()
|
destroyCity()
|
||||||
if(isCapital() && civInfo.cities.isNotEmpty()) // Yes, we actually razed the capital. Some people do this.
|
if(isCapital() && civInfo.cities.isNotEmpty()) // Yes, we actually razed the capital. Some people do this.
|
||||||
@ -170,9 +170,11 @@ class CityInfo {
|
|||||||
}
|
}
|
||||||
else population.nextTurn(stats.food)
|
else population.nextTurn(stats.food)
|
||||||
|
|
||||||
|
if(this in civInfo.cities) { // city was not destroyed
|
||||||
health = min(health + 20, getMaxHealth())
|
health = min(health + 20, getMaxHealth())
|
||||||
population.unassignExtraPopulation()
|
population.unassignExtraPopulation()
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fun destroyCity() {
|
fun destroyCity() {
|
||||||
civInfo.cities.remove(this)
|
civInfo.cities.remove(this)
|
||||||
|
@ -131,6 +131,8 @@ class CityStats {
|
|||||||
val happinessFromBuildings = cityInfo.cityConstructions.getStats().happiness.toInt().toFloat()
|
val happinessFromBuildings = cityInfo.cityConstructions.getStats().happiness.toInt().toFloat()
|
||||||
newHappinessList ["Buildings"] = happinessFromBuildings
|
newHappinessList ["Buildings"] = happinessFromBuildings
|
||||||
|
|
||||||
|
// we don't want to modify the existing happiness list because that leads
|
||||||
|
// to concurrency problems if we iterate on it while changing
|
||||||
happinessList=newHappinessList
|
happinessList=newHappinessList
|
||||||
return newHappinessList
|
return newHappinessList
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user