System: Update running game when media changes from save state

This commit is contained in:
Connor McLaughlin
2020-01-24 14:50:48 +10:00
parent f2d5ce74df
commit 0a5f7fcd75
4 changed files with 33 additions and 11 deletions

View File

@ -238,6 +238,26 @@ bool System::DoState(StateWrapper& sw)
sw.Do(&m_internal_frame_number);
sw.Do(&m_global_tick_counter);
std::string media_filename = m_cdrom->GetMediaFileName();
sw.Do(&media_filename);
if (sw.IsReading())
{
std::unique_ptr<CDImage> media;
if (!media_filename.empty())
{
media = CDImage::Open(media_filename.c_str());
if (!media)
Log_ErrorPrintf("Failed to open CD image from save state: '%s'", media_filename.c_str());
}
m_host_interface->UpdateRunningGame(media_filename.c_str(), media.get());
if (media)
m_cdrom->InsertMedia(std::move(media));
else
m_cdrom->RemoveMedia();
}
if (!sw.DoMarker("CPU") || !m_cpu->DoState(sw))
return false;