mirror of
https://github.com/yairm210/Unciv.git
synced 2025-08-01 15:49:46 +07:00
Fixed a few rare mod-specific crashes (#6070)
This commit is contained in:
@ -63,11 +63,12 @@ class PopulationManager {
|
||||
if (foodStored >= getFoodToNextPopulation()) { // growth!
|
||||
foodStored -= getFoodToNextPopulation()
|
||||
var percentOfFoodCarriedOver =
|
||||
(cityInfo.getMatchingUniques(UniqueType.CarryOverFood)
|
||||
(
|
||||
(cityInfo.getMatchingUniques(UniqueType.CarryOverFood)
|
||||
+ cityInfo.getMatchingUniques(UniqueType.CarryOverFoodAlsoDeprecated)
|
||||
).filter { cityInfo.matchesFilter(it.params[1]) }
|
||||
+ cityInfo.getMatchingUniques(UniqueType.CarryOverFoodDeprecated)
|
||||
+ cityInfo.getMatchingUniques(UniqueType.CarryOverFoodAlsoDeprecated)
|
||||
).filter { cityInfo.matchesFilter(it.params[1]) }
|
||||
.sumOf { it.params[0].toInt() }
|
||||
).sumOf { it.params[0].toInt() }
|
||||
// Try to avoid runaway food gain in mods, just in case
|
||||
if (percentOfFoodCarriedOver > 95) percentOfFoodCarriedOver = 95
|
||||
foodStored += (getFoodToNextPopulation() * percentOfFoodCarriedOver / 100f).toInt()
|
||||
|
@ -1,6 +1,7 @@
|
||||
package com.unciv.logic.civilization
|
||||
|
||||
import com.badlogic.gdx.math.Vector2
|
||||
import com.unciv.Constants
|
||||
import com.unciv.UncivGame
|
||||
import com.unciv.logic.GameInfo
|
||||
import com.unciv.logic.UncivShowableException
|
||||
@ -965,6 +966,11 @@ class CivilizationInfo {
|
||||
shouldShowDiplomaticVotingResults()
|
||||
|
||||
private fun updateRevolts() {
|
||||
if (gameInfo.civilizations.none { it.civName == Constants.barbarians }) {
|
||||
// Can't spawn revolts without barbarians ¯\_(ツ)_/¯
|
||||
return
|
||||
}
|
||||
|
||||
if (!hasUnique(UniqueType.SpawnRebels)) {
|
||||
removeFlag(CivFlags.RevoltSpawning.name)
|
||||
return
|
||||
|
Reference in New Issue
Block a user