mirror of
https://github.com/yairm210/Unciv.git
synced 2025-01-10 07:16:54 +07:00
Fixed bug that occured when city was being razed and managed to reach -1 population somehow
This commit is contained in:
parent
94e9098ac0
commit
c5e4a75505
@ -161,7 +161,7 @@ class CityInfo {
|
||||
expansion.nextTurn(stats.culture)
|
||||
if(isBeingRazed){
|
||||
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)
|
||||
destroyCity()
|
||||
if(isCapital() && civInfo.cities.isNotEmpty()) // Yes, we actually razed the capital. Some people do this.
|
||||
@ -170,8 +170,10 @@ class CityInfo {
|
||||
}
|
||||
else population.nextTurn(stats.food)
|
||||
|
||||
health = min(health+20, getMaxHealth())
|
||||
population.unassignExtraPopulation()
|
||||
if(this in civInfo.cities) { // city was not destroyed
|
||||
health = min(health + 20, getMaxHealth())
|
||||
population.unassignExtraPopulation()
|
||||
}
|
||||
}
|
||||
|
||||
fun destroyCity() {
|
||||
|
@ -131,6 +131,8 @@ class CityStats {
|
||||
val happinessFromBuildings = cityInfo.cityConstructions.getStats().happiness.toInt().toFloat()
|
||||
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
|
||||
return newHappinessList
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user