Fixed switching unit selection bug - #804

This commit is contained in:
Yair Morgenstern 2019-05-26 14:46:45 +03:00
parent a67fc9d55d
commit 9352243eb4
2 changed files with 9 additions and 8 deletions

View File

@ -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

View File

@ -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)