mirror of
https://github.com/yairm210/Unciv.git
synced 2025-01-05 21:11:35 +07:00
Solved concurrent modification problems from TechManager.researchedTechnologies and civInfo.exploredTiles
This commit is contained in:
parent
6096bde9cd
commit
ea68a70823
File diff suppressed because it is too large
Load Diff
Binary file not shown.
Before Width: | Height: | Size: 790 KiB After Width: | Height: | Size: 792 KiB |
@ -71,7 +71,7 @@ class CivilizationInfo {
|
||||
toReturn.scienceVictory = scienceVictory.clone()
|
||||
toReturn.diplomacy.putAll(diplomacy.values.map { it.clone() }.associateBy { it.otherCivName })
|
||||
toReturn.cities = cities.map { it.clone() }
|
||||
toReturn.exploredTiles.addAll(exploredTiles.toList()) // we actually fot a concurrent modification exception here, the toList should solve that
|
||||
toReturn.exploredTiles.addAll(exploredTiles)
|
||||
return toReturn
|
||||
}
|
||||
|
||||
@ -222,13 +222,17 @@ class CivilizationInfo {
|
||||
|
||||
|
||||
fun updateViewableTiles() {
|
||||
viewableTiles.clear()
|
||||
viewableTiles.addAll(cities.flatMap { it.getTiles() }.flatMap { it.neighbors }) // tiles adjacent to city tiles
|
||||
viewableTiles.addAll(getCivUnits().flatMap { it.getViewableTiles()})
|
||||
val newViewableTiles = HashSet<TileInfo>()
|
||||
newViewableTiles.addAll(cities.flatMap { it.getTiles() }.flatMap { it.neighbors }) // tiles adjacent to city tiles
|
||||
newViewableTiles.addAll(getCivUnits().flatMap { it.getViewableTiles()})
|
||||
viewableTiles = newViewableTiles // to avoid concurrent modification problems
|
||||
|
||||
// updating the viewable tiles also affects the explored tiles, obvs
|
||||
viewableTiles.asSequence().map { it.position }
|
||||
.filterNot { exploredTiles.contains(it) }.toCollection(exploredTiles)
|
||||
|
||||
val newExploredTiles = HashSet<Vector2>(exploredTiles)
|
||||
newExploredTiles.addAll(newViewableTiles.asSequence().map { it.position }
|
||||
.filterNot { exploredTiles.contains(it) })
|
||||
exploredTiles = newExploredTiles // ditto
|
||||
|
||||
|
||||
val viewedCivs = HashSet<CivilizationInfo>()
|
||||
|
@ -10,7 +10,7 @@ import java.util.*
|
||||
|
||||
class TechManager {
|
||||
@Transient lateinit var civInfo: CivilizationInfo
|
||||
@Transient val researchedTechnologies=ArrayList<Technology>()
|
||||
@Transient var researchedTechnologies=ArrayList<Technology>()
|
||||
|
||||
var freeTechs = 0
|
||||
var techsResearched = HashSet<String>()
|
||||
@ -75,7 +75,12 @@ class TechManager {
|
||||
if(currentTechnology!="Future Tech")
|
||||
techsToResearch.remove(currentTechnology)
|
||||
techsResearched.add(currentTechnology)
|
||||
researchedTechnologies.add(GameBasics.Technologies[currentTechnology]!!)
|
||||
|
||||
// this is to avoid concurrent modification problems
|
||||
val newResearchedTechnologies = ArrayList(researchedTechnologies)
|
||||
newResearchedTechnologies.add(GameBasics.Technologies[currentTechnology]!!)
|
||||
researchedTechnologies = newResearchedTechnologies
|
||||
|
||||
civInfo.addNotification("Research of [$currentTechnology] has completed!", null, Color.BLUE)
|
||||
|
||||
val currentEra = civInfo.getEra()
|
||||
|
Loading…
Reference in New Issue
Block a user