From 422bb588142383b47dfddc21e9888b0ed5337034 Mon Sep 17 00:00:00 2001 From: yairm210 Date: Mon, 15 Nov 2021 21:36:06 +0200 Subject: [PATCH] Caught out of memory errors on autosave --- core/src/com/unciv/logic/GameSaver.kt | 21 ++++++--------------- 1 file changed, 6 insertions(+), 15 deletions(-) diff --git a/core/src/com/unciv/logic/GameSaver.kt b/core/src/com/unciv/logic/GameSaver.kt index 178420ac6d..ca6b2aee28 100644 --- a/core/src/com/unciv/logic/GameSaver.kt +++ b/core/src/com/unciv/logic/GameSaver.kt @@ -149,24 +149,15 @@ object GameSaver { } fun autoSaveSingleThreaded(gameInfo: GameInfo) { -/* - ... out of order until further notice, see #3898 - // If the user has chosen a custom save location outside of the usual game directories, - // they'll probably expect us to overwrite that instead. E.g. if the user is saving their - // game to their Google Drive folder, they'll probably want that progress to be synced to - // other devices automatically so they don't have to remember to manually save before - // exiting the game. - if (gameInfo.customSaveLocation != null) { - // GameName is unused here since we're just overwriting the existing file - saveGame(gameInfo, "", false) - return + try { + saveGame(gameInfo, "Autosave") + } catch (oom: OutOfMemoryError) { + return // not much we can do here } -*/ - - saveGame(gameInfo, "Autosave") // keep auto-saves for the last 10 turns for debugging purposes - val newAutosaveFilename = saveFilesFolder + File.separator + "Autosave-${gameInfo.currentPlayer}-${gameInfo.turns}" + val newAutosaveFilename = + saveFilesFolder + File.separator + "Autosave-${gameInfo.currentPlayer}-${gameInfo.turns}" getSave("Autosave").copyTo(Gdx.files.local(newAutosaveFilename)) fun getAutosaves(): Sequence {