mirror of
https://github.com/yairm210/Unciv.git
synced 2025-07-21 13:18:56 +07:00
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:
@ -21,8 +21,8 @@ android {
|
|||||||
applicationId "com.unciv.app"
|
applicationId "com.unciv.app"
|
||||||
minSdkVersion 14
|
minSdkVersion 14
|
||||||
targetSdkVersion 29
|
targetSdkVersion 29
|
||||||
versionCode 338
|
versionCode 339
|
||||||
versionName "3.3.6"
|
versionName "3.3.7"
|
||||||
|
|
||||||
archivesBaseName = "Unciv"
|
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
|
// this can take a long time, because of the unit-to-tile calculation needed, so we put it in a different thread
|
||||||
thread {
|
thread {
|
||||||
// these are the heavy parts, finding where we want to go
|
// these are the heavy parts, finding where we want to go
|
||||||
if (!selectedUnit.movement.canReach(targetTile)) return@thread // can't move here
|
// Since this runs in a different thread, even if we check movement.canReach()
|
||||||
val tileToMoveTo = selectedUnit.movement.getTileToMoveToThisTurn(targetTile)
|
// 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 {
|
Gdx.app.postRunnable {
|
||||||
try {
|
try {
|
||||||
|
Reference in New Issue
Block a user