System: Use existing media if save state media is not found

This commit is contained in:
Connor McLaughlin 2020-11-29 23:00:24 +10:00
parent eaafd0a00c
commit b695d3c6ce
1 changed files with 23 additions and 6 deletions

View File

@ -980,11 +980,27 @@ bool DoLoadState(ByteStream* state, bool force_software_renderer, bool update_di
return false; return false;
} }
media = g_cdrom.RemoveMedia(); std::unique_ptr<CDImage> old_media = g_cdrom.RemoveMedia();
if (!media || media->GetFileName() != media_filename) 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); media = OpenCDImage(media_filename.c_str(), false);
if (!media) if (!media)
{
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->ReportFormattedError(
g_host_interface->TranslateString("System", "Failed to open CD image from save state: '%s'."), g_host_interface->TranslateString("System", "Failed to open CD image from save state: '%s'."),
@ -993,6 +1009,7 @@ bool DoLoadState(ByteStream* state, bool force_software_renderer, bool update_di
} }
} }
} }
}
std::string playlist_filename; std::string playlist_filename;
std::vector<std::string> playlist_entries; std::vector<std::string> playlist_entries;