Save states: Make auto save states ignore time when the game is paused

This commit is contained in:
Sour 2019-11-14 21:26:22 -05:00
parent 03ad7d5cc7
commit 246e8a2c0a

View file

@ -9,18 +9,27 @@ AutoSaveManager::AutoSaveManager(shared_ptr<Console> console)
_stopThread = false; _stopThread = false;
_timer.Reset(); _timer.Reset();
_autoSaveThread = std::thread([=]() { _autoSaveThread = std::thread([=]() {
bool showMessage = false;
double targetTime = (double)console->GetSettings()->GetAutoSaveDelay(showMessage) * 60 * 1000;
while(!_stopThread) { while(!_stopThread) {
bool showMessage = false;
uint32_t autoSaveDelay = console->GetSettings()->GetAutoSaveDelay(showMessage) * 60 * 1000; uint32_t autoSaveDelay = console->GetSettings()->GetAutoSaveDelay(showMessage) * 60 * 1000;
if(autoSaveDelay > 0) { if(autoSaveDelay > 0) {
if(_timer.GetElapsedMS() > autoSaveDelay) { if(targetTime >= 0 && !console->IsExecutionStopped()) {
if(!console->IsDebuggerAttached()) { targetTime -= _timer.GetElapsedMS();
console->GetSaveStateManager()->SaveState(_autoSaveSlot, showMessage); _timer.Reset();
if(targetTime <= 0) {
if(!console->IsDebuggerAttached()) {
console->GetSaveStateManager()->SaveState(_autoSaveSlot, showMessage);
}
targetTime = (double)console->GetSettings()->GetAutoSaveDelay(showMessage) * 60 * 1000;
_timer.Reset();
} }
} else {
_timer.Reset(); _timer.Reset();
} }
} else { } else {
_timer.Reset(); _timer.Reset();
targetTime = autoSaveDelay;
} }
if(!_stopThread) { if(!_stopThread) {