Silly multithreading movement problems should no longer crash the game for the user - they're rare, but when you have 50,000 users they pop up every day.
This commit is contained in:
parent
32ac709a02
commit
caf98b8470
2 changed files with 8 additions and 4 deletions
|
@ -21,8 +21,8 @@ android {
|
|||
applicationId "com.unciv.app"
|
||||
minSdkVersion 14
|
||||
targetSdkVersion 29
|
||||
versionCode 338
|
||||
versionName "3.3.6"
|
||||
versionCode 339
|
||||
versionName "3.3.7"
|
||||
|
||||
archivesBaseName = "Unciv"
|
||||
}
|
||||
|
|
|
@ -59,8 +59,12 @@ class UnitContextMenu(val tileMapHolder: TileMapHolder, val selectedUnit: MapUni
|
|||
// this can take a long time, because of the unit-to-tile calculation needed, so we put it in a different thread
|
||||
thread {
|
||||
// these are the heavy parts, finding where we want to go
|
||||
if (!selectedUnit.movement.canReach(targetTile)) return@thread // can't move here
|
||||
val tileToMoveTo = selectedUnit.movement.getTileToMoveToThisTurn(targetTile)
|
||||
// Since this runs in a different thread, even if we check movement.canReach()
|
||||
// then it might change until we get to the getTileToMoveTo, so we just try/catch it
|
||||
val tileToMoveTo:TileInfo
|
||||
try{
|
||||
tileToMoveTo = selectedUnit.movement.getTileToMoveToThisTurn(targetTile)
|
||||
}catch (ex:Exception){ return@thread } // can't move here
|
||||
|
||||
Gdx.app.postRunnable {
|
||||
try {
|
||||
|
|
Loading…
Reference in a new issue