diff --git a/Common/Serialize/Serializer.h b/Common/Serialize/Serializer.h index d002e64b30..255de352d0 100644 --- a/Common/Serialize/Serializer.h +++ b/Common/Serialize/Serializer.h @@ -200,7 +200,8 @@ public: ERROR_BAD_ALLOC, }; - // May fail badly if ptr doesn't point to valid data. + // May fail badly if ptr doesn't point to valid data. On failure, errorString is the title of the + // section that failed. template static Error LoadPtr(u8 *ptr, size_t size, T &_class, std::string *errorString) { @@ -211,8 +212,7 @@ public: if (p.error != p.ERROR_FAILURE) { return ERROR_NONE; } else { - std::string badSectionTitle = p.GetBadSectionTitle() ? p.GetBadSectionTitle() : "(unknown bad section)"; - *errorString = std::string("Failure at ") + badSectionTitle; + *errorString = p.GetBadSectionTitle() ? p.GetBadSectionTitle() : "unknown section"; return ERROR_BROKEN_STATE; } } diff --git a/Core/SaveState.cpp b/Core/SaveState.cpp index 47a9314598..82a890a2ba 100644 --- a/Core/SaveState.cpp +++ b/Core/SaveState.cpp @@ -974,9 +974,12 @@ int g_screenshotFailures; g_lastSaveTime = time_now_d(); } else if (result == CChunkFileReader::ERROR_BROKEN_STATE) { HandleLoadFailure(false, &callbackMetadata); - callbackMessage = std::string(i18nLoadFailure) + ": " + errorString; - callbackMetadata = SavedByVersion(op.path); - ERROR_LOG(Log::SaveState, "Load state failure: %s (saved by %s)", errorString.c_str(), callbackMetadata.c_str()); + // The file was fine, its contents weren't: almost always a state from another version. + // errorString is the section that failed. + callbackMessage = sc->T("LoadStateWrongVersion", i18nLoadFailure); + const std::string version = SavedByVersion(op.path); + callbackMetadata = version.empty() ? "(" + errorString + ")" : version + " (" + errorString + ")"; + ERROR_LOG(Log::SaveState, "Load state failure at %s (saved by %s)", errorString.c_str(), version.c_str()); callbackResult = Status::FAILURE; } else { callbackMessage = errorString.empty() ? std::string(i18nLoadFailure) : std::string(sc->T(errorString, i18nLoadFailure)); @@ -1052,11 +1055,11 @@ int g_screenshotFailures; hasLoadedState = true; Core_ResetException(); } else { - callbackMessage = std::string(i18nLoadFailure) + ": " + errorString; + callbackMessage = std::string(i18nLoadFailure) + " (" + errorString + ")"; callbackResult = Status::FAILURE; } } else { - callbackMessage = std::string(i18nLoadFailure) + ": " + errorString; + callbackMessage = i18nLoadFailure; callbackResult = Status::FAILURE; } break; diff --git a/UI/EmuScreen.cpp b/UI/EmuScreen.cpp index 2727e5e1af..8eb5a6efe6 100644 --- a/UI/EmuScreen.cpp +++ b/UI/EmuScreen.cpp @@ -1768,7 +1768,7 @@ ScreenRenderFlags EmuScreen::RunEmulation(bool skipBufferEffects) { } else if (PSP_CoreParameter().frozen) { std::string errorString; if (CChunkFileReader::ERROR_NONE != SaveState::LoadFromRam(freezeState_, &errorString)) { - ERROR_LOG(Log::SaveState, "Failed to load freeze state (%s). Unfreezing.", errorString.c_str()); + ERROR_LOG(Log::SaveState, "Failed to load freeze state (failure at %s). Unfreezing.", errorString.c_str()); PSP_CoreParameter().frozen = false; } }