Merge pull request #7135 from JosJuice/cant-load-state

Only show savestate version mismatch OSD message when relevant
This commit is contained in:
Markus Wick 2018-06-21 09:28:47 +02:00 committed by GitHub
commit 3816e825c9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 10 additions and 15 deletions

View File

@ -146,17 +146,18 @@ static bool DoStateVersion(PointerWrap& p, std::string* version_created_by)
return true; return true;
} }
static std::string DoState(PointerWrap& p) static void DoState(PointerWrap& p)
{ {
std::string version_created_by; std::string version_created_by;
if (!DoStateVersion(p, &version_created_by)) if (!DoStateVersion(p, &version_created_by))
{ {
// because the version doesn't match, fail. const std::string message =
// this will trigger an OSD message like "Can't load state from other revisions" version_created_by.empty() ?
// we could use the version numbers to maintain some level of backward compatibility, but "This savestate was created using an incompatible version of Dolphin" :
// currently don't. "This savestate was created using the incompatible version " + version_created_by;
Core::DisplayMessage(message, OSD::Duration::NORMAL);
p.SetMode(PointerWrap::MODE_MEASURE); p.SetMode(PointerWrap::MODE_MEASURE);
return version_created_by; return;
} }
bool is_wii = SConfig::GetInstance().bWii || SConfig::GetInstance().m_is_mios; bool is_wii = SConfig::GetInstance().bWii || SConfig::GetInstance().m_is_mios;
@ -168,7 +169,7 @@ static std::string DoState(PointerWrap& p)
is_wii ? "Wii" : "GC", is_wii_currently ? "Wii" : "GC"), is_wii ? "Wii" : "GC", is_wii_currently ? "Wii" : "GC"),
OSD::Duration::NORMAL, OSD::Color::RED); OSD::Duration::NORMAL, OSD::Color::RED);
p.SetMode(PointerWrap::MODE_MEASURE); p.SetMode(PointerWrap::MODE_MEASURE);
return version_created_by; return;
} }
// Begin with video backend, so that it gets a chance to clear its caches and writeback modified // Begin with video backend, so that it gets a chance to clear its caches and writeback modified
@ -196,8 +197,6 @@ static std::string DoState(PointerWrap& p)
#if defined(HAVE_FFMPEG) #if defined(HAVE_FFMPEG)
AVIDump::DoState(); AVIDump::DoState();
#endif #endif
return version_created_by;
} }
void LoadFromBuffer(std::vector<u8>& buffer) void LoadFromBuffer(std::vector<u8>& buffer)
@ -547,7 +546,6 @@ void LoadAs(const std::string& filename)
bool loaded = false; bool loaded = false;
bool loadedSuccessfully = false; bool loadedSuccessfully = false;
std::string version_created_by;
// brackets here are so buffer gets freed ASAP // brackets here are so buffer gets freed ASAP
{ {
@ -558,7 +556,7 @@ void LoadAs(const std::string& filename)
{ {
u8* ptr = &buffer[0]; u8* ptr = &buffer[0];
PointerWrap p(&ptr, PointerWrap::MODE_READ); PointerWrap p(&ptr, PointerWrap::MODE_READ);
version_created_by = DoState(p); DoState(p);
loaded = true; loaded = true;
loadedSuccessfully = (p.GetMode() == PointerWrap::MODE_READ); loadedSuccessfully = (p.GetMode() == PointerWrap::MODE_READ);
} }
@ -577,10 +575,7 @@ void LoadAs(const std::string& filename)
} }
else else
{ {
// failed to load Core::DisplayMessage("The savestate could not be loaded", OSD::Duration::NORMAL);
Core::DisplayMessage("Unable to load: Can't load state from other versions!", 4000);
if (!version_created_by.empty())
Core::DisplayMessage("The savestate was created using " + version_created_by, 4000);
// since we could be in an inconsistent state now (and might crash or whatever), undo. // since we could be in an inconsistent state now (and might crash or whatever), undo.
if (g_loadDepth < 2) if (g_loadDepth < 2)