From 9352243eb40ad93193083e2717c60bfc9c7de9da Mon Sep 17 00:00:00 2001 From: Yair Morgenstern Date: Sun, 26 May 2019 14:46:45 +0300 Subject: [PATCH] Fixed switching unit selection bug - #804 --- android/build.gradle | 4 ++-- core/src/com/unciv/ui/worldscreen/TileMapHolder.kt | 13 +++++++------ 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/android/build.gradle b/android/build.gradle index 3cf0f1cb61..ca10bbba81 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -21,8 +21,8 @@ android { applicationId "com.unciv.app" minSdkVersion 14 targetSdkVersion 28 - versionCode 246 - versionName "2.16.9" + versionCode 247 + versionName "2.16.10" } // 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 b9a07fb587..2544aed182 100644 --- a/core/src/com/unciv/ui/worldscreen/TileMapHolder.kt +++ b/core/src/com/unciv/ui/worldscreen/TileMapHolder.kt @@ -89,17 +89,17 @@ class TileMapHolder(internal val worldScreen: WorldScreen, internal val tileMap: unitActionOverlay?.remove() selectedTile = tileInfo - val selectedUnit = worldScreen.bottomBar.unitTable.selectedUnit + val previousSelectedUnit = worldScreen.bottomBar.unitTable.selectedUnit worldScreen.bottomBar.unitTable.tileSelected(tileInfo) + val newSelectedUnit = worldScreen.bottomBar.unitTable.selectedUnit - if (selectedUnit != null && selectedUnit.getTile() != tileInfo - && selectedUnit.canMoveTo(tileInfo) && selectedUnit.movementAlgs().canReach(tileInfo)) { + if (previousSelectedUnit != null && previousSelectedUnit.getTile() != tileInfo + && previousSelectedUnit.canMoveTo(tileInfo) && previousSelectedUnit.movementAlgs().canReach(tileInfo)) { // this can take a long time, because of the unit-to-tile calculation needed, so we put it in a different thread - moveHere(selectedUnit, tileInfo) - worldScreen.bottomBar.unitTable.selectedUnit = selectedUnit // keep moved unit selected + moveHere(previousSelectedUnit, tileInfo) } - if(selectedUnit==null || selectedUnit.type==UnitType.Civilian){ + if(newSelectedUnit==null || newSelectedUnit.type==UnitType.Civilian){ val unitsInTile = selectedTile!!.getUnits() if(unitsInTile.isNotEmpty() && unitsInTile.first().civInfo.isAtWarWith(worldScreen.currentPlayerCiv)){ // try to select the closest city to bombard this guy @@ -127,6 +127,7 @@ class TileMapHolder(internal val worldScreen: WorldScreen, internal val tileMap: if(UnCivGame.Current.settings.singleTapMove && turnsToGetThere==1) { // single turn instant move selectedUnit.movementAlgs().headTowards(tileInfo) + worldScreen.bottomBar.unitTable.selectedUnit = selectedUnit // keep moved unit selected } else { // add "move to" button val moveHereButtonDto = MoveHereButtonDto(selectedUnit, tileInfo, turnsToGetThere)