From 1ecb322daa0e2521fe0e179e87889db9aaaf63b0 Mon Sep 17 00:00:00 2001 From: TheKoopaKingdom Date: Wed, 8 Mar 2017 16:28:30 -0500 Subject: Added system for handling core errors in citra-qt. --- src/core/core.cpp | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) (limited to 'src/core/core.cpp') diff --git a/src/core/core.cpp b/src/core/core.cpp index 450e7566d..1861bfa9b 100644 --- a/src/core/core.cpp +++ b/src/core/core.cpp @@ -59,7 +59,7 @@ System::ResultStatus System::RunLoop(int tight_loop) { HW::Update(); Reschedule(); - return ResultStatus::Success; + return GetStatus(); } System::ResultStatus System::SingleStep() { @@ -73,11 +73,21 @@ System::ResultStatus System::Load(EmuWindow* emu_window, const std::string& file LOG_CRITICAL(Core, "Failed to obtain loader for %s!", filepath.c_str()); return ResultStatus::ErrorGetLoader; } + boost::optional system_mode = boost::none; - boost::optional system_mode{app_loader->LoadKernelSystemMode()}; + Loader::ResultStatus load_result{app_loader->LoadKernelSystemMode(system_mode)}; if (!system_mode) { - LOG_CRITICAL(Core, "Failed to determine system mode!"); - return ResultStatus::ErrorSystemMode; + LOG_CRITICAL(Core, "Failed to determine system mode (Error %i)!", load_result); + System::Shutdown(); + + switch (load_result) { + case Loader::ResultStatus::ErrorEncrypted: + return ResultStatus::ErrorLoader_ErrorEncrypted; + case Loader::ResultStatus::ErrorInvalidFormat: + return ResultStatus::ErrorLoader_ErrorInvalidFormat; + default: + return ResultStatus::ErrorSystemMode; + } } ResultStatus init_result{Init(emu_window, system_mode.get())}; @@ -87,7 +97,7 @@ System::ResultStatus System::Load(EmuWindow* emu_window, const std::string& file return init_result; } - const Loader::ResultStatus load_result{app_loader->Load()}; + load_result = app_loader->Load(); if (Loader::ResultStatus::Success != load_result) { LOG_CRITICAL(Core, "Failed to load ROM (Error %i)!", load_result); System::Shutdown(); @@ -101,6 +111,8 @@ System::ResultStatus System::Load(EmuWindow* emu_window, const std::string& file return ResultStatus::ErrorLoader; } } + // this->status will be used for errors while actually running the game + status = ResultStatus::Success; return ResultStatus::Success; } @@ -142,7 +154,7 @@ System::ResultStatus System::Init(EmuWindow* emu_window, u32 system_mode) { GDBStub::Init(); if (!VideoCore::Init(emu_window)) { - return ResultStatus::ErrorVideoCore; + return ResultStatus::ErrorOpenGL; } LOG_DEBUG(Core, "Initialized OK"); -- cgit v1.2.3 From 37bec598ea28662462dcaab65d5abd6db8372dbc Mon Sep 17 00:00:00 2001 From: TheKoopaKingdom Date: Wed, 8 Mar 2017 20:21:31 -0500 Subject: Made some changes from review comments: - Made LoadKernelSystemMode return a pair consisting of a system mode and a result code (Could use review). - Deleted ErrorOpenGL error code in favor of just having ErrorVideoCore. - Made dialog messages more clear. - Compared archive ID in fs_user.cpp to ArchiveIdCode::NCCH as opposed to hex magic. - Cleaned up some other stuff. --- src/core/core.cpp | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) (limited to 'src/core/core.cpp') diff --git a/src/core/core.cpp b/src/core/core.cpp index 1861bfa9b..2a9664cb4 100644 --- a/src/core/core.cpp +++ b/src/core/core.cpp @@ -3,6 +3,9 @@ // Refer to the license.txt file included. #include +#include + +#include #include "audio_core/audio_core.h" #include "common/logging/log.h" @@ -26,6 +29,7 @@ namespace Core { /*static*/ System System::s_instance; System::ResultStatus System::RunLoop(int tight_loop) { + this->status = ResultStatus::Success; if (!cpu_core) { return ResultStatus::ErrorNotInitialized; } @@ -73,14 +77,14 @@ System::ResultStatus System::Load(EmuWindow* emu_window, const std::string& file LOG_CRITICAL(Core, "Failed to obtain loader for %s!", filepath.c_str()); return ResultStatus::ErrorGetLoader; } - boost::optional system_mode = boost::none; + std::pair, Loader::ResultStatus> system_mode = + app_loader->LoadKernelSystemMode(); - Loader::ResultStatus load_result{app_loader->LoadKernelSystemMode(system_mode)}; - if (!system_mode) { - LOG_CRITICAL(Core, "Failed to determine system mode (Error %i)!", load_result); + if (system_mode.second != Loader::ResultStatus::Success) { + LOG_CRITICAL(Core, "Failed to determine system mode (Error %i)!", system_mode.second); System::Shutdown(); - switch (load_result) { + switch (system_mode.second) { case Loader::ResultStatus::ErrorEncrypted: return ResultStatus::ErrorLoader_ErrorEncrypted; case Loader::ResultStatus::ErrorInvalidFormat: @@ -90,15 +94,15 @@ System::ResultStatus System::Load(EmuWindow* emu_window, const std::string& file } } - ResultStatus init_result{Init(emu_window, system_mode.get())}; + ResultStatus init_result{Init(emu_window, system_mode.first.get())}; if (init_result != ResultStatus::Success) { LOG_CRITICAL(Core, "Failed to initialize system (Error %i)!", init_result); System::Shutdown(); return init_result; } - load_result = app_loader->Load(); - if (Loader::ResultStatus::Success != load_result) { + Loader::ResultStatus load_result = app_loader->Load(); + if (load_result != Loader::ResultStatus::Success) { LOG_CRITICAL(Core, "Failed to load ROM (Error %i)!", load_result); System::Shutdown(); @@ -154,7 +158,7 @@ System::ResultStatus System::Init(EmuWindow* emu_window, u32 system_mode) { GDBStub::Init(); if (!VideoCore::Init(emu_window)) { - return ResultStatus::ErrorOpenGL; + return ResultStatus::ErrorVideoCore; } LOG_DEBUG(Core, "Initialized OK"); -- cgit v1.2.3 From a8aef599e02e336f9ecb8d5cfc50aa856ea0a1c7 Mon Sep 17 00:00:00 2001 From: TheKoopaKingdom Date: Thu, 13 Apr 2017 01:18:54 -0400 Subject: Created a whitelist of system archives to prevent false positives creating dialogs. --- src/core/core.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'src/core/core.cpp') diff --git a/src/core/core.cpp b/src/core/core.cpp index 2a9664cb4..2456d8aa2 100644 --- a/src/core/core.cpp +++ b/src/core/core.cpp @@ -4,9 +4,6 @@ #include #include - -#include - #include "audio_core/audio_core.h" #include "common/logging/log.h" #include "core/arm/arm_interface.h" @@ -81,7 +78,8 @@ System::ResultStatus System::Load(EmuWindow* emu_window, const std::string& file app_loader->LoadKernelSystemMode(); if (system_mode.second != Loader::ResultStatus::Success) { - LOG_CRITICAL(Core, "Failed to determine system mode (Error %i)!", system_mode.second); + LOG_CRITICAL(Core, "Failed to determine system mode (Error %i)!", + static_cast(system_mode.second)); System::Shutdown(); switch (system_mode.second) { -- cgit v1.2.3 From f008b22e3b2baa7720ea65c320fe49929a53bad7 Mon Sep 17 00:00:00 2001 From: TheKoopaKingdom Date: Fri, 2 Jun 2017 17:03:38 -0400 Subject: Addressed Bunnei's review comments, and made some other tweaks: - Deleted GetStatus() because it wasn't used anywhere outside of Core::System. - Fixed design flaw where the message bar status could be set despite the game being stopped. --- src/core/core.cpp | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'src/core/core.cpp') diff --git a/src/core/core.cpp b/src/core/core.cpp index 2456d8aa2..5429bcb26 100644 --- a/src/core/core.cpp +++ b/src/core/core.cpp @@ -26,7 +26,7 @@ namespace Core { /*static*/ System System::s_instance; System::ResultStatus System::RunLoop(int tight_loop) { - this->status = ResultStatus::Success; + status = ResultStatus::Success; if (!cpu_core) { return ResultStatus::ErrorNotInitialized; } @@ -60,7 +60,7 @@ System::ResultStatus System::RunLoop(int tight_loop) { HW::Update(); Reschedule(); - return GetStatus(); + return status; } System::ResultStatus System::SingleStep() { @@ -99,8 +99,8 @@ System::ResultStatus System::Load(EmuWindow* emu_window, const std::string& file return init_result; } - Loader::ResultStatus load_result = app_loader->Load(); - if (load_result != Loader::ResultStatus::Success) { + const Loader::ResultStatus load_result{app_loader->Load()}; + if (Loader::ResultStatus::Success != load_result) { LOG_CRITICAL(Core, "Failed to load ROM (Error %i)!", load_result); System::Shutdown(); @@ -113,9 +113,8 @@ System::ResultStatus System::Load(EmuWindow* emu_window, const std::string& file return ResultStatus::ErrorLoader; } } - // this->status will be used for errors while actually running the game status = ResultStatus::Success; - return ResultStatus::Success; + return status; } void System::PrepareReschedule() { -- cgit v1.2.3