From f2c8c041064b7b0e7aa362405e3679790971171e Mon Sep 17 00:00:00 2001 From: Yair Morgenstern Date: Thu, 23 Apr 2020 20:00:08 +0300 Subject: [PATCH] More concurrency problems solved --- core/src/com/unciv/logic/city/CityExpansionManager.kt | 2 +- core/src/com/unciv/logic/map/MapUnit.kt | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/core/src/com/unciv/logic/city/CityExpansionManager.kt b/core/src/com/unciv/logic/city/CityExpansionManager.kt index 24b52b99eb..84095c3773 100644 --- a/core/src/com/unciv/logic/city/CityExpansionManager.kt +++ b/core/src/com/unciv/logic/city/CityExpansionManager.kt @@ -132,7 +132,7 @@ class CityExpansionManager { cityInfo.civInfo.updateDetailedCivResources() cityInfo.cityStats.update() - for (unit in tileInfo.getUnits()) + for (unit in tileInfo.getUnits().toList()) // tolisted because we're modifying if (!unit.civInfo.canEnterTiles(cityInfo.civInfo)) unit.movement.teleportToClosestMoveableTile() diff --git a/core/src/com/unciv/logic/map/MapUnit.kt b/core/src/com/unciv/logic/map/MapUnit.kt index a4cbf20c9e..1bb0426bb9 100644 --- a/core/src/com/unciv/logic/map/MapUnit.kt +++ b/core/src/com/unciv/logic/map/MapUnit.kt @@ -534,8 +534,8 @@ class MapUnit { } fun disband() { - // evacuation of transported units before disbanding, if possible - for (unit in currentTile.getUnits().filter { it.isTransported && isTransportTypeOf(it) }) { + // evacuation of transported units before disbanding, if possible. toListed because we're modifying the unit list. + for (unit in currentTile.getUnits().filter { it.isTransported && isTransportTypeOf(it) }.toList()) { // we disbanded a carrier in a city, it can still stay in the city if (currentTile.isCityCenter() && unit.movement.canMoveTo(currentTile)) continue // if no "fuel" to escape, should be disbanded as well