From a468273221097462032991bad2cca1218c2364b2 Mon Sep 17 00:00:00 2001 From: Zach Hilman Date: Mon, 24 Jun 2019 19:05:50 -0400 Subject: patch_manager: Add getter for title version --- src/core/file_sys/patch_manager.cpp | 10 ++++++++++ src/core/file_sys/patch_manager.h | 6 ++++-- 2 files changed, 14 insertions(+), 2 deletions(-) (limited to 'src/core/file_sys') diff --git a/src/core/file_sys/patch_manager.cpp b/src/core/file_sys/patch_manager.cpp index da823c37b..a8f80e2c6 100644 --- a/src/core/file_sys/patch_manager.cpp +++ b/src/core/file_sys/patch_manager.cpp @@ -493,6 +493,16 @@ std::map> PatchManager::GetPatchVersionNam return out; } +std::optional PatchManager::GetGameVersion() const { + const auto& installed = Core::System::GetInstance().GetContentProvider(); + const auto update_tid = GetUpdateTitleID(title_id); + if (installed.HasEntry(update_tid, ContentRecordType::Program)) { + return installed.GetEntryVersion(update_tid); + } + + return installed.GetEntryVersion(title_id); +} + std::pair, VirtualFile> PatchManager::GetControlMetadata() const { const auto& installed = Core::System::GetInstance().GetContentProvider(); diff --git a/src/core/file_sys/patch_manager.h b/src/core/file_sys/patch_manager.h index 769f8c6f0..f82b4ae1e 100644 --- a/src/core/file_sys/patch_manager.h +++ b/src/core/file_sys/patch_manager.h @@ -66,8 +66,10 @@ public: std::map> GetPatchVersionNames( VirtualFile update_raw = nullptr) const; - // Given title_id of the program, attempts to get the control data of the update and parse it, - // falling back to the base control data. + std::optional GetGameVersion() const; + + // Given title_id of the program, attempts to get the control data of the update and parse + // it, falling back to the base control data. std::pair, VirtualFile> GetControlMetadata() const; // Version of GetControlMetadata that takes an arbitrary NCA -- cgit v1.2.3 From db2e5e5fa6731c02a016ae583732ce1df8fae3b3 Mon Sep 17 00:00:00 2001 From: Zach Hilman Date: Mon, 24 Jun 2019 19:10:17 -0400 Subject: registered_cache: Add getter to determine source slot in content provider union Used to determine StorageId source for application data. --- src/core/file_sys/registered_cache.cpp | 14 ++++++++++++++ src/core/file_sys/registered_cache.h | 3 +++ 2 files changed, 17 insertions(+) (limited to 'src/core/file_sys') diff --git a/src/core/file_sys/registered_cache.cpp b/src/core/file_sys/registered_cache.cpp index 58917e094..3bb921210 100644 --- a/src/core/file_sys/registered_cache.cpp +++ b/src/core/file_sys/registered_cache.cpp @@ -645,6 +645,20 @@ ContentProviderUnion::ListEntriesFilterOrigin(std::optional ContentProviderUnion::GetSlotForEntry( + u64 title_id, ContentRecordType type) const { + for (const auto& [slot, provider] : providers) { + if (provider == nullptr) + continue; + + if (provider->HasEntry(title_id, type)) { + return slot; + } + } + + return std::nullopt; +} + ManualContentProvider::~ManualContentProvider() = default; void ManualContentProvider::AddEntry(TitleType title_type, ContentRecordType content_type, diff --git a/src/core/file_sys/registered_cache.h b/src/core/file_sys/registered_cache.h index ec9052653..4398d63e1 100644 --- a/src/core/file_sys/registered_cache.h +++ b/src/core/file_sys/registered_cache.h @@ -199,6 +199,9 @@ public: std::optional title_type = {}, std::optional record_type = {}, std::optional title_id = {}) const; + std::optional GetSlotForEntry(u64 title_id, + ContentRecordType type) const; + private: std::map providers; }; -- cgit v1.2.3 From d10fc2d7277cf075f875fe2831501cb79c50e21a Mon Sep 17 00:00:00 2001 From: Zach Hilman Date: Tue, 25 Jun 2019 22:25:10 -0400 Subject: glue: Correct missing bytes in ApplicationLaunchParameter --- src/core/file_sys/patch_manager.h | 3 +++ src/core/file_sys/registered_cache.cpp | 14 +++++++------- 2 files changed, 10 insertions(+), 7 deletions(-) (limited to 'src/core/file_sys') diff --git a/src/core/file_sys/patch_manager.h b/src/core/file_sys/patch_manager.h index f82b4ae1e..a363c6577 100644 --- a/src/core/file_sys/patch_manager.h +++ b/src/core/file_sys/patch_manager.h @@ -66,6 +66,9 @@ public: std::map> GetPatchVersionNames( VirtualFile update_raw = nullptr) const; + // If the game update exists, returns the u32 version field in its Meta-type NCA. If that fails, + // it will fallback to the Meta-type NCA of the base game. If that fails, the result will be + // std::nullopt std::optional GetGameVersion() const; // Given title_id of the program, attempts to get the control data of the update and parse diff --git a/src/core/file_sys/registered_cache.cpp b/src/core/file_sys/registered_cache.cpp index 3bb921210..4608490e0 100644 --- a/src/core/file_sys/registered_cache.cpp +++ b/src/core/file_sys/registered_cache.cpp @@ -647,16 +647,16 @@ ContentProviderUnion::ListEntriesFilterOrigin(std::optional ContentProviderUnion::GetSlotForEntry( u64 title_id, ContentRecordType type) const { - for (const auto& [slot, provider] : providers) { - if (provider == nullptr) - continue; + const auto iter = + std::find_if(providers.begin(), providers.end(), [title_id, type](const auto& provider) { + return provider.second != nullptr && provider.second->HasEntry(title_id, type); + }); - if (provider->HasEntry(title_id, type)) { - return slot; - } + if (iter == providers.end()) { + return std::nullopt; } - return std::nullopt; + return iter->first; } ManualContentProvider::~ManualContentProvider() = default; -- cgit v1.2.3