Hotfix: Do not reset the screen to the capital in the multiplayer game (#2502)

This commit is contained in:
Jack Rainy
2020-04-23 22:46:07 +03:00
committed by GitHub
parent 6c5eed4dd9
commit 813ba5b83c

View File

@ -129,10 +129,7 @@ class WorldScreen(val viewingCiv:CivilizationInfo) : CameraStageBaseScreen() {
if(gameInfo.gameParameters.isOnlineMultiplayer && !isPlayersTurn) {
// restart the timer
if (multiPlayerRefresher != null) {
multiPlayerRefresher?.cancel()
multiPlayerRefresher?.purge()
}
stopMultiPlayerRefresher()
// isDaemon = true, in order to not block the app closing
multiPlayerRefresher = Timer("multiPlayerRefresh", true).apply {
scheduleAtFixedRate(object : TimerTask() {
@ -154,6 +151,13 @@ class WorldScreen(val viewingCiv:CivilizationInfo) : CameraStageBaseScreen() {
shouldUpdate = true
}
private fun stopMultiPlayerRefresher() {
if (multiPlayerRefresher != null) {
multiPlayerRefresher?.cancel()
multiPlayerRefresher?.purge()
}
}
private fun cleanupKeyDispatcher() {
val delKeys = keyPressDispatcher.keys.filter { it!=' ' && it!='n' }
delKeys.forEach { keyPressDispatcher.remove(it) }
@ -232,7 +236,10 @@ class WorldScreen(val viewingCiv:CivilizationInfo) : CameraStageBaseScreen() {
}
latestGame.isUpToDate=true
// Since we're making a screen this needs to run from the main thread which has a GL context
Gdx.app.postRunnable { game.loadGame(latestGame) }
Gdx.app.postRunnable {
stopMultiPlayerRefresher()
game.loadGame(latestGame)
}
} catch (ex: Exception) {
loadingGamePopup.close()