diff options
Diffstat (limited to 'src/core/file_sys')
| -rw-r--r-- | src/core/file_sys/patch_manager.cpp | 56 | ||||
| -rw-r--r-- | src/core/file_sys/patch_manager.h | 5 |
2 files changed, 50 insertions, 11 deletions
diff --git a/src/core/file_sys/patch_manager.cpp b/src/core/file_sys/patch_manager.cpp index 6b14e08be..ecdc21c87 100644 --- a/src/core/file_sys/patch_manager.cpp +++ b/src/core/file_sys/patch_manager.cpp | |||
| @@ -56,6 +56,10 @@ PatchManager::PatchManager(u64 title_id) : title_id(title_id) {} | |||
| 56 | 56 | ||
| 57 | PatchManager::~PatchManager() = default; | 57 | PatchManager::~PatchManager() = default; |
| 58 | 58 | ||
| 59 | u64 PatchManager::GetTitleID() const { | ||
| 60 | return title_id; | ||
| 61 | } | ||
| 62 | |||
| 59 | VirtualDir PatchManager::PatchExeFS(VirtualDir exefs) const { | 63 | VirtualDir PatchManager::PatchExeFS(VirtualDir exefs) const { |
| 60 | LOG_INFO(Loader, "Patching ExeFS for title_id={:016X}", title_id); | 64 | LOG_INFO(Loader, "Patching ExeFS for title_id={:016X}", title_id); |
| 61 | 65 | ||
| @@ -73,11 +77,15 @@ VirtualDir PatchManager::PatchExeFS(VirtualDir exefs) const { | |||
| 73 | 77 | ||
| 74 | const auto installed = Service::FileSystem::GetUnionContents(); | 78 | const auto installed = Service::FileSystem::GetUnionContents(); |
| 75 | 79 | ||
| 80 | const auto& disabled = Settings::values.disabled_addons[title_id]; | ||
| 81 | const auto update_disabled = | ||
| 82 | std::find(disabled.begin(), disabled.end(), "Update") != disabled.end(); | ||
| 83 | |||
| 76 | // Game Updates | 84 | // Game Updates |
| 77 | const auto update_tid = GetUpdateTitleID(title_id); | 85 | const auto update_tid = GetUpdateTitleID(title_id); |
| 78 | const auto update = installed.GetEntry(update_tid, ContentRecordType::Program); | 86 | const auto update = installed.GetEntry(update_tid, ContentRecordType::Program); |
| 79 | 87 | ||
| 80 | if (update != nullptr && update->GetExeFS() != nullptr && | 88 | if (!update_disabled && update != nullptr && update->GetExeFS() != nullptr && |
| 81 | update->GetStatus() == Loader::ResultStatus::ErrorMissingBKTRBaseRomFS) { | 89 | update->GetStatus() == Loader::ResultStatus::ErrorMissingBKTRBaseRomFS) { |
| 82 | LOG_INFO(Loader, " ExeFS: Update ({}) applied successfully", | 90 | LOG_INFO(Loader, " ExeFS: Update ({}) applied successfully", |
| 83 | FormatTitleVersion(installed.GetEntryVersion(update_tid).value_or(0))); | 91 | FormatTitleVersion(installed.GetEntryVersion(update_tid).value_or(0))); |
| @@ -95,6 +103,9 @@ VirtualDir PatchManager::PatchExeFS(VirtualDir exefs) const { | |||
| 95 | std::vector<VirtualDir> layers; | 103 | std::vector<VirtualDir> layers; |
| 96 | layers.reserve(patch_dirs.size() + 1); | 104 | layers.reserve(patch_dirs.size() + 1); |
| 97 | for (const auto& subdir : patch_dirs) { | 105 | for (const auto& subdir : patch_dirs) { |
| 106 | if (std::find(disabled.begin(), disabled.end(), subdir->GetName()) != disabled.end()) | ||
| 107 | continue; | ||
| 108 | |||
| 98 | auto exefs_dir = subdir->GetSubdirectory("exefs"); | 109 | auto exefs_dir = subdir->GetSubdirectory("exefs"); |
| 99 | if (exefs_dir != nullptr) | 110 | if (exefs_dir != nullptr) |
| 100 | layers.push_back(std::move(exefs_dir)); | 111 | layers.push_back(std::move(exefs_dir)); |
| @@ -111,11 +122,16 @@ VirtualDir PatchManager::PatchExeFS(VirtualDir exefs) const { | |||
| 111 | return exefs; | 122 | return exefs; |
| 112 | } | 123 | } |
| 113 | 124 | ||
| 114 | static std::vector<VirtualFile> CollectPatches(const std::vector<VirtualDir>& patch_dirs, | 125 | std::vector<VirtualFile> PatchManager::CollectPatches(const std::vector<VirtualDir>& patch_dirs, |
| 115 | const std::string& build_id) { | 126 | const std::string& build_id) const { |
| 127 | const auto& disabled = Settings::values.disabled_addons[title_id]; | ||
| 128 | |||
| 116 | std::vector<VirtualFile> out; | 129 | std::vector<VirtualFile> out; |
| 117 | out.reserve(patch_dirs.size()); | 130 | out.reserve(patch_dirs.size()); |
| 118 | for (const auto& subdir : patch_dirs) { | 131 | for (const auto& subdir : patch_dirs) { |
| 132 | if (std::find(disabled.begin(), disabled.end(), subdir->GetName()) != disabled.end()) | ||
| 133 | continue; | ||
| 134 | |||
| 119 | auto exefs_dir = subdir->GetSubdirectory("exefs"); | 135 | auto exefs_dir = subdir->GetSubdirectory("exefs"); |
| 120 | if (exefs_dir != nullptr) { | 136 | if (exefs_dir != nullptr) { |
| 121 | for (const auto& file : exefs_dir->GetFiles()) { | 137 | for (const auto& file : exefs_dir->GetFiles()) { |
| @@ -228,6 +244,7 @@ static void ApplyLayeredFS(VirtualFile& romfs, u64 title_id, ContentRecordType t | |||
| 228 | return; | 244 | return; |
| 229 | } | 245 | } |
| 230 | 246 | ||
| 247 | const auto& disabled = Settings::values.disabled_addons[title_id]; | ||
| 231 | auto patch_dirs = load_dir->GetSubdirectories(); | 248 | auto patch_dirs = load_dir->GetSubdirectories(); |
| 232 | std::sort(patch_dirs.begin(), patch_dirs.end(), | 249 | std::sort(patch_dirs.begin(), patch_dirs.end(), |
| 233 | [](const VirtualDir& l, const VirtualDir& r) { return l->GetName() < r->GetName(); }); | 250 | [](const VirtualDir& l, const VirtualDir& r) { return l->GetName() < r->GetName(); }); |
| @@ -237,6 +254,9 @@ static void ApplyLayeredFS(VirtualFile& romfs, u64 title_id, ContentRecordType t | |||
| 237 | layers.reserve(patch_dirs.size() + 1); | 254 | layers.reserve(patch_dirs.size() + 1); |
| 238 | layers_ext.reserve(patch_dirs.size() + 1); | 255 | layers_ext.reserve(patch_dirs.size() + 1); |
| 239 | for (const auto& subdir : patch_dirs) { | 256 | for (const auto& subdir : patch_dirs) { |
| 257 | if (std::find(disabled.begin(), disabled.end(), subdir->GetName()) != disabled.end()) | ||
| 258 | continue; | ||
| 259 | |||
| 240 | auto romfs_dir = subdir->GetSubdirectory("romfs"); | 260 | auto romfs_dir = subdir->GetSubdirectory("romfs"); |
| 241 | if (romfs_dir != nullptr) | 261 | if (romfs_dir != nullptr) |
| 242 | layers.push_back(std::move(romfs_dir)); | 262 | layers.push_back(std::move(romfs_dir)); |
| @@ -282,7 +302,12 @@ VirtualFile PatchManager::PatchRomFS(VirtualFile romfs, u64 ivfc_offset, Content | |||
| 282 | // Game Updates | 302 | // Game Updates |
| 283 | const auto update_tid = GetUpdateTitleID(title_id); | 303 | const auto update_tid = GetUpdateTitleID(title_id); |
| 284 | const auto update = installed.GetEntryRaw(update_tid, type); | 304 | const auto update = installed.GetEntryRaw(update_tid, type); |
| 285 | if (update != nullptr) { | 305 | |
| 306 | const auto& disabled = Settings::values.disabled_addons[title_id]; | ||
| 307 | const auto update_disabled = | ||
| 308 | std::find(disabled.begin(), disabled.end(), "Update") != disabled.end(); | ||
| 309 | |||
| 310 | if (!update_disabled && update != nullptr) { | ||
| 286 | const auto new_nca = std::make_shared<NCA>(update, romfs, ivfc_offset); | 311 | const auto new_nca = std::make_shared<NCA>(update, romfs, ivfc_offset); |
| 287 | if (new_nca->GetStatus() == Loader::ResultStatus::Success && | 312 | if (new_nca->GetStatus() == Loader::ResultStatus::Success && |
| 288 | new_nca->GetRomFS() != nullptr) { | 313 | new_nca->GetRomFS() != nullptr) { |
| @@ -290,7 +315,7 @@ VirtualFile PatchManager::PatchRomFS(VirtualFile romfs, u64 ivfc_offset, Content | |||
| 290 | FormatTitleVersion(installed.GetEntryVersion(update_tid).value_or(0))); | 315 | FormatTitleVersion(installed.GetEntryVersion(update_tid).value_or(0))); |
| 291 | romfs = new_nca->GetRomFS(); | 316 | romfs = new_nca->GetRomFS(); |
| 292 | } | 317 | } |
| 293 | } else if (update_raw != nullptr) { | 318 | } else if (!update_disabled && update_raw != nullptr) { |
| 294 | const auto new_nca = std::make_shared<NCA>(update_raw, romfs, ivfc_offset); | 319 | const auto new_nca = std::make_shared<NCA>(update_raw, romfs, ivfc_offset); |
| 295 | if (new_nca->GetStatus() == Loader::ResultStatus::Success && | 320 | if (new_nca->GetStatus() == Loader::ResultStatus::Success && |
| 296 | new_nca->GetRomFS() != nullptr) { | 321 | new_nca->GetRomFS() != nullptr) { |
| @@ -320,25 +345,30 @@ std::map<std::string, std::string, std::less<>> PatchManager::GetPatchVersionNam | |||
| 320 | VirtualFile update_raw) const { | 345 | VirtualFile update_raw) const { |
| 321 | std::map<std::string, std::string, std::less<>> out; | 346 | std::map<std::string, std::string, std::less<>> out; |
| 322 | const auto installed = Service::FileSystem::GetUnionContents(); | 347 | const auto installed = Service::FileSystem::GetUnionContents(); |
| 348 | const auto& disabled = Settings::values.disabled_addons[title_id]; | ||
| 323 | 349 | ||
| 324 | // Game Updates | 350 | // Game Updates |
| 325 | const auto update_tid = GetUpdateTitleID(title_id); | 351 | const auto update_tid = GetUpdateTitleID(title_id); |
| 326 | PatchManager update{update_tid}; | 352 | PatchManager update{update_tid}; |
| 327 | auto [nacp, discard_icon_file] = update.GetControlMetadata(); | 353 | auto [nacp, discard_icon_file] = update.GetControlMetadata(); |
| 328 | 354 | ||
| 355 | const auto update_disabled = | ||
| 356 | std::find(disabled.begin(), disabled.end(), "Update") != disabled.end(); | ||
| 357 | const auto update_label = update_disabled ? "[D] Update" : "Update"; | ||
| 358 | |||
| 329 | if (nacp != nullptr) { | 359 | if (nacp != nullptr) { |
| 330 | out.insert_or_assign("Update", nacp->GetVersionString()); | 360 | out.insert_or_assign(update_label, nacp->GetVersionString()); |
| 331 | } else { | 361 | } else { |
| 332 | if (installed.HasEntry(update_tid, ContentRecordType::Program)) { | 362 | if (installed.HasEntry(update_tid, ContentRecordType::Program)) { |
| 333 | const auto meta_ver = installed.GetEntryVersion(update_tid); | 363 | const auto meta_ver = installed.GetEntryVersion(update_tid); |
| 334 | if (meta_ver.value_or(0) == 0) { | 364 | if (meta_ver.value_or(0) == 0) { |
| 335 | out.insert_or_assign("Update", ""); | 365 | out.insert_or_assign(update_label, ""); |
| 336 | } else { | 366 | } else { |
| 337 | out.insert_or_assign( | 367 | out.insert_or_assign( |
| 338 | "Update", FormatTitleVersion(*meta_ver, TitleVersionFormat::ThreeElements)); | 368 | update_label, FormatTitleVersion(*meta_ver, TitleVersionFormat::ThreeElements)); |
| 339 | } | 369 | } |
| 340 | } else if (update_raw != nullptr) { | 370 | } else if (update_raw != nullptr) { |
| 341 | out.insert_or_assign("Update", "PACKED"); | 371 | out.insert_or_assign(update_label, "PACKED"); |
| 342 | } | 372 | } |
| 343 | } | 373 | } |
| 344 | 374 | ||
| @@ -378,7 +408,9 @@ std::map<std::string, std::string, std::less<>> PatchManager::GetPatchVersionNam | |||
| 378 | if (types.empty()) | 408 | if (types.empty()) |
| 379 | continue; | 409 | continue; |
| 380 | 410 | ||
| 381 | out.insert_or_assign(mod->GetName(), types); | 411 | const auto mod_disabled = |
| 412 | std::find(disabled.begin(), disabled.end(), mod->GetName()) != disabled.end(); | ||
| 413 | out.insert_or_assign(mod_disabled ? "[D] " + mod->GetName() : mod->GetName(), types); | ||
| 382 | } | 414 | } |
| 383 | } | 415 | } |
| 384 | 416 | ||
| @@ -401,7 +433,9 @@ std::map<std::string, std::string, std::less<>> PatchManager::GetPatchVersionNam | |||
| 401 | 433 | ||
| 402 | list += fmt::format("{}", dlc_match.back().title_id & 0x7FF); | 434 | list += fmt::format("{}", dlc_match.back().title_id & 0x7FF); |
| 403 | 435 | ||
| 404 | out.insert_or_assign("DLC", std::move(list)); | 436 | const auto dlc_disabled = |
| 437 | std::find(disabled.begin(), disabled.end(), "DLC") != disabled.end(); | ||
| 438 | out.insert_or_assign(dlc_disabled ? "[D] DLC" : "DLC", std::move(list)); | ||
| 405 | } | 439 | } |
| 406 | 440 | ||
| 407 | return out; | 441 | return out; |
diff --git a/src/core/file_sys/patch_manager.h b/src/core/file_sys/patch_manager.h index 7d168837f..b8a1652fd 100644 --- a/src/core/file_sys/patch_manager.h +++ b/src/core/file_sys/patch_manager.h | |||
| @@ -30,6 +30,8 @@ public: | |||
| 30 | explicit PatchManager(u64 title_id); | 30 | explicit PatchManager(u64 title_id); |
| 31 | ~PatchManager(); | 31 | ~PatchManager(); |
| 32 | 32 | ||
| 33 | u64 GetTitleID() const; | ||
| 34 | |||
| 33 | // Currently tracked ExeFS patches: | 35 | // Currently tracked ExeFS patches: |
| 34 | // - Game Updates | 36 | // - Game Updates |
| 35 | VirtualDir PatchExeFS(VirtualDir exefs) const; | 37 | VirtualDir PatchExeFS(VirtualDir exefs) const; |
| @@ -63,6 +65,9 @@ public: | |||
| 63 | std::pair<std::unique_ptr<NACP>, VirtualFile> ParseControlNCA(const NCA& nca) const; | 65 | std::pair<std::unique_ptr<NACP>, VirtualFile> ParseControlNCA(const NCA& nca) const; |
| 64 | 66 | ||
| 65 | private: | 67 | private: |
| 68 | std::vector<VirtualFile> CollectPatches(const std::vector<VirtualDir>& patch_dirs, | ||
| 69 | const std::string& build_id) const; | ||
| 70 | |||
| 66 | u64 title_id; | 71 | u64 title_id; |
| 67 | }; | 72 | }; |
| 68 | 73 | ||