fix memory card saves

This commit is contained in:
dborth 2009-04-09 07:41:37 +00:00
parent 993a3eb00f
commit e0f60f7ba6
2 changed files with 27 additions and 20 deletions

View File

@ -217,10 +217,22 @@ bool MakeFilePath(char filepath[], int type, int method, char * filename, int fi
if(filenum >= -1) if(filenum >= -1)
{ {
if(method == METHOD_MC_SLOTA || method == METHOD_MC_SLOTB) if(method == METHOD_MC_SLOTA || method == METHOD_MC_SLOTB)
{
if(filenum > 9)
{
return false;
}
else if(filenum == -1)
{
filename[27] = 0; // truncate filename
sprintf(file, "%s.%s", filename, ext);
}
else
{ {
filename[26] = 0; // truncate filename filename[26] = 0; // truncate filename
sprintf(file, "%s%i.%s", filename, filenum, ext); sprintf(file, "%s%i.%s", filename, filenum, ext);
} }
}
else else
{ {
if(filenum == -1) if(filenum == -1)

View File

@ -325,10 +325,13 @@ bool LoadBatteryOrStateAuto(int method, int action, bool silent)
if (action==FILE_SRAM) if (action==FILE_SRAM)
{ {
if (!LoadBatteryOrState(filepath, method, action, SILENT)) if (LoadBatteryOrState(filepath, method, action, SILENT))
{ return true;
// look for file with no number or Auto appended
if(!MakeFilePath(filepath2, action, method, ROMFilename, -1)) if(!MakeFilePath(filepath2, action, method, ROMFilename, -1))
return false; return false;
if(LoadBatteryOrState(filepath2, method, action, silent)) if(LoadBatteryOrState(filepath2, method, action, silent))
{ {
// rename this file - append Auto // rename this file - append Auto
@ -337,16 +340,8 @@ bool LoadBatteryOrStateAuto(int method, int action, bool silent)
rename(fullpath2, fullpath); // rename file (to avoid duplicates) rename(fullpath2, fullpath); // rename file (to avoid duplicates)
return true; return true;
} }
else
{
return false; return false;
} }
}
else
{
return true;
}
}
else else
{ {
return LoadBatteryOrState(filepath, method, action, silent); return LoadBatteryOrState(filepath, method, action, silent);