diff options
author | FearlessTobi <thm.frey@gmail.com> | 2023-08-24 18:45:57 +0200 |
---|---|---|
committer | FearlessTobi <thm.frey@gmail.com> | 2023-08-24 18:48:02 +0200 |
commit | 59b3c30f9428aecbfe69f0fa80d5ed5c6744f0db (patch) | |
tree | 431137e5e9ac978b0a604700b757c4fed327178c /src/yuzu/main.cpp | |
parent | 7d89f2c1460b121bad14da5d1c7e13cc24e20527 (diff) |
yuzu/main: Ensure NCAs are registered in content provider when launching from CLI
Fixes updates and DLC not being loaded when launching yuzu from the command line.
Similar to https://github.com/yuzu-emu/yuzu/pull/11357.
Fixes https://github.com/yuzu-emu/yuzu/issues/8352,
Diffstat (limited to 'src/yuzu/main.cpp')
-rw-r--r-- | src/yuzu/main.cpp | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/src/yuzu/main.cpp b/src/yuzu/main.cpp index a9d035f3dd..8e933af648 100644 --- a/src/yuzu/main.cpp +++ b/src/yuzu/main.cpp @@ -1811,6 +1811,43 @@ bool GMainWindow::SelectAndSetCurrentUser( return true; } +void GMainWindow::ConfigureFilesystemProvider(const std::string& filepath) { + // Ensure all NCAs are registered before launching the game + const auto file = vfs->OpenFile(filepath, FileSys::Mode::Read); + if (!file) { + return; + } + + auto loader = Loader::GetLoader(*system, file); + if (!loader) { + return; + } + + const auto file_type = loader->GetFileType(); + if (file_type == Loader::FileType::Unknown || file_type == Loader::FileType::Error) { + return; + } + + u64 program_id = 0; + const auto res2 = loader->ReadProgramId(program_id); + if (res2 == Loader::ResultStatus::Success && file_type == Loader::FileType::NCA) { + provider->AddEntry(FileSys::TitleType::Application, + FileSys::GetCRTypeFromNCAType(FileSys::NCA{file}.GetType()), program_id, + file); + } else if (res2 == Loader::ResultStatus::Success && + (file_type == Loader::FileType::XCI || file_type == Loader::FileType::NSP)) { + const auto nsp = file_type == Loader::FileType::NSP + ? std::make_shared<FileSys::NSP>(file) + : FileSys::XCI{file}.GetSecurePartitionNSP(); + for (const auto& title : nsp->GetNCAs()) { + for (const auto& entry : title.second) { + provider->AddEntry(entry.first.first, entry.first.second, title.first, + entry.second->GetBaseFile()); + } + } + } +} + void GMainWindow::BootGame(const QString& filename, u64 program_id, std::size_t program_index, StartGameType type) { LOG_INFO(Frontend, "yuzu starting..."); @@ -1825,6 +1862,7 @@ void GMainWindow::BootGame(const QString& filename, u64 program_id, std::size_t last_filename_booted = filename; + ConfigureFilesystemProvider(filename.toStdString()); const auto v_file = Core::GetGameFileFromPath(vfs, filename.toUtf8().constData()); const auto loader = Loader::GetLoader(*system, v_file, program_id, program_index); |