1) Code clean up 2) Backup savestate now only applies to save slots

This commit is contained in:
adelikat 2008-12-23 23:08:27 +00:00
parent 40926ab5f7
commit ff7496930b
5 changed files with 26 additions and 38 deletions

View File

@ -66,25 +66,3 @@ void FCEUD_LoadStateFrom()
}
}
bool CheckBackupSaveStateExist()
{
//This function simply checks to see if the backup loadstate exists, the backup loadstate is a special savestate
//That is made before loading any state, so that the user never loses his data
string filename = GetBackupFileName(); //Get backup savestate filename
//Check if this filename exists
fstream test;
test.open(filename.c_str(),fstream::in);
if (test.fail())
{
test.close();
return false;
}
else
{
test.close();
return true;
}
}

View File

@ -1,5 +1,5 @@
void FCEUD_SaveStateAs();
void FCEUD_LoadStateFrom();
bool CheckBackupSaveStateExist(); //Checks if backupsavestate exists
void LoadBackup(); //Load backup savestate

View File

@ -22,6 +22,7 @@
// does not include functions relevant for dialog windows.
#include "../../input.h"
#include "../../state.h"
#include "window.h"
#include "main.h"
#include "state.h"
@ -94,10 +95,6 @@ void ShowNetplayConsole(void); //mbg merge 7/17/06 YECH had to add
void MapInput(void);
extern BOOL CALLBACK ReplayMetadataDialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam); //Metadata dialog
extern bool CheckFileExists(const char* filename); //Receives a filename (fullpath) and checks to see if that file exists
//From src/state.cpp
extern bool undoSS; //Decides if undo savestate is eligible
extern bool redoSS; //Decides if it should be called redo instead of undo
extern void SwapSaveState(); //Performs the undo/redo operation
//AutoFire-----------------------------------------------
void SetAutoFirePattern(int onframes, int offframes);

View File

@ -431,16 +431,6 @@ void FCEUSS_Save(const char *fname)
if(fname) //If filename is given use it.
{
//backup existing savestate first
if (CheckFileExists(fname))
{
CreateBackupSaveState(fname); //Make a backup of previous savestate before overwriting it
strcpy(lastSavestateMade,fname); //Remember what the last savestate filename was (for undoing later)
undoSS = true; //Backup was created so redo is possible
}
else
undoSS = false; //so backup made so lastSavestateMade does have a backup file, so no undo
st =FCEUD_UTF8_fstream(fname, "wb");
}
else //Else, generate one
@ -958,6 +948,28 @@ string GetBackupFileName()
return filename;
}
bool CheckBackupSaveStateExist()
{
//This function simply checks to see if the backup loadstate exists, the backup loadstate is a special savestate
//That is made before loading any state, so that the user never loses his data
string filename = GetBackupFileName(); //Get backup savestate filename
//Check if this filename exists
fstream test;
test.open(filename.c_str(),fstream::in);
if (test.fail())
{
test.close();
return false;
}
else
{
test.close();
return true;
}
}
void BackupLoadState()
{
string filename = GetBackupFileName();

View File

@ -67,4 +67,5 @@ void LoadBackup(); //Loads the backupsavestate
void SwapSaveState(); //Swaps a savestate with its backup state
extern bool undoSS; //undo savestate flag
extern bool redoSS; //redo savestate flag
extern char lastSavestateMade[2048]; //Filename of last savestate used
extern char lastSavestateMade[2048]; //Filename of last savestate used
bool CheckBackupSaveStateExist(); //Checks if backupsavestate exists