mirror of https://github.com/snes9xgit/snes9x.git
Revert "Save oops unconditionally on loading state."
This reverts commit fc0b79ec2f
.
This commit is contained in:
parent
fc0b79ec2f
commit
ae814163dd
|
@ -385,6 +385,8 @@ S9xAutoSaveSRAM (void)
|
||||||
void
|
void
|
||||||
S9xLoadState (const char *filename)
|
S9xLoadState (const char *filename)
|
||||||
{
|
{
|
||||||
|
S9xFreezeGame (S9xGetFilename (".undo", SNAPSHOT_DIR));
|
||||||
|
|
||||||
if (S9xUnfreezeGame (filename))
|
if (S9xUnfreezeGame (filename))
|
||||||
{
|
{
|
||||||
sprintf (buf, "%s loaded", filename);
|
sprintf (buf, "%s loaded", filename);
|
||||||
|
@ -528,6 +530,9 @@ S9xQuickLoadSlot (int slot)
|
||||||
S9xGetDirectory (SNAPSHOT_DIR), SLASH_STR, def,
|
S9xGetDirectory (SNAPSHOT_DIR), SLASH_STR, def,
|
||||||
slot);
|
slot);
|
||||||
|
|
||||||
|
if (file_exists (filename))
|
||||||
|
S9xFreezeGame (S9xGetFilename (".undo", SNAPSHOT_DIR));
|
||||||
|
|
||||||
if (S9xUnfreezeGame (filename))
|
if (S9xUnfreezeGame (filename))
|
||||||
{
|
{
|
||||||
snprintf (buf, PATH_MAX, "%s.%03d loaded", def, slot);
|
snprintf (buf, PATH_MAX, "%s.%03d loaded", def, slot);
|
||||||
|
@ -543,6 +548,9 @@ S9xQuickLoadSlot (int slot)
|
||||||
S9xGetDirectory (SNAPSHOT_DIR), SLASH_STR,
|
S9xGetDirectory (SNAPSHOT_DIR), SLASH_STR,
|
||||||
def, digits[slot]);
|
def, digits[slot]);
|
||||||
|
|
||||||
|
if (file_exists (filename))
|
||||||
|
S9xFreezeGame (S9xGetFilename (".undo", SNAPSHOT_DIR));
|
||||||
|
|
||||||
if (S9xUnfreezeGame (filename))
|
if (S9xUnfreezeGame (filename))
|
||||||
{
|
{
|
||||||
snprintf (buf, PATH_MAX,
|
snprintf (buf, PATH_MAX,
|
||||||
|
|
|
@ -463,7 +463,7 @@ event_load_state (GtkWidget *widget, gpointer data)
|
||||||
static void
|
static void
|
||||||
event_load_state_undo (GtkWidget *widget, gpointer data)
|
event_load_state_undo (GtkWidget *widget, gpointer data)
|
||||||
{
|
{
|
||||||
S9xUnfreezeGame (S9xGetFilename (".oops", SNAPSHOT_DIR));
|
S9xUnfreezeGame (S9xGetFilename (".undo", SNAPSHOT_DIR));
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
11
snapshot.cpp
11
snapshot.cpp
|
@ -1182,11 +1182,12 @@ static void UnfreezeStructFromCopy (void *, FreezeData *, int, uint8 *, int);
|
||||||
static void FreezeBlock (STREAM, const char *, uint8 *, int);
|
static void FreezeBlock (STREAM, const char *, uint8 *, int);
|
||||||
static void FreezeStruct (STREAM, const char *, void *, FreezeData *, int);
|
static void FreezeStruct (STREAM, const char *, void *, FreezeData *, int);
|
||||||
|
|
||||||
static time_t oops_timer = -1;
|
|
||||||
|
|
||||||
void S9xResetSaveTimer (bool8 dontsave)
|
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 filename[PATH_MAX + 1];
|
||||||
char drive[_MAX_DRIVE + 1], dir[_MAX_DIR + 1], def[_MAX_FNAME + 1], ext[_MAX_EXT + 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);
|
S9xFreezeGame(filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
oops_timer = time(NULL);
|
t = time(NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32 S9xFreezeSize()
|
uint32 S9xFreezeSize()
|
||||||
|
@ -1256,14 +1257,12 @@ bool8 S9xUnfreezeGame (const char *filename)
|
||||||
const char *base = S9xBasename(filename);
|
const char *base = S9xBasename(filename);
|
||||||
|
|
||||||
_splitpath(filename, drive, dir, def, ext);
|
_splitpath(filename, drive, dir, def, ext);
|
||||||
|
S9xResetSaveTimer(!strcmp(ext, "oops") || !strcmp(ext, "oop") || !strcmp(ext, ".oops") || !strcmp(ext, ".oop"));
|
||||||
|
|
||||||
if (S9xOpenSnapshotFile(filename, TRUE, &stream))
|
if (S9xOpenSnapshotFile(filename, TRUE, &stream))
|
||||||
{
|
{
|
||||||
int result;
|
int result;
|
||||||
|
|
||||||
oops_timer = 0;
|
|
||||||
S9xResetSaveTimer(!strcmp(ext, "oops") || !strcmp(ext, "oop") || !strcmp(ext, ".oops") || !strcmp(ext, ".oop"));
|
|
||||||
|
|
||||||
result = S9xUnfreezeFromStream(stream);
|
result = S9xUnfreezeFromStream(stream);
|
||||||
S9xCloseSnapshotFile(stream);
|
S9xCloseSnapshotFile(stream);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue