Maybe solved a concurrency-related java.lang.IllegalArgumentException from CameraStageBaseScreen.render

It's hard to tell because it only crops extremely randomly in, like, 1 in a 1000 games, and the users just continue on with their lives,
But it's a crash record and we want 0 of those!
This commit is contained in:
Yair Morgenstern 2018-12-19 19:53:53 +02:00
parent a677850084
commit 51b62028a8
2 changed files with 11 additions and 9 deletions

View file

@ -21,8 +21,8 @@ android {
applicationId "com.unciv.game"
minSdkVersion 14
targetSdkVersion 28
versionCode 182
versionName "2.11.0"
versionCode 183
versionName "2.11.1"
}
// Had to add this crap for Travis to build, it wanted to sign the app

View file

@ -24,8 +24,7 @@ class TileMapHolder(internal val worldScreen: WorldScreen, internal val tileMap:
val tileGroups = HashMap<TileInfo, WorldTileGroup>()
var moveToOverlay :Actor?=null
val cityButtonOverlays = ArrayList<Actor>()
var removeMoveToOverlay=false
// Used to transfer data on the "move here" button that should be created, from the side thread to the main thread
class MoveHereButtonDto(val unit: MapUnit, val tileInfo: TileInfo, val turnsToGetThere: Int)
@ -49,6 +48,7 @@ class TileMapHolder(internal val worldScreen: WorldScreen, internal val tileMap:
val groupSize = 50
tileGroup.setPosition(worldScreen.stage.width / 2 + positionalVector.x * 0.8f * groupSize.toFloat(),
worldScreen.stage.height / 2 + positionalVector.y * 0.8f * groupSize.toFloat())
tileGroups[tileInfo] = tileGroup
allTiles.addActor(tileGroup)
topX = Math.max(topX, tileGroup.x + groupSize)
@ -168,8 +168,8 @@ class TileMapHolder(internal val worldScreen: WorldScreen, internal val tileMap:
// we don't update it directly because we're on a different thread; instead, we tell it to update itself
worldScreen.shouldUpdate = true
moveToOverlay?.remove()
moveToOverlay = null
removeMoveToOverlay=true
}
}
@ -182,12 +182,14 @@ class TileMapHolder(internal val worldScreen: WorldScreen, internal val tileMap:
}
internal fun updateTiles(civInfo: CivilizationInfo) {
if(removeMoveToOverlay){
removeMoveToOverlay=false
moveToOverlay?.remove()
}
val playerViewableTilePositions = civInfo.viewableTiles.map { it.position }.toHashSet()
val playerViewableInvisibleUnitsTilePositions = civInfo.viewableInvisibleUnitsTiles.map { it.position }.toHashSet()
cityButtonOverlays.forEach{it.remove()}
cityButtonOverlays.clear()
for (tileGroup in tileGroups.values){
val canSeeTile = UnCivGame.Current.viewEntireMapForDebug
|| playerViewableTilePositions.contains(tileGroup.tileInfo.position)