diff --git a/core/src/com/unciv/logic/GameInfo.kt b/core/src/com/unciv/logic/GameInfo.kt index b35c04cffe..cba1378ea6 100644 --- a/core/src/com/unciv/logic/GameInfo.kt +++ b/core/src/com/unciv/logic/GameInfo.kt @@ -82,7 +82,17 @@ class GameInfo { fun getPlayerToViewAs(): CivilizationInfo { if (!gameParameters.isOnlineMultiplayer) return currentPlayerCiv // non-online, play as human player val userId = UncivGame.Current.settings.userId - if (civilizations.any { it.playerId == userId }) return civilizations.first { it.playerId == userId } + + // Iterating on all civs, starting from the the current player, gives us the one that will have the next turn + // This allows multiple civs from the same UserID + if (civilizations.any { it.playerId == userId }) { + var civIndex = civilizations.map { it.civName }.indexOf(currentPlayer) + while (true) { + val civToCheck = civilizations[civIndex % civilizations.size] + if (civToCheck.playerId == userId) return civToCheck + civIndex++ + } + } else return getBarbarianCivilization()// you aren't anyone. How did you even get this game? Can you spectate? } diff --git a/core/src/com/unciv/ui/worldscreen/WorldScreen.kt b/core/src/com/unciv/ui/worldscreen/WorldScreen.kt index 488b6e56bb..7f37f94c51 100644 --- a/core/src/com/unciv/ui/worldscreen/WorldScreen.kt +++ b/core/src/com/unciv/ui/worldscreen/WorldScreen.kt @@ -332,7 +332,7 @@ 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 (viewingCiv.civName != latestGame.currentPlayer) { + if (viewingCiv.playerId != latestGame.getCurrentPlayerCivilization().playerId) { Gdx.app.postRunnable { loadingGamePopup.close() } shouldUpdate = true return @@ -574,11 +574,15 @@ class WorldScreen(val gameInfo: GameInfo, val viewingCiv:CivilizationInfo) : Cam game.gameInfo = gameInfo val newWorldScreen = WorldScreen(gameInfo, gameInfo.getPlayerToViewAs()) - newWorldScreen.mapHolder.scrollX = mapHolder.scrollX - newWorldScreen.mapHolder.scrollY = mapHolder.scrollY - newWorldScreen.mapHolder.scaleX = mapHolder.scaleX - newWorldScreen.mapHolder.scaleY = mapHolder.scaleY - newWorldScreen.mapHolder.updateVisualScroll() + + // This is not the case if you have a multiplayer game where you play as 2 civs + if (newWorldScreen.viewingCiv.civName == viewingCiv.civName) { + newWorldScreen.mapHolder.scrollX = mapHolder.scrollX + newWorldScreen.mapHolder.scrollY = mapHolder.scrollY + newWorldScreen.mapHolder.scaleX = mapHolder.scaleX + newWorldScreen.mapHolder.scaleY = mapHolder.scaleY + newWorldScreen.mapHolder.updateVisualScroll() + } newWorldScreen.selectedCiv = gameInfo.getCivilization(selectedCiv.civName) newWorldScreen.fogOfWar = fogOfWar