From 91c1e0ae6dbf3865c318cf337b8c5c9514626bfc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=A4in=C3=B6=20M=C3=A4kel=C3=A4?= Date: Tue, 5 May 2020 20:15:13 +0300 Subject: [PATCH] Fix the missing overlays caused by commit 0ffb038129b14ec696373bfc188b796ff1aefe93 (#2586) --- core/src/com/unciv/ui/worldscreen/WorldMapHolder.kt | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/core/src/com/unciv/ui/worldscreen/WorldMapHolder.kt b/core/src/com/unciv/ui/worldscreen/WorldMapHolder.kt index 476d7b0fde..be5b5d7496 100644 --- a/core/src/com/unciv/ui/worldscreen/WorldMapHolder.kt +++ b/core/src/com/unciv/ui/worldscreen/WorldMapHolder.kt @@ -94,8 +94,10 @@ class WorldMapHolder(internal val worldScreen: WorldScreen, internal val tileMap private fun addTileOverlaysWithUnitMovement(selectedUnit: MapUnit, tileInfo: TileInfo) { // some code is copied from canReach not to call getShortestPath on the main thread before calling it on this thread - if (selectedUnit.type.isAirUnit() && selectedUnit.currentTile.aerialDistanceTo(tileInfo) > selectedUnit.getRange()*2) + if (selectedUnit.type.isAirUnit() && selectedUnit.currentTile.aerialDistanceTo(tileInfo) > selectedUnit.getRange()*2) { + addTileOverlays(tileInfo) return + } thread(name="TurnsToGetThere") { /** LibGdx sometimes has these weird errors when you try to edit the UI layout from 2 separate threads. * And so, all UI editing will be done on the main thread. @@ -104,8 +106,6 @@ class WorldMapHolder(internal val worldScreen: WorldScreen, internal val tileMap */ val turnsToGetThere = if(selectedUnit.type.isAirUnit()) 1 else selectedUnit.movement.getShortestPath(tileInfo).size // this is what takes the most time, tbh - if (turnsToGetThere == 0) // there is no path to tileInfo - return@thread Gdx.app.postRunnable { if(UncivGame.Current.settings.singleTapMove && turnsToGetThere==1) { @@ -113,8 +113,9 @@ class WorldMapHolder(internal val worldScreen: WorldScreen, internal val tileMap selectedUnit.movement.headTowards(tileInfo) worldScreen.bottomUnitTable.selectedUnit = selectedUnit // keep moved unit selected } else { - // add "move to" button - val moveHereButtonDto = MoveHereButtonDto(selectedUnit, tileInfo, turnsToGetThere) + // add "move to" button if there is a path to tileInfo + val moveHereButtonDto = if (turnsToGetThere != 0) MoveHereButtonDto(selectedUnit, tileInfo, turnsToGetThere) + else null addTileOverlays(tileInfo, moveHereButtonDto) } worldScreen.shouldUpdate = true