VERY experimental Nintendo Switch 2 emulator
C++
Kernel: Remove g_program_id
Yuri Kunde Schlesnera5eba2f98466
diff --git a/src/core/file_sys/archive_savedata.cpp b/src/core/file_sys/archive_savedata.cppindex 12624fa31d..8dff519663 100644--- a/src/core/file_sys/archive_savedata.cpp+++ b/src/core/file_sys/archive_savedata.cpp@@ -11,6 +11,7 @@#include "core/file_sys/archive_savedata.h"#include "core/file_sys/disk_archive.h"+#include "core/hle/kernel/process.h"#include "core/hle/service/fs/archive.h"#include "core/settings.h"@@ -36,7 +37,7 @@ ArchiveFactory_SaveData::ArchiveFactory_SaveData(const std::string& sdmc_directo}ResultVal<std::unique_ptr<ArchiveBackend>> ArchiveFactory_SaveData::Open(const Path& path) {- std::string concrete_mount_point = GetSaveDataPath(mount_point, Kernel::g_program_id);+ std::string concrete_mount_point = GetSaveDataPath(mount_point, Kernel::g_current_process->program_id);if (!FileUtil::Exists(concrete_mount_point)) {// When a SaveData archive is created for the first time, it is not yet formatted// and the save file/directory structure expected by the game has not yet been initialized.@@ -51,7 +52,7 @@ ResultVal<std::unique_ptr<ArchiveBackend>> ArchiveFactory_SaveData::Open(const P}ResultCode ArchiveFactory_SaveData::Format(const Path& path) {- std::string concrete_mount_point = GetSaveDataPath(mount_point, Kernel::g_program_id);+ std::string concrete_mount_point = GetSaveDataPath(mount_point, Kernel::g_current_process->program_id);FileUtil::DeleteDirRecursively(concrete_mount_point);FileUtil::CreateFullPath(concrete_mount_point);return RESULT_SUCCESS;diff --git a/src/core/hle/kernel/kernel.cpp b/src/core/hle/kernel/kernel.cppindex 9c8d6fa367..5157ab2afb 100644--- a/src/core/hle/kernel/kernel.cpp+++ b/src/core/hle/kernel/kernel.cpp@@ -19,7 +19,6 @@ namespace Kernel {unsigned int Object::next_object_id;SharedPtr<Thread> g_main_thread;HandleTable g_handle_table;-u64 g_program_id;void WaitObject::AddWaitingThread(SharedPtr<Thread> thread) {auto itr = std::find(waiting_threads.begin(), waiting_threads.end(), thread);@@ -141,7 +140,6 @@ void Init() {Kernel::TimersInit();Object::next_object_id = 0;- g_program_id = 0;g_main_thread = nullptr;}diff --git a/src/core/hle/kernel/kernel.h b/src/core/hle/kernel/kernel.hindex d0c69677ac..7c106d37c0 100644--- a/src/core/hle/kernel/kernel.h+++ b/src/core/hle/kernel/kernel.h@@ -273,12 +273,6 @@ private:extern HandleTable g_handle_table;-/// The ID code of the currently running game-/// TODO(Subv): This variable should not be here,-/// we need a way to store information about the currently loaded application-/// for later query during runtime, maybe using the LDR service?-extern u64 g_program_id;-/// Initialize the kernelvoid Init();diff --git a/src/core/loader/loader.cpp b/src/core/loader/loader.cppindex 97525fbebe..2718e88c14 100644--- a/src/core/loader/loader.cpp+++ b/src/core/loader/loader.cpp@@ -131,7 +131,6 @@ ResultStatus LoadFile(const std::string& filename) {// Load application and RomFSif (ResultStatus::Success == app_loader.Load()) {- Kernel::g_program_id = app_loader.GetProgramId();Service::FS::RegisterArchiveType(Common::make_unique<FileSys::ArchiveFactory_RomFS>(app_loader), Service::FS::ArchiveIdCode::RomFS);return ResultStatus::Success;}diff --git a/src/core/loader/ncch.cpp b/src/core/loader/ncch.cppindex 5310001378..0e2db2fbbe 100644--- a/src/core/loader/ncch.cpp+++ b/src/core/loader/ncch.cpp@@ -293,8 +293,4 @@ ResultStatus AppLoader_NCCH::ReadRomFS(std::vector<u8>& buffer) const {return ResultStatus::ErrorNotUsed;}-u64 AppLoader_NCCH::GetProgramId() const {- return *reinterpret_cast<u64 const*>(&ncch_header.program_id[0]);-}-} // namespace Loaderdiff --git a/src/core/loader/ncch.h b/src/core/loader/ncch.hindex dec46e86c2..1be941f194 100644--- a/src/core/loader/ncch.h+++ b/src/core/loader/ncch.h@@ -213,12 +213,6 @@ public:*/ResultStatus ReadRomFS(std::vector<u8>& buffer) const override;- /*- * Gets the program id from the NCCH header- * @return u64 Program id- */- u64 GetProgramId() const;-private:/**