Handling for multiplayer download errors (#5958)

This commit is contained in:
Yair Morgenstern 2022-01-14 10:09:10 +02:00 committed by GitHub
parent 4cce74253d
commit 826b8f4826
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -193,20 +193,20 @@ class MultiplayerScreen(previousScreen: BaseScreen) : PickerScreen() {
loadingGamePopup.add("Loading latest game state...".tr())
loadingGamePopup.open()
// For whatever reason, the only way to show the popup before the ANRs started was to
// call the loadGame explicitly with a runnable on the main thread.
// Maybe this adds just enough lag for the popup to show up
postCrashHandlingRunnable {
crashHandlingThread(name = "JoinMultiplayerGame") {
try {
game.loadGame(OnlineMultiplayer().tryDownloadGame((multiplayerGames[selectedGameFile]!!.gameId)))
val gameId = multiplayerGames[selectedGameFile]!!.gameId
val gameInfo = OnlineMultiplayer().tryDownloadGame(gameId)
postCrashHandlingRunnable { game.loadGame(gameInfo) }
} catch (ex: Exception) {
loadingGamePopup.close()
val errorPopup = Popup(this)
errorPopup.addGoodSizedLabel("Could not download game!")
errorPopup.row()
errorPopup.addCloseButton()
errorPopup.open()
postCrashHandlingRunnable {
loadingGamePopup.close()
val errorPopup = Popup(this)
errorPopup.addGoodSizedLabel("Could not download game!")
errorPopup.row()
errorPopup.addCloseButton()
errorPopup.open()
}
}
}
}