Band-aided a bug where players in multiplayer games were waiting for themselves. (#5768)

(cherry picked from commit 22b3997c28da4eb75c1b633625d5c006b17934d8)
This commit is contained in:
Xander Lenstra 2021-12-07 20:38:45 +01:00 committed by yairm210
parent 0d4da03b7c
commit 099b180a07
2 changed files with 7 additions and 2 deletions

View File

@ -120,7 +120,7 @@ class GameInfo {
} }
/** Get a civ by name /** Get a civ by name
* @throws NoSuchElementException if no civ of than name is in the game (alive or dead)! */ * @throws NoSuchElementException if no civ of that name is in the game (alive or dead)! */
fun getCivilization(civName: String) = civilizations.first { it.civName == civName } fun getCivilization(civName: String) = civilizations.first { it.civName == civName }
fun getCurrentPlayerCivilization() = currentPlayerCiv fun getCurrentPlayerCivilization() = currentPlayerCiv
fun getCivilizationsAsPreviews() = civilizations.map { it.asPreview() }.toMutableList() fun getCivilizationsAsPreviews() = civilizations.map { it.asPreview() }.toMutableList()

View File

@ -335,7 +335,12 @@ class WorldScreen(val gameInfo: GameInfo, val viewingCiv:CivilizationInfo) : Bas
val latestGame = OnlineMultiplayer().tryDownloadGame(gameInfo.gameId) val latestGame = OnlineMultiplayer().tryDownloadGame(gameInfo.gameId)
// if we find the current player didn't change, don't update // if we find the current player didn't change, don't update
if (gameInfo.currentPlayer == latestGame.currentPlayer) { // Additionally, check if we are the current player, and in that case always stop
// This fixes a bug where for some reason players were waiting for themselves.
if (gameInfo.currentPlayer == latestGame.currentPlayer
&& gameInfo.turns == latestGame.turns
&& latestGame.currentPlayer != gameInfo.getPlayerToViewAs().civName
) {
Gdx.app.postRunnable { loadingGamePopup.close() } Gdx.app.postRunnable { loadingGamePopup.close() }
shouldUpdate = true shouldUpdate = true
return return