diff --git a/core/src/com/unciv/logic/map/tile/Tile.kt b/core/src/com/unciv/logic/map/tile/Tile.kt index 6a1d30f2a5..97a8241147 100644 --- a/core/src/com/unciv/logic/map/tile/Tile.kt +++ b/core/src/com/unciv/logic/map/tile/Tile.kt @@ -21,6 +21,8 @@ import com.unciv.models.ruleset.unique.StateForConditionals import com.unciv.models.ruleset.unique.Unique import com.unciv.models.ruleset.unique.UniqueMap import com.unciv.models.ruleset.unique.UniqueType +import com.unciv.ui.components.extensions.withItem +import com.unciv.ui.components.extensions.withoutItem import com.unciv.utils.DebugUtils import kotlin.math.abs import kotlin.math.min @@ -85,6 +87,7 @@ open class Tile : IsPartOfGameInfoSerialization { var terrainFeatures: List = listOf() private set + /** Should be immutable - never be altered in-place, instead replaced */ var exploredBy = HashSet() @Transient @@ -174,7 +177,7 @@ open class Tile : IsPartOfGameInfoSerialization { toReturn.hasBottomRightRiver = hasBottomRightRiver toReturn.hasBottomRiver = hasBottomRiver toReturn.continent = continent - toReturn.exploredBy.addAll(exploredBy) + toReturn.exploredBy = exploredBy toReturn.history = history.clone() return toReturn } @@ -240,7 +243,8 @@ open class Tile : IsPartOfGameInfoSerialization { fun setExplored(player: Civilization, isExplored: Boolean, explorerPosition: Vector2? = null) { if (isExplored) { // Disable the undo button if a new tile has been explored - if (exploredBy.add(player.civName) && GUI.isWorldLoaded()) { + if (!exploredBy.contains(player.civName) && GUI.isWorldLoaded()) { + exploredBy = exploredBy.withItem(player.civName) val worldScreen = GUI.getWorldScreen() worldScreen.preActionGameInfo = worldScreen.gameInfo } @@ -248,7 +252,7 @@ open class Tile : IsPartOfGameInfoSerialization { if (player.playerType == PlayerType.Human) player.exploredRegion.checkTilePosition(position, explorerPosition) } else { - exploredBy.remove(player.civName) + exploredBy = exploredBy.withoutItem(player.civName) } }