From b813e0b38ad91b0f18b61ea94d265c7634cfc14f Mon Sep 17 00:00:00 2001 From: Yair Morgenstern Date: Sun, 16 Jan 2022 18:42:45 +0200 Subject: [PATCH] Fixed assumption that the current game is in the list of games gathered from preview files (#5981) --- android/src/com/unciv/app/MultiplayerTurnCheckWorker.kt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/android/src/com/unciv/app/MultiplayerTurnCheckWorker.kt b/android/src/com/unciv/app/MultiplayerTurnCheckWorker.kt index 7abc9b21b9..0e0b28375a 100644 --- a/android/src/com/unciv/app/MultiplayerTurnCheckWorker.kt +++ b/android/src/com/unciv/app/MultiplayerTurnCheckWorker.kt @@ -186,7 +186,11 @@ class MultiplayerTurnCheckWorker(appContext: Context, workerParams: WorkerParame if (currentGameInfo.currentPlayerCiv.playerId == settings.userId) { // May be useful to remind a player that he forgot to complete his turn. - notifyUserAboutTurn(applicationContext, gameNames[gameIds.indexOf(currentGameInfo.gameId)]) + val gameIndex = gameIds.indexOf(currentGameInfo.gameId) + // Of the turnNotification is OFF, this will be -1 since we never saved this game in the array + // Or possibly reading the preview file returned an exception + if (gameIndex!=-1) + notifyUserAboutTurn(applicationContext, gameNames[gameIndex]) } else { val inputData = workDataOf(Pair(FAIL_COUNT, 0), Pair(GAME_ID, gameIds), Pair(GAME_NAME, gameNames), Pair(USER_ID, settings.userId), Pair(CONFIGURED_DELAY, settings.multiplayerTurnCheckerDelayInMinutes),