mirror of
https://github.com/yairm210/Unciv.git
synced 2025-07-10 07:48:31 +07:00
Resolved #9332 - Solved rare concurrency bug for explored tiles
This commit is contained in:
@ -21,6 +21,8 @@ import com.unciv.models.ruleset.unique.StateForConditionals
|
|||||||
import com.unciv.models.ruleset.unique.Unique
|
import com.unciv.models.ruleset.unique.Unique
|
||||||
import com.unciv.models.ruleset.unique.UniqueMap
|
import com.unciv.models.ruleset.unique.UniqueMap
|
||||||
import com.unciv.models.ruleset.unique.UniqueType
|
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 com.unciv.utils.DebugUtils
|
||||||
import kotlin.math.abs
|
import kotlin.math.abs
|
||||||
import kotlin.math.min
|
import kotlin.math.min
|
||||||
@ -85,6 +87,7 @@ open class Tile : IsPartOfGameInfoSerialization {
|
|||||||
var terrainFeatures: List<String> = listOf()
|
var terrainFeatures: List<String> = listOf()
|
||||||
private set
|
private set
|
||||||
|
|
||||||
|
/** Should be immutable - never be altered in-place, instead replaced */
|
||||||
var exploredBy = HashSet<String>()
|
var exploredBy = HashSet<String>()
|
||||||
|
|
||||||
@Transient
|
@Transient
|
||||||
@ -174,7 +177,7 @@ open class Tile : IsPartOfGameInfoSerialization {
|
|||||||
toReturn.hasBottomRightRiver = hasBottomRightRiver
|
toReturn.hasBottomRightRiver = hasBottomRightRiver
|
||||||
toReturn.hasBottomRiver = hasBottomRiver
|
toReturn.hasBottomRiver = hasBottomRiver
|
||||||
toReturn.continent = continent
|
toReturn.continent = continent
|
||||||
toReturn.exploredBy.addAll(exploredBy)
|
toReturn.exploredBy = exploredBy
|
||||||
toReturn.history = history.clone()
|
toReturn.history = history.clone()
|
||||||
return toReturn
|
return toReturn
|
||||||
}
|
}
|
||||||
@ -240,7 +243,8 @@ open class Tile : IsPartOfGameInfoSerialization {
|
|||||||
fun setExplored(player: Civilization, isExplored: Boolean, explorerPosition: Vector2? = null) {
|
fun setExplored(player: Civilization, isExplored: Boolean, explorerPosition: Vector2? = null) {
|
||||||
if (isExplored) {
|
if (isExplored) {
|
||||||
// Disable the undo button if a new tile has been explored
|
// 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()
|
val worldScreen = GUI.getWorldScreen()
|
||||||
worldScreen.preActionGameInfo = worldScreen.gameInfo
|
worldScreen.preActionGameInfo = worldScreen.gameInfo
|
||||||
}
|
}
|
||||||
@ -248,7 +252,7 @@ open class Tile : IsPartOfGameInfoSerialization {
|
|||||||
if (player.playerType == PlayerType.Human)
|
if (player.playerType == PlayerType.Human)
|
||||||
player.exploredRegion.checkTilePosition(position, explorerPosition)
|
player.exploredRegion.checkTilePosition(position, explorerPosition)
|
||||||
} else {
|
} else {
|
||||||
exploredBy.remove(player.civName)
|
exploredBy = exploredBy.withoutItem(player.civName)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user