mirror of
https://github.com/yairm210/Unciv.git
synced 2025-09-28 14:24:43 -04:00
Fixed crash when a city had negative population due to faster razing (#4389)
This commit is contained in:
parent
7875ec4896
commit
9e37cc8f16
@ -409,7 +409,7 @@ class CityInfo {
|
|||||||
cityConstructions.endTurn(stats)
|
cityConstructions.endTurn(stats)
|
||||||
expansion.nextTurn(stats.culture)
|
expansion.nextTurn(stats.culture)
|
||||||
if (isBeingRazed) {
|
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)
|
population.addPopulation(-1 * removedPopulation)
|
||||||
if (population.population <= 0) {
|
if (population.population <= 0) {
|
||||||
civInfo.addNotification("[$name] has been razed to the ground!", location, "OtherIcons/Fire")
|
civInfo.addNotification("[$name] has been razed to the ground!", location, "OtherIcons/Fire")
|
||||||
|
@ -73,6 +73,7 @@ class PopulationManager {
|
|||||||
|
|
||||||
internal fun addPopulation(count: Int) {
|
internal fun addPopulation(count: Int) {
|
||||||
population += count
|
population += count
|
||||||
|
if (population < 0) population = 0
|
||||||
val freePopulation = getFreePopulation()
|
val freePopulation = getFreePopulation()
|
||||||
if (freePopulation < 0) {
|
if (freePopulation < 0) {
|
||||||
unassignExtraPopulation()
|
unassignExtraPopulation()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user