From b3166c4922b82ad51c83ff11a31e403bced9039c Mon Sep 17 00:00:00 2001 From: SomeTroglodyte <63000004+SomeTroglodyte@users.noreply.github.com> Date: Mon, 22 May 2023 19:12:31 +0200 Subject: [PATCH] Fix ConcurrentModificationException when puppeting a city (#9430) --- .../unciv/logic/city/managers/CityPopulationManager.kt | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/core/src/com/unciv/logic/city/managers/CityPopulationManager.kt b/core/src/com/unciv/logic/city/managers/CityPopulationManager.kt index d34461d585..434d1fb2d8 100644 --- a/core/src/com/unciv/logic/city/managers/CityPopulationManager.kt +++ b/core/src/com/unciv/logic/city/managers/CityPopulationManager.kt @@ -203,11 +203,9 @@ class CityPopulationManager : IsPartOfGameInfoSerialization { } // unassign specialists that cannot be (e.g. the city was captured and one of the specialist buildings was destroyed) - val maxSpecialists = getMaxSpecialists() - val specialistsHashmap = specialistAllocations - for ((specialistName, amount) in specialistsHashmap) - if (amount > maxSpecialists[specialistName]) - specialistAllocations[specialistName] = maxSpecialists[specialistName] + for ((specialistName, maxAmount) in getMaxSpecialists()) + if (specialistAllocations[specialistName] > maxAmount) + specialistAllocations[specialistName] = maxAmount val localUniqueCache = LocalUniqueCache()