diff options
Diffstat (limited to 'src/yuzu/main.cpp')
-rw-r--r-- | src/yuzu/main.cpp | 56 |
1 files changed, 50 insertions, 6 deletions
diff --git a/src/yuzu/main.cpp b/src/yuzu/main.cpp index 97ae9e49a..8e933af64 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); @@ -2535,8 +2573,8 @@ void GMainWindow::OnGameListDumpRomFS(u64 program_id, const std::string& game_pa return; } - FileSys::VirtualFile file; - if (loader->ReadRomFS(file) != Loader::ResultStatus::Success) { + FileSys::VirtualFile base_romfs; + if (loader->ReadRomFS(base_romfs) != Loader::ResultStatus::Success) { failed(); return; } @@ -2549,6 +2587,14 @@ void GMainWindow::OnGameListDumpRomFS(u64 program_id, const std::string& game_pa return; } + const auto type = *romfs_title_id == program_id ? FileSys::ContentRecordType::Program + : FileSys::ContentRecordType::Data; + const auto base_nca = installed.GetEntry(*romfs_title_id, type); + if (!base_nca) { + failed(); + return; + } + const auto dump_dir = target == DumpRomFSTarget::Normal ? Common::FS::GetYuzuPath(Common::FS::YuzuPath::DumpDir) @@ -2560,12 +2606,10 @@ void GMainWindow::OnGameListDumpRomFS(u64 program_id, const std::string& game_pa FileSys::VirtualFile romfs; if (*romfs_title_id == program_id) { - const u64 ivfc_offset = loader->ReadRomFSIVFCOffset(); const FileSys::PatchManager pm{program_id, system->GetFileSystemController(), installed}; - romfs = - pm.PatchRomFS(file, ivfc_offset, FileSys::ContentRecordType::Program, nullptr, false); + romfs = pm.PatchRomFS(base_nca.get(), base_romfs, type, nullptr, false); } else { - romfs = installed.GetEntry(*romfs_title_id, FileSys::ContentRecordType::Data)->GetRomFS(); + romfs = installed.GetEntry(*romfs_title_id, type)->GetRomFS(); } const auto extracted = FileSys::ExtractRomFS(romfs, FileSys::RomFSExtractionType::Full); |