Fixed bug where effects of all aquaducts nationwide stacked in each city (#4487)

* Fixed bug where effects of all aquaducts nationwide stacked in each city

* Implemented requested changes

* Implemented requested changes better
This commit is contained in:
Xander Lenstra
2021-07-13 05:26:37 +02:00
committed by GitHub
parent 573eacb8c9
commit 07e3a2228e
2 changed files with 10 additions and 4 deletions

View File

@ -60,9 +60,15 @@ class PopulationManager {
if (foodStored >= getFoodToNextPopulation()) { // growth!
foodStored -= getFoodToNextPopulation()
var percentOfFoodCarriedOver = cityInfo
.getMatchingUniques("[]% of food is carried over after population increases")
.getMatchingUniques("[]% of food is carried over [] after population increases")
.filter { cityInfo.matchesFilter(it.params[1]) }
.sumBy { it.params[0].toInt() }
// Deprecated since 3.15.11
percentOfFoodCarriedOver += cityInfo
.getLocalMatchingUniques("[]% of food is carried over after population increases")
.sumBy { it.params[0].toInt() }
// Try to avoid runaway food gain in mods, just in case mod makes don't notice it
//
// Try to avoid runaway food gain in mods, just in case
if (percentOfFoodCarriedOver > 95) percentOfFoodCarriedOver = 95
foodStored += (getFoodToNextPopulation() * percentOfFoodCarriedOver / 100f).toInt()
population++