diff options
| author | 2018-09-26 22:15:05 -0400 | |
|---|---|---|
| committer | 2018-09-30 21:01:35 -0400 | |
| commit | 32fc31fb13d4381dc4b2124df4f13cbcbde7fb8b (patch) | |
| tree | da85deeafc220fa40ae5b42bc3ac6fff2a9a5a3a /src | |
| parent | Merge pull request #1338 from raven02/service_vi (diff) | |
| download | yuzu-32fc31fb13d4381dc4b2124df4f13cbcbde7fb8b.tar.gz yuzu-32fc31fb13d4381dc4b2124df4f13cbcbde7fb8b.tar.xz yuzu-32fc31fb13d4381dc4b2124df4f13cbcbde7fb8b.zip | |
patch_manager: Add DLC recognition to PatchManager
Diffstat (limited to '')
| -rw-r--r-- | src/core/file_sys/patch_manager.cpp | 26 | ||||
| -rw-r--r-- | src/core/file_sys/patch_manager.h | 1 |
2 files changed, 27 insertions, 0 deletions
diff --git a/src/core/file_sys/patch_manager.cpp b/src/core/file_sys/patch_manager.cpp index 4b3b5e665..5ac2b987e 100644 --- a/src/core/file_sys/patch_manager.cpp +++ b/src/core/file_sys/patch_manager.cpp | |||
| @@ -18,6 +18,7 @@ | |||
| 18 | namespace FileSys { | 18 | namespace FileSys { |
| 19 | 19 | ||
| 20 | constexpr u64 SINGLE_BYTE_MODULUS = 0x100; | 20 | constexpr u64 SINGLE_BYTE_MODULUS = 0x100; |
| 21 | constexpr u64 DLC_BASE_TITLE_ID_MASK = 0xFFFFFFFFFFFFE000; | ||
| 21 | 22 | ||
| 22 | std::string FormatTitleVersion(u32 version, TitleVersionFormat format) { | 23 | std::string FormatTitleVersion(u32 version, TitleVersionFormat format) { |
| 23 | std::array<u8, sizeof(u32)> bytes{}; | 24 | std::array<u8, sizeof(u32)> bytes{}; |
| @@ -35,6 +36,7 @@ std::string FormatTitleVersion(u32 version, TitleVersionFormat format) { | |||
| 35 | constexpr std::array<const char*, 2> PATCH_TYPE_NAMES{ | 36 | constexpr std::array<const char*, 2> PATCH_TYPE_NAMES{ |
| 36 | "Update", | 37 | "Update", |
| 37 | "LayeredFS", | 38 | "LayeredFS", |
| 39 | "DLC", | ||
| 38 | }; | 40 | }; |
| 39 | 41 | ||
| 40 | std::string FormatPatchTypeName(PatchType type) { | 42 | std::string FormatPatchTypeName(PatchType type) { |
| @@ -139,6 +141,7 @@ std::map<PatchType, std::string> PatchManager::GetPatchVersionNames() const { | |||
| 139 | std::map<PatchType, std::string> out; | 141 | std::map<PatchType, std::string> out; |
| 140 | const auto installed = Service::FileSystem::GetUnionContents(); | 142 | const auto installed = Service::FileSystem::GetUnionContents(); |
| 141 | 143 | ||
| 144 | // Update | ||
| 142 | const auto update_tid = GetUpdateTitleID(title_id); | 145 | const auto update_tid = GetUpdateTitleID(title_id); |
| 143 | PatchManager update{update_tid}; | 146 | PatchManager update{update_tid}; |
| 144 | auto [nacp, discard_icon_file] = update.GetControlMetadata(); | 147 | auto [nacp, discard_icon_file] = update.GetControlMetadata(); |
| @@ -161,6 +164,29 @@ std::map<PatchType, std::string> PatchManager::GetPatchVersionNames() const { | |||
| 161 | if (lfs_dir != nullptr && lfs_dir->GetSize() > 0) | 164 | if (lfs_dir != nullptr && lfs_dir->GetSize() > 0) |
| 162 | out.insert_or_assign(PatchType::LayeredFS, ""); | 165 | out.insert_or_assign(PatchType::LayeredFS, ""); |
| 163 | 166 | ||
| 167 | // DLC | ||
| 168 | const auto dlc_entries = installed->ListEntriesFilter(TitleType::AOC, ContentRecordType::Data); | ||
| 169 | std::vector<RegisteredCacheEntry> dlc_match; | ||
| 170 | dlc_match.reserve(dlc_entries.size()); | ||
| 171 | std::copy_if(dlc_entries.begin(), dlc_entries.end(), std::back_inserter(dlc_match), | ||
| 172 | [this, &installed](const RegisteredCacheEntry& entry) { | ||
| 173 | return (entry.title_id & DLC_BASE_TITLE_ID_MASK) == title_id && | ||
| 174 | installed->GetEntry(entry)->GetStatus() == | ||
| 175 | Loader::ResultStatus::Success; | ||
| 176 | }); | ||
| 177 | if (!dlc_match.empty()) { | ||
| 178 | // Ensure sorted so DLC IDs show in order. | ||
| 179 | std::sort(dlc_match.begin(), dlc_match.end()); | ||
| 180 | |||
| 181 | std::string list; | ||
| 182 | for (size_t i = 0; i < dlc_match.size() - 1; ++i) | ||
| 183 | list += fmt::format("{}, ", dlc_match[i].title_id & 0x7FF); | ||
| 184 | |||
| 185 | list += fmt::format("{}", dlc_match.back().title_id & 0x7FF); | ||
| 186 | |||
| 187 | out[PatchType::DLC] = list; | ||
| 188 | } | ||
| 189 | |||
| 164 | return out; | 190 | return out; |
| 165 | } | 191 | } |
| 166 | 192 | ||
diff --git a/src/core/file_sys/patch_manager.h b/src/core/file_sys/patch_manager.h index 464f17515..3a2a9d212 100644 --- a/src/core/file_sys/patch_manager.h +++ b/src/core/file_sys/patch_manager.h | |||
| @@ -27,6 +27,7 @@ std::string FormatTitleVersion(u32 version, | |||
| 27 | enum class PatchType { | 27 | enum class PatchType { |
| 28 | Update, | 28 | Update, |
| 29 | LayeredFS, | 29 | LayeredFS, |
| 30 | DLC, | ||
| 30 | }; | 31 | }; |
| 31 | 32 | ||
| 32 | std::string FormatPatchTypeName(PatchType type); | 33 | std::string FormatPatchTypeName(PatchType type); |