Fixed crash when a city had negative population due to faster razing (#4389)

This commit is contained in:
Xander Lenstra 2021-07-06 18:41:23 +02:00 committed by GitHub
parent 7875ec4896
commit 9e37cc8f16
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 1 deletions

View File

@ -409,7 +409,7 @@ class CityInfo {
cityConstructions.endTurn(stats)
expansion.nextTurn(stats.culture)
if (isBeingRazed) {
val removedPopulation = 1 + civInfo.getMatchingUniques("Cities are razed [] times as fast").sumBy { it.params[0].toInt() }
val removedPopulation = 1 + civInfo.getMatchingUniques("Cities are razed [] times as fast").sumBy { it.params[0].toInt() - 1 }
population.addPopulation(-1 * removedPopulation)
if (population.population <= 0) {
civInfo.addNotification("[$name] has been razed to the ground!", location, "OtherIcons/Fire")

View File

@ -73,6 +73,7 @@ class PopulationManager {
internal fun addPopulation(count: Int) {
population += count
if (population < 0) population = 0
val freePopulation = getFreePopulation()
if (freePopulation < 0) {
unassignExtraPopulation()