Revert "Save oops unconditionally on loading state."

This reverts commit fc0b79ec2f.
This commit is contained in:
Brandon Wright 2018-06-21 13:46:29 -05:00
parent fc0b79ec2f
commit ae814163dd
3 changed files with 14 additions and 7 deletions

View File

@ -385,6 +385,8 @@ S9xAutoSaveSRAM (void)
void
S9xLoadState (const char *filename)
{
S9xFreezeGame (S9xGetFilename (".undo", SNAPSHOT_DIR));
if (S9xUnfreezeGame (filename))
{
sprintf (buf, "%s loaded", filename);
@ -528,6 +530,9 @@ 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);
@ -543,6 +548,9 @@ 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 (".oops", SNAPSHOT_DIR));
S9xUnfreezeGame (S9xGetFilename (".undo", SNAPSHOT_DIR));
return;
}

View File

@ -1182,11 +1182,12 @@ 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)
{
if (!Settings.DontSaveOopsSnapshot && !dontsave && oops_timer != -1 && time(NULL) - oops_timer > 300)
static time_t t = -1;
if (!Settings.DontSaveOopsSnapshot && !dontsave && t != -1 && time(NULL) - t > 300)
{
char filename[PATH_MAX + 1];
char drive[_MAX_DRIVE + 1], dir[_MAX_DIR + 1], def[_MAX_FNAME + 1], ext[_MAX_EXT + 1];
@ -1197,7 +1198,7 @@ void S9xResetSaveTimer (bool8 dontsave)
S9xFreezeGame(filename);
}
oops_timer = time(NULL);
t = time(NULL);
}
uint32 S9xFreezeSize()
@ -1256,14 +1257,12 @@ 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);