mirror of
https://github.com/yairm210/Unciv.git
synced 2025-08-04 09:09:21 +07:00
perf: Only attempt to get game ID for multiplayer game if current game is actually multiplayer
This commit is contained in:
@ -67,11 +67,12 @@ class OnlineMultiplayer {
|
||||
while (true) {
|
||||
delay(500)
|
||||
if (!currentCoroutineContext().isActive) return@flow
|
||||
val currentGame = getCurrentGame()
|
||||
val multiplayerSettings: GameSettings.GameSettingsMultiplayer
|
||||
try { // Fails in unknown cases - cannot debug :/ This is just so it doesn't appear in GP analytics
|
||||
multiplayerSettings = UncivGame.Current.settings.multiplayer
|
||||
} catch (ex:Exception){ continue }
|
||||
|
||||
val currentGame = getCurrentGame()
|
||||
val preview = currentGame?.preview
|
||||
if (currentGame != null && (usesCustomServer() || preview == null || !preview.isUsersTurn())) {
|
||||
throttle(lastCurGameRefresh, multiplayerSettings.currentGameRefreshDelay, {}) { currentGame.requestUpdate() }
|
||||
@ -85,7 +86,7 @@ class OnlineMultiplayer {
|
||||
|
||||
private fun getCurrentGame(): OnlineMultiplayerGame? {
|
||||
val gameInfo = UncivGame.Current.gameInfo
|
||||
return if (gameInfo != null) {
|
||||
return if (gameInfo != null && gameInfo.gameParameters.isOnlineMultiplayer) {
|
||||
getGameByGameId(gameInfo.gameId)
|
||||
} else null
|
||||
}
|
||||
|
Reference in New Issue
Block a user