From 9b878bef6d5b7dea9072161724195d8d0e4ad371 Mon Sep 17 00:00:00 2001 From: GeorgCantor Date: Sat, 13 Sep 2025 22:26:12 +0300 Subject: [PATCH] Update BarbarianManager.kt --- .../unciv/logic/automation/civilization/BarbarianManager.kt | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/core/src/com/unciv/logic/automation/civilization/BarbarianManager.kt b/core/src/com/unciv/logic/automation/civilization/BarbarianManager.kt index 399b80c2b1..b28435a0fa 100644 --- a/core/src/com/unciv/logic/automation/civilization/BarbarianManager.kt +++ b/core/src/com/unciv/logic/automation/civilization/BarbarianManager.kt @@ -54,13 +54,15 @@ class BarbarianManager : IsPartOfGameInfoSerialization { fun updateEncampments() { // Check if camps were destroyed - for (encampment in encampments.toList()) { // tolist to avoid concurrent modification + val iterator = encampments.iterator() + while (iterator.hasNext()) { + val encampment = iterator.next() if (tileMap[encampment.position].improvement != Constants.barbarianEncampment) { encampment.wasDestroyed() } // Check if the ghosts are ready to depart if (encampment.destroyed && encampment.countdown == 0) - encampments.remove(encampment) + iterator.remove() } // Possibly place a new encampment