add code to make a backup savestate every time a slot savestate is loaded. I don't need to spell out for you which users this is for, and why they need it.
This commit is contained in:
parent
d854909b04
commit
0d65ea6050
|
@ -45,14 +45,6 @@ public:
|
||||||
return &info;
|
return &info;
|
||||||
}
|
}
|
||||||
|
|
||||||
//called once when the emulator starts up, or when the device springs into existence
|
|
||||||
virtual bool init()
|
|
||||||
{
|
|
||||||
//strange to do this here but we need to make sure its done at some point
|
|
||||||
srand(time(NULL));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual void connect()
|
virtual void connect()
|
||||||
{
|
{
|
||||||
img = slot1_GetFatImage();
|
img = slot1_GetFatImage();
|
||||||
|
|
|
@ -230,6 +230,9 @@ ENDL
|
||||||
|
|
||||||
bool CommandLine::parse(int argc,char **argv)
|
bool CommandLine::parse(int argc,char **argv)
|
||||||
{
|
{
|
||||||
|
//closest thing to a portable main() we have, I guess.
|
||||||
|
srand((unsigned)time(nullptr));
|
||||||
|
|
||||||
std::string _render3d;
|
std::string _render3d;
|
||||||
|
|
||||||
int opt_help = 0;
|
int opt_help = 0;
|
||||||
|
|
|
@ -411,8 +411,6 @@ void PathInfo::formatname(char *output)
|
||||||
time_t now = time(NULL);
|
time_t now = time(NULL);
|
||||||
tm *time_struct = localtime(&now);
|
tm *time_struct = localtime(&now);
|
||||||
|
|
||||||
srand((unsigned)now);
|
|
||||||
|
|
||||||
for (char* p = screenshotFormat,
|
for (char* p = screenshotFormat,
|
||||||
*end = p + sizeof(screenshotFormat); p < end; p++)
|
*end = p + sizeof(screenshotFormat); p < end; p++)
|
||||||
{
|
{
|
||||||
|
|
|
@ -57,6 +57,7 @@
|
||||||
|
|
||||||
#ifdef HOST_WINDOWS
|
#ifdef HOST_WINDOWS
|
||||||
#include "frontend/windows/main.h"
|
#include "frontend/windows/main.h"
|
||||||
|
extern char IniName[MAX_PATH];
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int lastSaveState = 0; //Keeps track of last savestate used for quick save/load functions
|
int lastSaveState = 0; //Keeps track of last savestate used for quick save/load functions
|
||||||
|
@ -726,8 +727,44 @@ void loadstate_slot(int num)
|
||||||
|
|
||||||
path.getpathnoext(path.STATE_SLOTS, filename);
|
path.getpathnoext(path.STATE_SLOTS, filename);
|
||||||
|
|
||||||
|
//save the state before we load the state, to give people a path for recovery in case they hit the wrong key
|
||||||
|
#ifdef HOST_WINDOWS
|
||||||
|
if(!GetPrivateProfileInt("General", "BackupSavestateSuppress", 0, IniName))
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
if(movieMode == MOVIEMODE_INACTIVE)
|
||||||
|
{
|
||||||
|
std::string dirname = (std::string)filename + " (backups)";
|
||||||
|
#ifdef HOST_WINDOWS
|
||||||
|
static const char PSS = '\\';
|
||||||
|
#else
|
||||||
|
static const char PSS = '/';
|
||||||
|
#endif
|
||||||
|
mkdir(dirname.c_str(),0777);
|
||||||
|
static unsigned seed;
|
||||||
|
for(;;)
|
||||||
|
{
|
||||||
|
std::string fname = dirname + PSS;
|
||||||
|
char mini[100];
|
||||||
|
sprintf(mini,"%u",seed);
|
||||||
|
fname += mini + (std::string)".dst";
|
||||||
|
FILE* f = fopen(fname.c_str(),"rb");
|
||||||
|
if(f)
|
||||||
|
{
|
||||||
|
seed = rand()*16000+rand();
|
||||||
|
fclose(f);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
seed++;
|
||||||
|
savestate_save(fname.c_str());
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (strlen(filename) + strlen(".dsx") + strlen("-2147483648") /* = biggest string for num */ > MAX_PATH) return;
|
if (strlen(filename) + strlen(".dsx") + strlen("-2147483648") /* = biggest string for num */ > MAX_PATH) return;
|
||||||
sprintf(filename + strlen(filename), ".ds%d", num);
|
sprintf(filename + strlen(filename), ".ds%d", num);
|
||||||
|
|
||||||
if (savestate_load(filename))
|
if (savestate_load(filename))
|
||||||
{
|
{
|
||||||
driver->SetLineColor(255, 255, 255);
|
driver->SetLineColor(255, 255, 255);
|
||||||
|
|
Loading…
Reference in New Issue