mirror of
https://github.com/yairm210/Unciv.git
synced 2025-02-08 10:04:28 +07:00
Resolved #12180 - only trigger population reassignment on new buildings when it really changes something
This commit is contained in:
parent
2ed5fb9d05
commit
396bf60e25
@ -543,13 +543,16 @@ class CityConstructions : IsPartOfGameInfoSerialization {
|
||||
&& city.isCapital())
|
||||
civ.tech.addScience(civ.tech.scienceOfLast8Turns.sum() / 8)
|
||||
|
||||
// Happiness is global, so it could affect all cities
|
||||
if (building.isStatRelated(Stat.Happiness, city)) {
|
||||
for (city in civ.cities) {
|
||||
city.reassignPopulationDeferred()
|
||||
}
|
||||
}
|
||||
else city.reassignPopulationDeferred()
|
||||
val previousHappiness = civ.getHappiness()
|
||||
// can cause civ happiness update: reassignPopulationDeferred -> reassignPopulation -> cityStats.update -> civ.updateHappiness
|
||||
city.reassignPopulationDeferred()
|
||||
val newHappiness = civ.getHappiness()
|
||||
|
||||
/** Same check as [com.unciv.logic.civilization.Civilization.updateStatsForNextTurn] -
|
||||
* but that triggers *stat calculation* whereas this is for *population assignment* */
|
||||
if (previousHappiness != newHappiness && city.civ.gameInfo.ruleset.allHappinessLevelsThatAffectUniques
|
||||
.any { newHappiness < it != previousHappiness < it})
|
||||
city.civ.cities.filter { it != city }.forEach { it.reassignPopulationDeferred() }
|
||||
|
||||
if (tryAddFreeBuildings)
|
||||
city.civ.civConstructions.tryAddFreeBuildings()
|
||||
|
Loading…
Reference in New Issue
Block a user