From 98a3ec7805ba658a8897f6afe82aed35ae494069 Mon Sep 17 00:00:00 2001 From: yairm210 Date: Fri, 28 Jun 2024 16:13:04 +0300 Subject: [PATCH] perf: Don't update civ stats on auto assign population --- core/src/com/unciv/logic/automation/unit/UnitAutomation.kt | 4 +++- .../com/unciv/logic/city/managers/CityPopulationManager.kt | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/core/src/com/unciv/logic/automation/unit/UnitAutomation.kt b/core/src/com/unciv/logic/automation/unit/UnitAutomation.kt index e0639988a2..1ba8ba5fb7 100644 --- a/core/src/com/unciv/logic/automation/unit/UnitAutomation.kt +++ b/core/src/com/unciv/logic/automation/unit/UnitAutomation.kt @@ -469,7 +469,9 @@ object UnitAutomation { // this can be sped up if we check each layer separately val unitDistanceToTiles = unit.movement.getDistanceToTilesAtPosition( unit.getTile().position, - unit.getMaxMovement() * CLOSE_ENEMY_TURNS_AWAY_LIMIT + unit.getMaxMovement() * CLOSE_ENEMY_TURNS_AWAY_LIMIT, + // Consider ZoC is expensive - we just want to find the closest, not the exact movement we'll need to get there + false, ) var closeEnemies = TargetHelper.getAttackableEnemies( unit, diff --git a/core/src/com/unciv/logic/city/managers/CityPopulationManager.kt b/core/src/com/unciv/logic/city/managers/CityPopulationManager.kt index dd754b3e30..9804b60bff 100644 --- a/core/src/com/unciv/logic/city/managers/CityPopulationManager.kt +++ b/core/src/com/unciv/logic/city/managers/CityPopulationManager.kt @@ -145,7 +145,7 @@ class CityPopulationManager : IsPartOfGameInfoSerialization { /** Only assigns free population */ internal fun autoAssignPopulation() { - city.cityStats.update() // calculate current stats with current assignments + city.cityStats.update(updateCivStats = false) // calculate current stats with current assignments val freePopulation = getFreePopulation() if (freePopulation <= 0) return