From b695d3c6ce378fece0a0d0135bbb5781ee4962e1 Mon Sep 17 00:00:00 2001 From: Connor McLaughlin Date: Sun, 29 Nov 2020 23:00:24 +1000 Subject: [PATCH] System: Use existing media if save state media is not found --- src/core/system.cpp | 29 +++++++++++++++++++++++------ 1 file changed, 23 insertions(+), 6 deletions(-) diff --git a/src/core/system.cpp b/src/core/system.cpp index d5b82a429..e5ad71b84 100644 --- a/src/core/system.cpp +++ b/src/core/system.cpp @@ -980,16 +980,33 @@ bool DoLoadState(ByteStream* state, bool force_software_renderer, bool update_di return false; } - media = g_cdrom.RemoveMedia(); - if (!media || media->GetFileName() != media_filename) + std::unique_ptr old_media = g_cdrom.RemoveMedia(); + if (old_media && old_media->GetFileName() == media_filename) + { + Log_InfoPrintf("Re-using same media '%s'", media_filename.c_str()); + media = std::move(old_media); + } + else { media = OpenCDImage(media_filename.c_str(), false); if (!media) { - g_host_interface->ReportFormattedError( - g_host_interface->TranslateString("System", "Failed to open CD image from save state: '%s'."), - media_filename.c_str()); - return false; + if (old_media) + { + g_host_interface->AddFormattedOSDMessage( + 30.0f, + g_host_interface->TranslateString("OSDMessage", "Failed to open CD image from save state: '%s'. Using " + "existing image '%s', this may result in instability."), + media_filename.c_str(), old_media->GetFileName().c_str()); + media = std::move(old_media); + } + else + { + g_host_interface->ReportFormattedError( + g_host_interface->TranslateString("System", "Failed to open CD image from save state: '%s'."), + media_filename.c_str()); + return false; + } } } }