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,19 +9,28 @@ AutoSaveManager::AutoSaveManager(shared_ptr<Console> console)
_stopThread = false;
_timer.Reset();
_autoSaveThread = std::thread([=]() {
while(!_stopThread) {
bool showMessage = false;
double targetTime = (double)console->GetSettings()->GetAutoSaveDelay(showMessage) * 60 * 1000;
while(!_stopThread) {
uint32_t autoSaveDelay = console->GetSettings()->GetAutoSaveDelay(showMessage) * 60 * 1000;
if(autoSaveDelay > 0) {
if(_timer.GetElapsedMS() > autoSaveDelay) {
if(targetTime >= 0 && !console->IsExecutionStopped()) {
targetTime -= _timer.GetElapsedMS();
_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();
}
} else {
_timer.Reset();
targetTime = autoSaveDelay;
}
if(!_stopThread) {
_signal.Wait(1000);