From db4523f1ece642475d58f8764863c8930a0812e3 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Sat, 1 Dec 2018 20:32:38 -0500 Subject: filesystem: De-globalize registered_cache_union We can just return a new instance of this when it's requested. This only ever holds pointers to the existing registed caches, so it's not a large object. Plus, this also gets rid of the need to keep around a separate member function just to properly clear out the union. Gets rid of one of five globals in the filesystem code. --- src/core/file_sys/patch_manager.cpp | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) (limited to 'src/core/file_sys/patch_manager.cpp') diff --git a/src/core/file_sys/patch_manager.cpp b/src/core/file_sys/patch_manager.cpp index e8df08724..6b14e08be 100644 --- a/src/core/file_sys/patch_manager.cpp +++ b/src/core/file_sys/patch_manager.cpp @@ -75,12 +75,12 @@ VirtualDir PatchManager::PatchExeFS(VirtualDir exefs) const { // Game Updates const auto update_tid = GetUpdateTitleID(title_id); - const auto update = installed->GetEntry(update_tid, ContentRecordType::Program); + const auto update = installed.GetEntry(update_tid, ContentRecordType::Program); if (update != nullptr && update->GetExeFS() != nullptr && update->GetStatus() == Loader::ResultStatus::ErrorMissingBKTRBaseRomFS) { LOG_INFO(Loader, " ExeFS: Update ({}) applied successfully", - FormatTitleVersion(installed->GetEntryVersion(update_tid).value_or(0))); + FormatTitleVersion(installed.GetEntryVersion(update_tid).value_or(0))); exefs = update->GetExeFS(); } @@ -281,13 +281,13 @@ VirtualFile PatchManager::PatchRomFS(VirtualFile romfs, u64 ivfc_offset, Content // Game Updates const auto update_tid = GetUpdateTitleID(title_id); - const auto update = installed->GetEntryRaw(update_tid, type); + const auto update = installed.GetEntryRaw(update_tid, type); if (update != nullptr) { const auto new_nca = std::make_shared(update, romfs, ivfc_offset); if (new_nca->GetStatus() == Loader::ResultStatus::Success && new_nca->GetRomFS() != nullptr) { LOG_INFO(Loader, " RomFS: Update ({}) applied successfully", - FormatTitleVersion(installed->GetEntryVersion(update_tid).value_or(0))); + FormatTitleVersion(installed.GetEntryVersion(update_tid).value_or(0))); romfs = new_nca->GetRomFS(); } } else if (update_raw != nullptr) { @@ -329,8 +329,8 @@ std::map> PatchManager::GetPatchVersionNam if (nacp != nullptr) { out.insert_or_assign("Update", nacp->GetVersionString()); } else { - if (installed->HasEntry(update_tid, ContentRecordType::Program)) { - const auto meta_ver = installed->GetEntryVersion(update_tid); + if (installed.HasEntry(update_tid, ContentRecordType::Program)) { + const auto meta_ver = installed.GetEntryVersion(update_tid); if (meta_ver.value_or(0) == 0) { out.insert_or_assign("Update", ""); } else { @@ -383,14 +383,13 @@ std::map> PatchManager::GetPatchVersionNam } // DLC - const auto dlc_entries = installed->ListEntriesFilter(TitleType::AOC, ContentRecordType::Data); + const auto dlc_entries = installed.ListEntriesFilter(TitleType::AOC, ContentRecordType::Data); std::vector dlc_match; dlc_match.reserve(dlc_entries.size()); std::copy_if(dlc_entries.begin(), dlc_entries.end(), std::back_inserter(dlc_match), [this, &installed](const RegisteredCacheEntry& entry) { return (entry.title_id & DLC_BASE_TITLE_ID_MASK) == title_id && - installed->GetEntry(entry)->GetStatus() == - Loader::ResultStatus::Success; + installed.GetEntry(entry)->GetStatus() == Loader::ResultStatus::Success; }); if (!dlc_match.empty()) { // Ensure sorted so DLC IDs show in order. @@ -411,7 +410,7 @@ std::map> PatchManager::GetPatchVersionNam std::pair, VirtualFile> PatchManager::GetControlMetadata() const { const auto installed{Service::FileSystem::GetUnionContents()}; - const auto base_control_nca = installed->GetEntry(title_id, ContentRecordType::Control); + const auto base_control_nca = installed.GetEntry(title_id, ContentRecordType::Control); if (base_control_nca == nullptr) return {}; -- cgit v1.2.3