From fa4fa164cb56b9fa6b3c727f0254ac4887d93501 Mon Sep 17 00:00:00 2001 From: StapleButter Date: Mon, 5 Nov 2018 16:14:48 +0100 Subject: * store all 32 matrix stack entries in savestates instead of 31. * bump savestate version up. will break compatibility, but the alternative would be guessing the missing matrix entries somehow, so blarg. * avoid relocating the savefile if loading a savestate fails. --- src/libui_sdl/main.cpp | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) (limited to 'src/libui_sdl/main.cpp') diff --git a/src/libui_sdl/main.cpp b/src/libui_sdl/main.cpp index 4c19314..9ca829e 100644 --- a/src/libui_sdl/main.cpp +++ b/src/libui_sdl/main.cpp @@ -922,6 +922,8 @@ void LoadState(int slot) NDS::DoSavestate(backup); delete backup; + bool failed = false; + Savestate* state = new Savestate(filename, false); if (state->Error) { @@ -931,26 +933,30 @@ void LoadState(int slot) // current state might be crapoed, so restore from sane backup state = new Savestate("timewarp.mln", false); + failed = true; } NDS::DoSavestate(state); delete state; - if (Config::SavestateRelocSRAM && ROMPath[0]!='\0') + if (!failed) { - strncpy(PrevSRAMPath, SRAMPath, 1024); + if (Config::SavestateRelocSRAM && ROMPath[0]!='\0') + { + strncpy(PrevSRAMPath, SRAMPath, 1024); + + strncpy(SRAMPath, filename, 1019); + int len = strlen(SRAMPath); + strcpy(&SRAMPath[len], ".sav"); + SRAMPath[len+4] = '\0'; - strncpy(SRAMPath, filename, 1019); - int len = strlen(SRAMPath); - strcpy(&SRAMPath[len], ".sav"); - SRAMPath[len+4] = '\0'; + NDS::RelocateSave(SRAMPath, false); + } - NDS::RelocateSave(SRAMPath, false); + SavestateLoaded = true; + uiMenuItemEnable(MenuItem_UndoStateLoad); } - SavestateLoaded = true; - uiMenuItemEnable(MenuItem_UndoStateLoad); - EmuRunning = prevstatus; } -- cgit v1.2.3