mirror of
https://github.com/yairm210/Unciv.git
synced 2025-07-13 01:08:25 +07:00
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:
@ -242,7 +242,13 @@ class MultiplayerTurnCheckWorker(appContext: Context, workerParams: WorkerParame
|
|||||||
val currentTurnPlayer = game.getCivilization(game.currentPlayer)
|
val currentTurnPlayer = game.getCivilization(game.currentPlayer)
|
||||||
|
|
||||||
//Save game so MultiplayerScreen gets updated
|
//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)!!) {
|
if (currentTurnPlayer.playerId == inputData.getString(USER_ID)!!) {
|
||||||
foundGame = true
|
foundGame = true
|
||||||
|
@ -295,15 +295,16 @@ class MultiplayerScreen(previousScreen: CameraStageBaseScreen) : PickerScreen()
|
|||||||
|
|
||||||
//One thread for all downloads
|
//One thread for all downloads
|
||||||
thread(name = "multiplayerGameDownload") {
|
thread(name = "multiplayerGameDownload") {
|
||||||
for (entry in multiplayerGames) {
|
for ((fileHandle, gameInfo) in multiplayerGames) {
|
||||||
try {
|
try {
|
||||||
val game = OnlineMultiplayer().tryDownloadGame(entry.value.gameId)
|
val game = OnlineMultiplayer().tryDownloadGame(gameInfo.gameId)
|
||||||
GameSaver.saveGame(game, entry.key.name(), true)
|
GameSaver.saveGame(game, fileHandle.name(), true)
|
||||||
|
multiplayerGames[fileHandle] = game
|
||||||
} catch (ex: Exception) {
|
} catch (ex: Exception) {
|
||||||
//skipping one is not fatal
|
//skipping one is not fatal
|
||||||
//Trying to use as many prev. used strings as possible
|
//Trying to use as many prev. used strings as possible
|
||||||
Gdx.app.postRunnable {
|
Gdx.app.postRunnable {
|
||||||
ToastPopup("Could not download game!" + " ${entry.key.name()}", this)
|
ToastPopup("Could not download game!" + " ${fileHandle.name()}", this)
|
||||||
}
|
}
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
@ -242,10 +242,8 @@ class WorldScreen(val gameInfo: GameInfo, val viewingCiv:CivilizationInfo) : Cam
|
|||||||
val latestGame = OnlineMultiplayer().tryDownloadGame(gameInfo.gameId)
|
val latestGame = OnlineMultiplayer().tryDownloadGame(gameInfo.gameId)
|
||||||
|
|
||||||
// if we find it still isn't player's turn...nothing changed
|
// 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() }
|
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
|
shouldUpdate = true
|
||||||
return
|
return
|
||||||
} else { //else we found it is the player's turn again, turn off polling and load turn
|
} else { //else we found it is the player's turn again, turn off polling and load turn
|
||||||
|
Reference in New Issue
Block a user