diff --git a/core/src/com/unciv/logic/map/tile/Tile.kt b/core/src/com/unciv/logic/map/tile/Tile.kt index 422d8d28d3..3584b592b5 100644 --- a/core/src/com/unciv/logic/map/tile/Tile.kt +++ b/core/src/com/unciv/logic/map/tile/Tile.kt @@ -826,8 +826,10 @@ class Tile : IsPartOfGameInfoSerialization, Json.Serializable { setTerrainFeatures(ArrayList(terrainFeatures).apply { add(terrainFeature) }) } - fun removeTerrainFeature(terrainFeature: String) = - setTerrainFeatures(ArrayList(terrainFeatures).apply { remove(terrainFeature) }) + fun removeTerrainFeature(terrainFeature: String) { + if (terrainFeature in terrainFeatures) + setTerrainFeatures(ArrayList(terrainFeatures).apply { remove(terrainFeature) }) + } fun removeTerrainFeatures() = setTerrainFeatures(listOf()) diff --git a/core/src/com/unciv/ui/components/input/ActivationActionMap.kt b/core/src/com/unciv/ui/components/input/ActivationActionMap.kt index 309187a271..41848f220d 100644 --- a/core/src/com/unciv/ui/components/input/ActivationActionMap.kt +++ b/core/src/com/unciv/ui/components/input/ActivationActionMap.kt @@ -3,11 +3,12 @@ package com.unciv.ui.components.input import com.unciv.models.UncivSound import com.unciv.ui.audio.SoundPlayer import com.unciv.utils.Concurrency +import java.util.EnumMap typealias ActivationAction = () -> Unit // The delegation inheritance is only done to reduce the signature and limit clients to *our* add functions -internal class ActivationActionMap : MutableMap by LinkedHashMap() { +internal class ActivationActionMap : MutableMap by EnumMap(ActivationTypes::class.java) { // todo Old listener said "happens if there's a double (or more) click function but no single click" - // means when we register a single-click but the listener *only* reports a double, the registered single-click action is invoked. diff --git a/core/src/com/unciv/ui/components/tilegroups/TileGroupMap.kt b/core/src/com/unciv/ui/components/tilegroups/TileGroupMap.kt index 90c4aef207..8fef2ca469 100644 --- a/core/src/com/unciv/ui/components/tilegroups/TileGroupMap.kt +++ b/core/src/com/unciv/ui/components/tilegroups/TileGroupMap.kt @@ -102,14 +102,16 @@ class TileGroupMap( drawTopX = topX - bottomX drawBottomX = bottomX - bottomX - val baseLayers = ArrayList() - val featureLayers = ArrayList() - val borderLayers = ArrayList() - val miscLayers = ArrayList() - val pixelUnitLayers = ArrayList() - val circleFogCrosshairLayers = ArrayList() - val unitLayers = ArrayList() - val cityButtonLayers = ArrayList() + val numberOfTilegroups = tileGroups.count() + + val baseLayers = ArrayList(numberOfTilegroups) + val featureLayers = ArrayList(numberOfTilegroups) + val borderLayers = ArrayList(numberOfTilegroups) + val miscLayers = ArrayList(numberOfTilegroups) + val pixelUnitLayers = ArrayList(numberOfTilegroups) + val circleFogCrosshairLayers = ArrayList(numberOfTilegroups) + val unitLayers = ArrayList(numberOfTilegroups) + val cityButtonLayers = ArrayList(numberOfTilegroups) // Apparently the sortedByDescending is kinda memory-intensive because it needs to sort ALL the tiles // So instead we group by and then sort on the groups