From a8b55c3e10d8337052aa2f200f4e080bd2b39603 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sun, 9 Feb 2014 13:45:51 -0800 Subject: [PATCH] Keep track of whether a savestate has been used. Mostly to improve info we get in reporting. --- Core/Reporting.cpp | 4 +++- Core/SaveState.cpp | 11 +++++++++++ Core/SaveState.h | 3 +++ 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/Core/Reporting.cpp b/Core/Reporting.cpp index fb851a8eb7..9b03cb106e 100644 --- a/Core/Reporting.cpp +++ b/Core/Reporting.cpp @@ -20,6 +20,7 @@ #include "Common/CPUDetect.h" #include "Core/CoreTiming.h" #include "Core/Config.h" +#include "Core/SaveState.h" #include "Core/System.h" #include "Core/HLE/sceDisplay.h" #include "Core/HLE/sceKernelMemory.h" @@ -219,7 +220,8 @@ namespace Reporting postdata.Add("fps", fps); } - // TODO: Settings, savestate/savedata status, some measure of speed/fps? + // TODO: Settings? + postdata.Add("savestate_used", SaveState::HasLoadedState()); switch (payload.type) { diff --git a/Core/SaveState.cpp b/Core/SaveState.cpp index 1e440e530d..b45886de71 100644 --- a/Core/SaveState.cpp +++ b/Core/SaveState.cpp @@ -203,6 +203,7 @@ namespace SaveState static bool needsProcess = false; static std::vector pending; static std::recursive_mutex mutex; + static bool hasLoadedState = false; // TODO: Should this be configurable? static const int REWIND_NUM_STATES = 20; @@ -430,6 +431,11 @@ namespace SaveState rewindStates.Save(); } + bool HasLoadedState() + { + return hasLoadedState; + } + void Process() { #ifndef MOBILE_DEVICE @@ -474,6 +480,7 @@ namespace SaveState if (result == CChunkFileReader::ERROR_NONE) { osm.Show(s->T("Loaded State"), 2.0); callbackResult = true; + hasLoadedState = true; } else if (result == CChunkFileReader::ERROR_BROKEN_STATE) { HandleFailure(); osm.Show(i18nLoadFailure, 2.0); @@ -513,12 +520,14 @@ namespace SaveState if (result == CChunkFileReader::ERROR_NONE) { osm.Show(s->T("Loaded State"), 2.0); callbackResult = true; + hasLoadedState = true; } else if (result == CChunkFileReader::ERROR_BROKEN_STATE) { // Cripes. Good news is, we might have more. Let's try those too, better than a reset. if (HandleFailure()) { // Well, we did rewind, even if too much... osm.Show(s->T("Loaded State"), 2.0); callbackResult = true; + hasLoadedState = true; } else { osm.Show(i18nLoadFailure, 2.0); callbackResult = false; @@ -547,5 +556,7 @@ namespace SaveState std::lock_guard guard(mutex); rewindStates.Clear(); + + hasLoadedState = false; } } diff --git a/Core/SaveState.h b/Core/SaveState.h index 1244bb3b8e..d27eb0bb26 100644 --- a/Core/SaveState.h +++ b/Core/SaveState.h @@ -63,6 +63,9 @@ namespace SaveState // Returns true if there are rewind snapshots available. bool CanRewind(); + // Returns true if a savestate has been used during this session. + bool HasLoadedState(); + // Check if there's any save stating needing to be done. Normally called once per frame. void Process(); };