mirror of
https://github.com/yairm210/Unciv.git
synced 2025-07-07 00:41:39 +07:00
Loading a new game while nextTurn is running no longer reverts you to that game
This commit is contained in:
@ -636,12 +636,13 @@ class WorldScreen(val gameInfo: GameInfo, val viewingCiv:CivilizationInfo) : Bas
|
|||||||
if (consoleLog)
|
if (consoleLog)
|
||||||
println("\nNext turn starting " + Date().formatDate())
|
println("\nNext turn starting " + Date().formatDate())
|
||||||
val startTime = System.currentTimeMillis()
|
val startTime = System.currentTimeMillis()
|
||||||
val gameInfoClone = gameInfo.clone()
|
val originalGameInfo = gameInfo
|
||||||
|
val gameInfoClone = originalGameInfo.clone()
|
||||||
gameInfoClone.setTransients() // this can get expensive on large games, not the clone itself
|
gameInfoClone.setTransients() // this can get expensive on large games, not the clone itself
|
||||||
|
|
||||||
gameInfoClone.nextTurn()
|
gameInfoClone.nextTurn()
|
||||||
|
|
||||||
if (gameInfo.gameParameters.isOnlineMultiplayer) {
|
if (originalGameInfo.gameParameters.isOnlineMultiplayer) {
|
||||||
try {
|
try {
|
||||||
OnlineMultiplayer().tryUploadGame(gameInfoClone, withPreview = true)
|
OnlineMultiplayer().tryUploadGame(gameInfoClone, withPreview = true)
|
||||||
} catch (ex: Exception) {
|
} catch (ex: Exception) {
|
||||||
@ -657,6 +658,9 @@ class WorldScreen(val gameInfo: GameInfo, val viewingCiv:CivilizationInfo) : Bas
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (game.gameInfo != originalGameInfo) // while this was turning we loaded another game
|
||||||
|
return@crashHandlingThread
|
||||||
|
|
||||||
game.gameInfo = gameInfoClone
|
game.gameInfo = gameInfoClone
|
||||||
if (consoleLog)
|
if (consoleLog)
|
||||||
println("Next turn took ${System.currentTimeMillis()-startTime}ms")
|
println("Next turn took ${System.currentTimeMillis()-startTime}ms")
|
||||||
@ -667,7 +671,6 @@ class WorldScreen(val gameInfo: GameInfo, val viewingCiv:CivilizationInfo) : Bas
|
|||||||
// do this on main thread - it's the only one that has a GL context to create images from
|
// do this on main thread - it's the only one that has a GL context to create images from
|
||||||
postCrashHandlingRunnable {
|
postCrashHandlingRunnable {
|
||||||
|
|
||||||
|
|
||||||
if (gameInfoClone.currentPlayerCiv.civName != viewingCiv.civName
|
if (gameInfoClone.currentPlayerCiv.civName != viewingCiv.civName
|
||||||
&& !gameInfoClone.gameParameters.isOnlineMultiplayer)
|
&& !gameInfoClone.gameParameters.isOnlineMultiplayer)
|
||||||
game.setScreen(PlayerReadyScreen(gameInfoClone, gameInfoClone.getCurrentPlayerCivilization()))
|
game.setScreen(PlayerReadyScreen(gameInfoClone, gameInfoClone.getCurrentPlayerCivilization()))
|
||||||
|
Reference in New Issue
Block a user