From 6b870179cfb242fc14d350174bd38f2115535c42 Mon Sep 17 00:00:00 2001 From: dborth Date: Mon, 25 Jan 2010 22:31:54 +0000 Subject: [PATCH] use srm file without "auto", if found --- source/ngc/snes9xGX.cpp | 1 - source/ngc/sram.cpp | 27 ++++++++++++++++++--------- 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/source/ngc/snes9xGX.cpp b/source/ngc/snes9xGX.cpp index c2cf715..ea7fa9b 100644 --- a/source/ngc/snes9xGX.cpp +++ b/source/ngc/snes9xGX.cpp @@ -45,7 +45,6 @@ #include "snes9xGX.h" #include "networkop.h" #include "video.h" -#include "s9xconfig.h" #include "audio.h" #include "menu.h" #include "sram.h" diff --git a/source/ngc/sram.cpp b/source/ngc/sram.cpp index 96fc250..23038a1 100644 --- a/source/ngc/sram.cpp +++ b/source/ngc/sram.cpp @@ -34,7 +34,7 @@ LoadSRAM (char * filepath, bool silent) int len = 0; int device; bool result = false; - + if(!FindDevice(filepath, &device)) return 0; @@ -70,7 +70,6 @@ bool LoadSRAMAuto (bool silent) { char filepath[MAXPATHLEN]; - char filepath2[MAXPATHLEN]; // look for Auto save file if(!MakeFilePath(filepath, FILE_SRAM, Memory.ROMFilename, 0)) @@ -80,15 +79,12 @@ LoadSRAMAuto (bool silent) return true; // look for file with no number or Auto appended - if(!MakeFilePath(filepath2, FILE_SRAM, Memory.ROMFilename, -1)) + if(!MakeFilePath(filepath, FILE_SRAM, Memory.ROMFilename, -1)) return false; - if(LoadSRAM(filepath2, silent)) - { - // rename this file - append Auto - rename(filepath2, filepath); // rename file (to avoid duplicates) + if(LoadSRAM(filepath, silent)) return true; - } + return false; } @@ -141,9 +137,22 @@ SaveSRAMAuto (bool silent) { char filepath[1024]; - if(!MakeFilePath(filepath, FILE_SRAM, Memory.ROMFilename, 0)) + // look for file with no number or Auto appended + if(!MakeFilePath(filepath, FILE_SRAM, Memory.ROMFilename, -1)) return false; + FILE * fp = fopen (filepath, "rb"); + + if(fp) // file found + { + fclose (fp); + } + else + { + if(!MakeFilePath(filepath, FILE_SRAM, Memory.ROMFilename, 0)) + return false; + } + return SaveSRAM(filepath, silent); }