mirror of
https://github.com/yairm210/Unciv.git
synced 2025-01-19 16:57:38 +07:00
Resolved #9332 - Solved rare concurrency bug for explored tiles
This commit is contained in:
parent
f8b4b202e7
commit
02e6785969
@ -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<String> = listOf()
|
||||
private set
|
||||
|
||||
/** Should be immutable - never be altered in-place, instead replaced */
|
||||
var exploredBy = HashSet<String>()
|
||||
|
||||
@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)
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user