From 51b62028a8d1dd7dc46a3571e2c29e6ce7bba3b6 Mon Sep 17 00:00:00 2001 From: Yair Morgenstern Date: Wed, 19 Dec 2018 19:53:53 +0200 Subject: [PATCH] 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! --- android/build.gradle | 4 ++-- .../com/unciv/ui/worldscreen/TileMapHolder.kt | 16 +++++++++------- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/android/build.gradle b/android/build.gradle index 270bc3714d..ce33525e45 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -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 diff --git a/core/src/com/unciv/ui/worldscreen/TileMapHolder.kt b/core/src/com/unciv/ui/worldscreen/TileMapHolder.kt index a087363046..3ed69ca477 100644 --- a/core/src/com/unciv/ui/worldscreen/TileMapHolder.kt +++ b/core/src/com/unciv/ui/worldscreen/TileMapHolder.kt @@ -24,8 +24,7 @@ class TileMapHolder(internal val worldScreen: WorldScreen, internal val tileMap: val tileGroups = HashMap() var moveToOverlay :Actor?=null - val cityButtonOverlays = ArrayList() - + 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)