From c4ef959e47facac7ac883865ec71f3c3b0907ec1 Mon Sep 17 00:00:00 2001 From: Konrad Borowski Date: Wed, 26 Jul 2023 17:52:34 +0200 Subject: [PATCH] Backup save when saving --- Data/Scripts/050_AddOns/MultiSaves.rb | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Data/Scripts/050_AddOns/MultiSaves.rb b/Data/Scripts/050_AddOns/MultiSaves.rb index dc6df66c4..b6547c715 100644 --- a/Data/Scripts/050_AddOns/MultiSaves.rb +++ b/Data/Scripts/050_AddOns/MultiSaves.rb @@ -285,7 +285,9 @@ class PokemonLoadScreen def try_load_backup(file_path) if File.file?(file_path + ".bak") pbMessage(_INTL("The save file is corrupt. A backup will be loaded.")) - save_data = load_save_file(file_path + ".bak") + file_copy(file_path, SaveData.get_backup_file_path) + File.rename(file_path + '.bak', file_path) + save_data = load_save_file(file_path) else self.prompt_save_deletion(file_path) return {} @@ -693,6 +695,9 @@ module Game $Trainer.save_slot = slot unless auto $Trainer.last_time_saved = Time.now begin + if File.exists?(file_path) + file_copy(file_path, file_path + '.bak') + end SaveData.save_to_file(file_path) Graphics.frame_reset rescue IOError, SystemCallError