From 834239774af18e1ccc3998b35029e91c45bc5f23 Mon Sep 17 00:00:00 2001 From: SomeTroglodyte <63000004+SomeTroglodyte@users.noreply.github.com> Date: Thu, 3 Jul 2025 09:24:01 +0200 Subject: [PATCH] Avoid List.removeFirst() not being available on Android API 21..34 levels (#13567) --- .../com/unciv/logic/civilization/managers/ThreatManager.kt | 3 +-- core/src/com/unciv/logic/civilization/managers/TurnManager.kt | 2 +- core/src/com/unciv/logic/map/mapgenerator/MapGenerator.kt | 4 ++-- core/src/com/unciv/logic/map/mapunit/MapUnit.kt | 2 +- 4 files changed, 5 insertions(+), 6 deletions(-) diff --git a/core/src/com/unciv/logic/civilization/managers/ThreatManager.kt b/core/src/com/unciv/logic/civilization/managers/ThreatManager.kt index 3ac0fbcd1b..9e2eb93ea2 100644 --- a/core/src/com/unciv/logic/civilization/managers/ThreatManager.kt +++ b/core/src/com/unciv/logic/civilization/managers/ThreatManager.kt @@ -45,7 +45,7 @@ class ThreatManager(val civInfo: Civilization) { else enemyTile.second.coerceAtMost(maxDist) } else { // This tile is no longer valid - tilesWithEnemies.removeFirst() + tilesWithEnemies.removeAt(0) } } @@ -184,4 +184,3 @@ class ThreatManager(val civInfo: Civilization) { distanceToClosestEnemyTiles.clear() } } - diff --git a/core/src/com/unciv/logic/civilization/managers/TurnManager.kt b/core/src/com/unciv/logic/civilization/managers/TurnManager.kt index dd2ec59a8e..f478943fca 100644 --- a/core/src/com/unciv/logic/civilization/managers/TurnManager.kt +++ b/core/src/com/unciv/logic/civilization/managers/TurnManager.kt @@ -242,7 +242,7 @@ class TurnManager(val civInfo: Civilization) { notificationsThisTurn.notifications.addAll(civInfo.notifications) while (notificationsLog.size >= UncivGame.Current.settings.notificationsLogMaxTurns) { - notificationsLog.removeFirst() + notificationsLog.removeAt(0) } if (notificationsThisTurn.notifications.isNotEmpty()) diff --git a/core/src/com/unciv/logic/map/mapgenerator/MapGenerator.kt b/core/src/com/unciv/logic/map/mapgenerator/MapGenerator.kt index 8734854658..9cd1939440 100644 --- a/core/src/com/unciv/logic/map/mapgenerator/MapGenerator.kt +++ b/core/src/com/unciv/logic/map/mapgenerator/MapGenerator.kt @@ -317,13 +317,13 @@ class MapGenerator(val ruleset: Ruleset, private val coroutineScope: CoroutineSc val maxLakeSize = ruleset.modOptions.constants.maxLakeSize while (waterTiles.isNotEmpty()) { - val initialWaterTile = waterTiles.removeFirst() + val initialWaterTile = waterTiles.removeAt(0) tilesInArea += initialWaterTile tilesToCheck += initialWaterTile // Floodfill to cluster water tiles while (tilesToCheck.isNotEmpty()) { - val tileWeAreChecking = tilesToCheck.removeFirst() + val tileWeAreChecking = tilesToCheck.removeAt(0) for (vector in tileWeAreChecking.neighbors){ if (tilesInArea.contains(vector)) continue if (!waterTiles.contains(vector)) continue diff --git a/core/src/com/unciv/logic/map/mapunit/MapUnit.kt b/core/src/com/unciv/logic/map/mapunit/MapUnit.kt index ebca6caaaa..4a3421f589 100644 --- a/core/src/com/unciv/logic/map/mapunit/MapUnit.kt +++ b/core/src/com/unciv/logic/map/mapunit/MapUnit.kt @@ -1039,7 +1039,7 @@ class MapUnit : IsPartOfGameInfoSerialization { // When in the unit's turn— I.E. For a player unit— The last two entries will be from .endTurn() followed by from .startTurn(), so the segment from .movementMemories will have zero length. Instead, what gets seen will be the segment from the end of .movementMemories to the unit's current position. // When not in the unit's turn— I.E. For a foreign unit— The segment from the end of .movementMemories to the unit's current position will have zero length, while the last two entries here will be from .startTurn() followed by .endTurn(), so the segment here will be what gets shown. // The exception is when a unit changes position when not in its turn, such as by melee withdrawal or foreign territory expulsion. Then the segment here and the segment from the end of here to the current position can both be shown. - movementMemories.removeFirst() + movementMemories.removeAt(0) } }