mirror of
https://github.com/stenzek/duckstation.git
synced 2024-11-23 05:49:43 +00:00
System: Simplify error path in BootSystem()
This commit is contained in:
parent
b62e58776e
commit
a9bfe2642f
@ -1723,9 +1723,7 @@ bool System::BootSystem(SystemBootParameters parameters, Error* error)
|
|||||||
{
|
{
|
||||||
if (!OpenGPUDump(parameters.filename, error))
|
if (!OpenGPUDump(parameters.filename, error))
|
||||||
{
|
{
|
||||||
s_state = State::Shutdown;
|
DestroySystem();
|
||||||
Host::OnSystemDestroyed();
|
|
||||||
Host::OnIdleStateChanged();
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1750,9 +1748,7 @@ bool System::BootSystem(SystemBootParameters parameters, Error* error)
|
|||||||
if (!disc)
|
if (!disc)
|
||||||
{
|
{
|
||||||
Error::AddPrefixFmt(error, "Failed to open CD image '{}':\n", Path::GetFileName(parameters.filename));
|
Error::AddPrefixFmt(error, "Failed to open CD image '{}':\n", Path::GetFileName(parameters.filename));
|
||||||
s_state = State::Shutdown;
|
DestroySystem();
|
||||||
Host::OnSystemDestroyed();
|
|
||||||
Host::OnIdleStateChanged();
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1798,10 +1794,7 @@ bool System::BootSystem(SystemBootParameters parameters, Error* error)
|
|||||||
{
|
{
|
||||||
Error::AddPrefixFmt(error, "Failed to switch to subimage {} in '{}':\n", parameters.media_playlist_index,
|
Error::AddPrefixFmt(error, "Failed to switch to subimage {} in '{}':\n", parameters.media_playlist_index,
|
||||||
Path::GetFileName(parameters.filename));
|
Path::GetFileName(parameters.filename));
|
||||||
s_state = State::Shutdown;
|
DestroySystem();
|
||||||
s_gpu_dump_player.reset();
|
|
||||||
Host::OnSystemDestroyed();
|
|
||||||
Host::OnIdleStateChanged();
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1815,12 +1808,7 @@ bool System::BootSystem(SystemBootParameters parameters, Error* error)
|
|||||||
{
|
{
|
||||||
Error::SetStringFmt(error, "File '{}' is not a valid executable to boot.",
|
Error::SetStringFmt(error, "File '{}' is not a valid executable to boot.",
|
||||||
Path::GetFileName(parameters.override_exe));
|
Path::GetFileName(parameters.override_exe));
|
||||||
s_state = State::Shutdown;
|
DestroySystem();
|
||||||
s_gpu_dump_player.reset();
|
|
||||||
Cheats::UnloadAll();
|
|
||||||
ClearRunningGame();
|
|
||||||
Host::OnSystemDestroyed();
|
|
||||||
Host::OnIdleStateChanged();
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1832,12 +1820,7 @@ bool System::BootSystem(SystemBootParameters parameters, Error* error)
|
|||||||
// Check for SBI.
|
// Check for SBI.
|
||||||
if (!CheckForSBIFile(disc.get(), error))
|
if (!CheckForSBIFile(disc.get(), error))
|
||||||
{
|
{
|
||||||
s_state = State::Shutdown;
|
DestroySystem();
|
||||||
s_gpu_dump_player.reset();
|
|
||||||
Cheats::UnloadAll();
|
|
||||||
ClearRunningGame();
|
|
||||||
Host::OnSystemDestroyed();
|
|
||||||
Host::OnIdleStateChanged();
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1871,14 +1854,8 @@ bool System::BootSystem(SystemBootParameters parameters, Error* error)
|
|||||||
|
|
||||||
if (cancelled)
|
if (cancelled)
|
||||||
{
|
{
|
||||||
s_state = State::Shutdown;
|
|
||||||
s_gpu_dump_player.reset();
|
|
||||||
Cheats::UnloadAll();
|
|
||||||
ClearRunningGame();
|
|
||||||
Host::OnSystemDestroyed();
|
|
||||||
Host::OnIdleStateChanged();
|
|
||||||
|
|
||||||
// Technically a failure, but user-initiated. Returning false here would try to display a non-existent error.
|
// Technically a failure, but user-initiated. Returning false here would try to display a non-existent error.
|
||||||
|
DestroySystem();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1886,12 +1863,7 @@ bool System::BootSystem(SystemBootParameters parameters, Error* error)
|
|||||||
// Load BIOS image.
|
// Load BIOS image.
|
||||||
if (!SetBootMode(boot_mode, disc_region, error))
|
if (!SetBootMode(boot_mode, disc_region, error))
|
||||||
{
|
{
|
||||||
s_state = State::Shutdown;
|
DestroySystem();
|
||||||
s_gpu_dump_player.reset();
|
|
||||||
Cheats::UnloadAll();
|
|
||||||
ClearRunningGame();
|
|
||||||
Host::OnSystemDestroyed();
|
|
||||||
Host::OnIdleStateChanged();
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1899,13 +1871,7 @@ bool System::BootSystem(SystemBootParameters parameters, Error* error)
|
|||||||
if (!Initialize(parameters.force_software_renderer, parameters.override_fullscreen.value_or(ShouldStartFullscreen()),
|
if (!Initialize(parameters.force_software_renderer, parameters.override_fullscreen.value_or(ShouldStartFullscreen()),
|
||||||
error))
|
error))
|
||||||
{
|
{
|
||||||
s_boot_mode = System::BootMode::None;
|
DestroySystem();
|
||||||
s_state = State::Shutdown;
|
|
||||||
s_gpu_dump_player.reset();
|
|
||||||
Cheats::UnloadAll();
|
|
||||||
ClearRunningGame();
|
|
||||||
Host::OnSystemDestroyed();
|
|
||||||
Host::OnIdleStateChanged();
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2018,11 +1984,7 @@ bool System::Initialize(bool force_software_renderer, bool fullscreen, Error* er
|
|||||||
CPU::Initialize();
|
CPU::Initialize();
|
||||||
|
|
||||||
if (!CreateGPU(force_software_renderer ? GPURenderer::Software : g_settings.gpu_renderer, false, fullscreen, error))
|
if (!CreateGPU(force_software_renderer ? GPURenderer::Software : g_settings.gpu_renderer, false, fullscreen, error))
|
||||||
{
|
|
||||||
CPU::Shutdown();
|
|
||||||
Bus::Shutdown();
|
|
||||||
return false;
|
return false;
|
||||||
}
|
|
||||||
|
|
||||||
GTE::UpdateAspectRatio();
|
GTE::UpdateAspectRatio();
|
||||||
|
|
||||||
@ -2031,16 +1993,7 @@ bool System::Initialize(bool force_software_renderer, bool fullscreen, Error* er
|
|||||||
|
|
||||||
// Was startup cancelled? (e.g. shading compilers took too long and the user closed the application)
|
// Was startup cancelled? (e.g. shading compilers took too long and the user closed the application)
|
||||||
if (IsStartupCancelled())
|
if (IsStartupCancelled())
|
||||||
{
|
|
||||||
g_gpu.reset();
|
|
||||||
if (!s_keep_gpu_device_on_shutdown)
|
|
||||||
Host::ReleaseGPUDevice();
|
|
||||||
if (g_settings.gpu_pgxp_enable)
|
|
||||||
CPU::PGXP::Shutdown();
|
|
||||||
CPU::Shutdown();
|
|
||||||
Bus::Shutdown();
|
|
||||||
return false;
|
return false;
|
||||||
}
|
|
||||||
|
|
||||||
DMA::Initialize();
|
DMA::Initialize();
|
||||||
CDROM::Initialize();
|
CDROM::Initialize();
|
||||||
|
Loading…
Reference in New Issue
Block a user