System: Simplify save state booting

Fixes memory card warning messages on load state.
This commit is contained in:
Connor McLaughlin
2020-05-27 02:01:09 +10:00
parent d2c7639dd8
commit b17a5832e5
5 changed files with 95 additions and 61 deletions

View File

@ -82,13 +82,13 @@ void HostInterface::CreateAudioStream()
bool HostInterface::BootSystem(const SystemBootParameters& parameters)
{
if (parameters.filename.empty())
Log_InfoPrintf("Boot Filename: <BIOS/Shell>");
else
Log_InfoPrintf("Boot Filename: %s", parameters.filename.c_str());
if (!parameters.state_filename.empty())
Log_InfoPrintf("Save State Filename: %s", parameters.filename.c_str());
if (!parameters.state_stream)
{
if (parameters.filename.empty())
Log_InfoPrintf("Boot Filename: <BIOS/Shell>");
else
Log_InfoPrintf("Boot Filename: %s", parameters.filename.c_str());
}
if (!AcquireHostDisplay())
{
@ -111,9 +111,6 @@ bool HostInterface::BootSystem(const SystemBootParameters& parameters)
return false;
}
if (!parameters.state_filename.empty())
LoadState(parameters.state_filename.c_str());
OnSystemCreated();
m_paused = m_settings.start_paused;
@ -475,18 +472,9 @@ bool HostInterface::LoadState(const char* filename)
else
{
SystemBootParameters boot_params;
boot_params.state_stream = std::move(stream);
if (!BootSystem(boot_params))
{
ReportFormattedError("Failed to boot system to load state from '%s'.", filename);
return false;
}
if (!m_system->LoadState(stream.get()))
{
ReportFormattedError("Failed to load state. The log may contain more information. Shutting down system.");
DestroySystem();
return false;
}
}
m_system->ResetPerformanceCounters();
@ -1219,19 +1207,13 @@ void HostInterface::RecreateSystem()
DestroySystem();
SystemBootParameters boot_params;
boot_params.state_stream = std::move(stream);
if (!BootSystem(boot_params))
{
ReportError("Failed to boot system after recreation.");
return;
}
if (!m_system->LoadState(stream.get()))
{
ReportError("Failed to load state after system recreation. Shutting down.");
DestroySystem();
return;
}
m_system->ResetPerformanceCounters();
PauseSystem(was_paused);
}