From e15039372ea63efb37cdaa70833b2d080931ee3c Mon Sep 17 00:00:00 2001 From: Morph <39850852+Morph1984@users.noreply.github.com> Date: Thu, 3 Dec 2020 22:57:28 -0500 Subject: fsp_srv: Implement OpenDataStorageWithProgramIndex - Used by RollerCoaster Tycoon 3: Complete Edition --- src/core/file_sys/romfs_factory.cpp | 22 ++++++++++++++++++++++ src/core/file_sys/romfs_factory.h | 4 ++++ 2 files changed, 26 insertions(+) (limited to 'src/core/file_sys') diff --git a/src/core/file_sys/romfs_factory.cpp b/src/core/file_sys/romfs_factory.cpp index 987199747..f4e16e4be 100644 --- a/src/core/file_sys/romfs_factory.cpp +++ b/src/core/file_sys/romfs_factory.cpp @@ -7,6 +7,7 @@ #include "common/common_types.h" #include "common/logging/log.h" #include "core/file_sys/card_image.h" +#include "core/file_sys/common_funcs.h" #include "core/file_sys/content_archive.h" #include "core/file_sys/nca_metadata.h" #include "core/file_sys/patch_manager.h" @@ -47,6 +48,27 @@ ResultVal RomFSFactory::OpenCurrentProcess(u64 current_process_titl patch_manager.PatchRomFS(file, ivfc_offset, ContentRecordType::Program, update_raw)); } +ResultVal RomFSFactory::OpenPatchedRomFS(u64 title_id, ContentRecordType type) const { + auto nca = content_provider.GetEntry(title_id, type); + + if (nca == nullptr) { + // TODO: Find the right error code to use here + return RESULT_UNKNOWN; + } + + const PatchManager patch_manager{title_id, filesystem_controller, content_provider}; + + return MakeResult( + patch_manager.PatchRomFS(nca->GetRomFS(), nca->GetBaseIVFCOffset(), type)); +} + +ResultVal RomFSFactory::OpenPatchedRomFSWithProgramIndex( + u64 title_id, u8 program_index, ContentRecordType type) const { + const auto res_title_id = GetBaseTitleIDWithProgramIndex(title_id, program_index); + + return OpenPatchedRomFS(res_title_id, type); +} + ResultVal RomFSFactory::Open(u64 title_id, StorageId storage, ContentRecordType type) const { const std::shared_ptr res = GetEntry(title_id, storage, type); diff --git a/src/core/file_sys/romfs_factory.h b/src/core/file_sys/romfs_factory.h index ec704dfa8..96dd0d578 100644 --- a/src/core/file_sys/romfs_factory.h +++ b/src/core/file_sys/romfs_factory.h @@ -42,6 +42,10 @@ public: void SetPackedUpdate(VirtualFile update_raw); [[nodiscard]] ResultVal OpenCurrentProcess(u64 current_process_title_id) const; + [[nodiscard]] ResultVal OpenPatchedRomFS(u64 title_id, + ContentRecordType type) const; + [[nodiscard]] ResultVal OpenPatchedRomFSWithProgramIndex( + u64 title_id, u8 program_index, ContentRecordType type) const; [[nodiscard]] ResultVal Open(u64 title_id, StorageId storage, ContentRecordType type) const; -- cgit v1.2.3