From 038e1cadbfed9f7eb85e85ed7a0e1161d7ebcf09 Mon Sep 17 00:00:00 2001 From: Jack Rainy Date: Thu, 16 Apr 2020 16:15:47 +0300 Subject: [PATCH] Application crash after the defeat (#2427) --- core/src/com/unciv/ui/worldscreen/WorldMapHolder.kt | 2 +- core/src/com/unciv/ui/worldscreen/WorldScreen.kt | 2 +- core/src/com/unciv/ui/worldscreen/bottombar/TileInfoTable.kt | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/core/src/com/unciv/ui/worldscreen/WorldMapHolder.kt b/core/src/com/unciv/ui/worldscreen/WorldMapHolder.kt index 989ca8f44e..2bcca6c364 100644 --- a/core/src/com/unciv/ui/worldscreen/WorldMapHolder.kt +++ b/core/src/com/unciv/ui/worldscreen/WorldMapHolder.kt @@ -307,7 +307,7 @@ class WorldMapHolder(internal val worldScreen: WorldScreen, internal val tileMap fun setCenterPosition(vector: Vector2, immediately: Boolean = false, selectUnit: Boolean = true) { - val tileGroup = tileGroups.values.first { it.tileInfo.position == vector } + val tileGroup = tileGroups.values.firstOrNull { it.tileInfo.position == vector } ?: return selectedTile = tileGroup.tileInfo if(selectUnit) worldScreen.bottomUnitTable.tileSelected(selectedTile!!) diff --git a/core/src/com/unciv/ui/worldscreen/WorldScreen.kt b/core/src/com/unciv/ui/worldscreen/WorldScreen.kt index 83712a239c..78e3c6d93a 100644 --- a/core/src/com/unciv/ui/worldscreen/WorldScreen.kt +++ b/core/src/com/unciv/ui/worldscreen/WorldScreen.kt @@ -244,7 +244,7 @@ class WorldScreen(val viewingCiv:CivilizationInfo) : CameraStageBaseScreen() { displayTutorialsOnUpdate() bottomUnitTable.update() - bottomTileInfoTable.updateTileTable(mapHolder.selectedTile!!) + bottomTileInfoTable.updateTileTable(mapHolder.selectedTile) bottomTileInfoTable.x = stage.width - bottomTileInfoTable.width bottomTileInfoTable.y = if (UncivGame.Current.settings.showMinimap) minimapWrapper.height else 0f battleTable.update() diff --git a/core/src/com/unciv/ui/worldscreen/bottombar/TileInfoTable.kt b/core/src/com/unciv/ui/worldscreen/bottombar/TileInfoTable.kt index 9ef73b00a2..f28fa5da81 100644 --- a/core/src/com/unciv/ui/worldscreen/bottombar/TileInfoTable.kt +++ b/core/src/com/unciv/ui/worldscreen/bottombar/TileInfoTable.kt @@ -15,10 +15,10 @@ class TileInfoTable(private val viewingCiv :CivilizationInfo) : Table(CameraStag background = ImageGetter.getBackground(ImageGetter.getBlue().lerp(Color.BLACK, 0.5f)) } - internal fun updateTileTable(tile: TileInfo) { + internal fun updateTileTable(tile: TileInfo?) { clearChildren() - if (UncivGame.Current.viewEntireMapForDebug || viewingCiv.exploredTiles.contains(tile.position)) { + if ((tile != null) && (UncivGame.Current.viewEntireMapForDebug || viewingCiv.exploredTiles.contains(tile.position))) { add(getStatsTable(tile)) add(tile.toString(viewingCiv).toLabel()).colspan(2).pad(10f) }