Save oops unconditionally on loading state.

GTK+: Use oops for undo load state.
This commit is contained in:
Brandon Wright 2018-06-20 12:44:09 -05:00
parent e91f14744b
commit fc0b79ec2f
3 changed files with 7 additions and 14 deletions

View File

@ -385,8 +385,6 @@ S9xAutoSaveSRAM (void)
void
S9xLoadState (const char *filename)
{
S9xFreezeGame (S9xGetFilename (".undo", SNAPSHOT_DIR));
if (S9xUnfreezeGame (filename))
{
sprintf (buf, "%s loaded", filename);
@ -530,9 +528,6 @@ S9xQuickLoadSlot (int slot)
S9xGetDirectory (SNAPSHOT_DIR), SLASH_STR, def,
slot);
if (file_exists (filename))
S9xFreezeGame (S9xGetFilename (".undo", SNAPSHOT_DIR));
if (S9xUnfreezeGame (filename))
{
snprintf (buf, PATH_MAX, "%s.%03d loaded", def, slot);
@ -548,9 +543,6 @@ S9xQuickLoadSlot (int slot)
S9xGetDirectory (SNAPSHOT_DIR), SLASH_STR,
def, digits[slot]);
if (file_exists (filename))
S9xFreezeGame (S9xGetFilename (".undo", SNAPSHOT_DIR));
if (S9xUnfreezeGame (filename))
{
snprintf (buf, PATH_MAX,

View File

@ -463,7 +463,7 @@ event_load_state (GtkWidget *widget, gpointer data)
static void
event_load_state_undo (GtkWidget *widget, gpointer data)
{
S9xUnfreezeGame (S9xGetFilename (".undo", SNAPSHOT_DIR));
S9xUnfreezeGame (S9xGetFilename (".oops", SNAPSHOT_DIR));
return;
}

View File

@ -1182,12 +1182,11 @@ static void UnfreezeStructFromCopy (void *, FreezeData *, int, uint8 *, int);
static void FreezeBlock (STREAM, const char *, uint8 *, int);
static void FreezeStruct (STREAM, const char *, void *, FreezeData *, int);
static time_t oops_timer = -1;
void S9xResetSaveTimer (bool8 dontsave)
{
static time_t t = -1;
if (!Settings.DontSaveOopsSnapshot && !dontsave && t != -1 && time(NULL) - t > 300)
if (!Settings.DontSaveOopsSnapshot && !dontsave && oops_timer != -1 && time(NULL) - oops_timer > 300)
{
char filename[PATH_MAX + 1];
char drive[_MAX_DRIVE + 1], dir[_MAX_DIR + 1], def[_MAX_FNAME + 1], ext[_MAX_EXT + 1];
@ -1198,7 +1197,7 @@ void S9xResetSaveTimer (bool8 dontsave)
S9xFreezeGame(filename);
}
t = time(NULL);
oops_timer = time(NULL);
}
uint32 S9xFreezeSize()
@ -1257,12 +1256,14 @@ bool8 S9xUnfreezeGame (const char *filename)
const char *base = S9xBasename(filename);
_splitpath(filename, drive, dir, def, ext);
S9xResetSaveTimer(!strcmp(ext, "oops") || !strcmp(ext, "oop") || !strcmp(ext, ".oops") || !strcmp(ext, ".oop"));
if (S9xOpenSnapshotFile(filename, TRUE, &stream))
{
int result;
oops_timer = 0;
S9xResetSaveTimer(!strcmp(ext, "oops") || !strcmp(ext, "oop") || !strcmp(ext, ".oops") || !strcmp(ext, ".oop"));
result = S9xUnfreezeFromStream(stream);
S9xCloseSnapshotFile(stream);