VERY experimental Nintendo Switch 2 emulator
C++
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.
TheKoopaKingdome0f8f75f43ab
diff --git a/src/citra_qt/main.cpp b/src/citra_qt/main.cppindex c899e075fd..4f5b2ddabc 100644--- a/src/citra_qt/main.cpp+++ b/src/citra_qt/main.cpp@@ -663,10 +663,11 @@ void GMainWindow::OnCoreError(Core::System::ResultStatus result, std::string detswitch (result) {case Core::System::ResultStatus::ErrorSystemFiles: {QString message = "Citra was unable to locate a 3DS system archive";- if (details != std::string())+ if (!details.empty()) {message.append(tr(": %1. ").arg(details.c_str()));- else+ } else {message.append(". ");+ }message.append(common_message);answer = QMessageBox::question(this, tr("System Archive Not Found"), message,@@ -698,11 +699,15 @@ void GMainWindow::OnCoreError(Core::System::ResultStatus result, std::string det}if (answer == QMessageBox::Yes) {- if (emu_thread != nullptr)+ if (emu_thread) {ShutdownGame();+ }} else {- message_label->setText(status_message);- message_label->setVisible(true);+ // Only show the message if the game is still running.+ if (emu_thread) {+ message_label->setText(status_message);+ message_label->setVisible(true);+ }}}diff --git a/src/core/core.cpp b/src/core/core.cppindex 2456d8aa2b..5429bcb268 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& filereturn 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& filereturn ResultStatus::ErrorLoader;}}- // this->status will be used for errors while actually running the gamestatus = ResultStatus::Success;- return ResultStatus::Success;+ return status;}void System::PrepareReschedule() {diff --git a/src/core/core.h b/src/core/core.hindex 6e555f9545..4e3b6b4092 100644--- a/src/core/core.h+++ b/src/core/core.h@@ -108,16 +108,14 @@ public:PerfStats perf_stats;FrameLimiter frame_limiter;- ResultStatus GetStatus() {- return status;- }-- void SetStatus(ResultStatus new_status, std::string details = std::string()) {+ void SetStatus(ResultStatus new_status, const char* details = nullptr) {status = new_status;- status_details = details;+ if (details) {+ status_details = details;+ }}- std::string GetStatusDetails() {+ const std::string& GetStatusDetails() const {return status_details;}@@ -147,8 +145,8 @@ private:static System s_instance;- ResultStatus status;- std::string status_details;+ ResultStatus status = ResultStatus::Success;+ std::string status_details = "";};inline ARM_Interface& CPU() {diff --git a/src/core/file_sys/archive_ncch.cpp b/src/core/file_sys/archive_ncch.cppindex ad59c053e9..6d90077313 100644--- a/src/core/file_sys/archive_ncch.cpp+++ b/src/core/file_sys/archive_ncch.cpp@@ -42,13 +42,13 @@ ResultVal<std::unique_ptr<ArchiveBackend>> ArchiveFactory_NCCH::Open(const Path&if (!file->IsOpen()) {// High Title ID of the archive: The category (https://3dbrew.org/wiki/Title_list).- const u32 shared_data_archive = 0x0004009B;- const u32 system_data_archive = 0x000400DB;+ constexpr u32 shared_data_archive = 0x0004009B;+ constexpr u32 system_data_archive = 0x000400DB;// Low Title IDs.- const u32 mii_data = 0x00010202;- const u32 region_manifest = 0x00010402;- const u32 ng_word_list = 0x00010302;+ constexpr u32 mii_data = 0x00010202;+ constexpr u32 region_manifest = 0x00010402;+ constexpr u32 ng_word_list = 0x00010302;LOG_DEBUG(Service_FS, "Full Path: %s. Category: 0x%X. Path: 0x%X.", path.DebugStr().c_str(),high, low);@@ -60,7 +60,7 @@ ResultVal<std::unique_ptr<ArchiveBackend>> ArchiveFactory_NCCH::Open(const Path&"Mii data");} else if (low == region_manifest) {LOG_ERROR(Service_FS,- "Failed to get a handle for shared data archive: region manifes");+ "Failed to get a handle for shared data archive: region manifest.");Core::System::GetInstance().SetStatus(Core::System::ResultStatus::ErrorSystemFiles,"Region manifest");}diff --git a/src/core/hle/service/fs/archive.cpp b/src/core/hle/service/fs/archive.cppindex 40d52f54b9..21929e966b 100644--- a/src/core/hle/service/fs/archive.cpp+++ b/src/core/hle/service/fs/archive.cpp@@ -257,8 +257,9 @@ ResultVal<ArchiveHandle> OpenArchive(ArchiveIdCode id_code, FileSys::Path& archiLOG_TRACE(Service_FS, "Opening archive with id code 0x%08X", id_code);auto itr = id_code_map.find(id_code);- if (itr == id_code_map.end())+ if (itr == id_code_map.end()) {return FileSys::ERROR_NOT_FOUND;+ }CASCADE_RESULT(std::unique_ptr<ArchiveBackend> res, itr->second->Open(archive_path));diff --git a/src/core/loader/loader.h b/src/core/loader/loader.hindex adb3ffdcfd..48bbf687dd 100644--- a/src/core/loader/loader.h+++ b/src/core/loader/loader.h@@ -101,7 +101,7 @@ public:* Loads the system mode that this application needs.* This function defaults to 2 (96MB allocated to the application) if it can't read the* information.- * @returns a pair of Optional with the kernel system mode and ResultStatus.+ * @returns A pair with the optional system mode, and and the status.*/virtual std::pair<boost::optional<u32>, ResultStatus> LoadKernelSystemMode() {// 96MB allocated to the application.diff --git a/src/core/loader/ncch.h b/src/core/loader/ncch.hindex 507da75506..0ebd47fd5c 100644--- a/src/core/loader/ncch.h+++ b/src/core/loader/ncch.h@@ -179,7 +179,7 @@ public:/*** Loads the Exheader and returns the system mode for this application.- * @returns a pair of Optional with the kernel system mode and ResultStatus+ * @returns A pair with the optional system mode, and and the status.*/std::pair<boost::optional<u32>, ResultStatus> LoadKernelSystemMode() override;