Fixed Multiplayer bugs (#3781)

* Removed save feature from TurnChecker

* Hopefully fixed not correctly updating multiplayer games?

* Fixed "refresh list" not updating the savegame correctly

* Fixed game update when upload fails

* Revert "Fixed game update when upload fails"

This reverts commit cc9f1cf589.
This commit is contained in:
GGGuenni
2021-04-13 21:57:39 +02:00
committed by GitHub
parent 00ec000d50
commit 3efbbc716e
3 changed files with 13 additions and 8 deletions

View File

@ -242,7 +242,13 @@ class MultiplayerTurnCheckWorker(appContext: Context, workerParams: WorkerParame
val currentTurnPlayer = game.getCivilization(game.currentPlayer)
//Save game so MultiplayerScreen gets updated
GameSaver.saveGame(game, gameNames[arrayIndex], true)
/*
I received multiple reports regarding broken save games.
All of them where missing a few thousand chars at the end of the save game.
I assume this happened because the TurnCheckerWorker gets canceled by the AndroidLauncher
while saves are getting saved right here.
*/
//GameSaver.saveGame(game, gameNames[arrayIndex], true)
if (currentTurnPlayer.playerId == inputData.getString(USER_ID)!!) {
foundGame = true

View File

@ -295,15 +295,16 @@ class MultiplayerScreen(previousScreen: CameraStageBaseScreen) : PickerScreen()
//One thread for all downloads
thread(name = "multiplayerGameDownload") {
for (entry in multiplayerGames) {
for ((fileHandle, gameInfo) in multiplayerGames) {
try {
val game = OnlineMultiplayer().tryDownloadGame(entry.value.gameId)
GameSaver.saveGame(game, entry.key.name(), true)
val game = OnlineMultiplayer().tryDownloadGame(gameInfo.gameId)
GameSaver.saveGame(game, fileHandle.name(), true)
multiplayerGames[fileHandle] = game
} catch (ex: Exception) {
//skipping one is not fatal
//Trying to use as many prev. used strings as possible
Gdx.app.postRunnable {
ToastPopup("Could not download game!" + " ${entry.key.name()}", this)
ToastPopup("Could not download game!" + " ${fileHandle.name()}", this)
}
continue
}

View File

@ -242,10 +242,8 @@ class WorldScreen(val gameInfo: GameInfo, val viewingCiv:CivilizationInfo) : Cam
val latestGame = OnlineMultiplayer().tryDownloadGame(gameInfo.gameId)
// if we find it still isn't player's turn...nothing changed
if (gameInfo.currentPlayer == latestGame.currentPlayer) {
if (viewingCiv.civName != latestGame.currentPlayer) {
Gdx.app.postRunnable { loadingGamePopup.close() }
// edge case - if there's only one player in a multiplayer game, we still check online, but it could be that we were correct and it is our turn
isPlayersTurn = latestGame.currentPlayer == viewingCiv.civName
shouldUpdate = true
return
} else { //else we found it is the player's turn again, turn off polling and load turn