mirror of
https://github.com/yairm210/Unciv.git
synced 2025-02-11 03:18:18 +07:00
Resolved #4960 - can now play as 2 separate civs with the same userId
This commit is contained in:
parent
23cb4394a7
commit
6db92da52a
@ -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?
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user