summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbunnei <bunneidev@gmail.com>2018-10-10 04:29:39 +0200
committerGitHub <noreply@github.com>2018-10-10 04:29:39 +0200
commit3ac874c32ebba99c5d1402ea6b82277e7f303b93 (patch)
treefa616d3b0c8846a143916261f74278d6509233d4
parentMerge pull request #1466 from lioncash/unused (diff)
parentpatch_manager: Return a std::unique_ptr from ParseControlNCA() and GetControlMetadata() instead of a std::shared_ptr (diff)
downloadyuzu-3ac874c32ebba99c5d1402ea6b82277e7f303b93.tar
yuzu-3ac874c32ebba99c5d1402ea6b82277e7f303b93.tar.gz
yuzu-3ac874c32ebba99c5d1402ea6b82277e7f303b93.tar.bz2
yuzu-3ac874c32ebba99c5d1402ea6b82277e7f303b93.tar.lz
yuzu-3ac874c32ebba99c5d1402ea6b82277e7f303b93.tar.xz
yuzu-3ac874c32ebba99c5d1402ea6b82277e7f303b93.tar.zst
yuzu-3ac874c32ebba99c5d1402ea6b82277e7f303b93.zip
-rw-r--r--src/core/file_sys/patch_manager.cpp15
-rw-r--r--src/core/file_sys/patch_manager.h5
-rw-r--r--src/core/loader/nsp.cpp2
-rw-r--r--src/core/loader/nsp.h2
-rw-r--r--src/core/loader/xci.cpp2
-rw-r--r--src/core/loader/xci.h2
-rw-r--r--src/yuzu/game_list_worker.cpp11
7 files changed, 18 insertions, 21 deletions
diff --git a/src/core/file_sys/patch_manager.cpp b/src/core/file_sys/patch_manager.cpp
index b14d7cb0a..019caebe9 100644
--- a/src/core/file_sys/patch_manager.cpp
+++ b/src/core/file_sys/patch_manager.cpp
@@ -345,23 +345,22 @@ std::map<std::string, std::string, std::less<>> PatchManager::GetPatchVersionNam
return out;
}
-std::pair<std::shared_ptr<NACP>, VirtualFile> PatchManager::GetControlMetadata() const {
+std::pair<std::unique_ptr<NACP>, VirtualFile> PatchManager::GetControlMetadata() const {
const auto& installed{Service::FileSystem::GetUnionContents()};
const auto base_control_nca = installed->GetEntry(title_id, ContentRecordType::Control);
if (base_control_nca == nullptr)
return {};
- return ParseControlNCA(base_control_nca);
+ return ParseControlNCA(*base_control_nca);
}
-std::pair<std::shared_ptr<NACP>, VirtualFile> PatchManager::ParseControlNCA(
- const std::shared_ptr<NCA>& nca) const {
- const auto base_romfs = nca->GetRomFS();
+std::pair<std::unique_ptr<NACP>, VirtualFile> PatchManager::ParseControlNCA(const NCA& nca) const {
+ const auto base_romfs = nca.GetRomFS();
if (base_romfs == nullptr)
return {};
- const auto romfs = PatchRomFS(base_romfs, nca->GetBaseIVFCOffset(), ContentRecordType::Control);
+ const auto romfs = PatchRomFS(base_romfs, nca.GetBaseIVFCOffset(), ContentRecordType::Control);
if (romfs == nullptr)
return {};
@@ -373,7 +372,7 @@ std::pair<std::shared_ptr<NACP>, VirtualFile> PatchManager::ParseControlNCA(
if (nacp_file == nullptr)
nacp_file = extracted->GetFile("Control.nacp");
- const auto nacp = nacp_file == nullptr ? nullptr : std::make_shared<NACP>(nacp_file);
+ auto nacp = nacp_file == nullptr ? nullptr : std::make_unique<NACP>(nacp_file);
VirtualFile icon_file;
for (const auto& language : FileSys::LANGUAGE_NAMES) {
@@ -382,6 +381,6 @@ std::pair<std::shared_ptr<NACP>, VirtualFile> PatchManager::ParseControlNCA(
break;
}
- return {nacp, icon_file};
+ return {std::move(nacp), icon_file};
}
} // namespace FileSys
diff --git a/src/core/file_sys/patch_manager.h b/src/core/file_sys/patch_manager.h
index eb6fc4607..7d168837f 100644
--- a/src/core/file_sys/patch_manager.h
+++ b/src/core/file_sys/patch_manager.h
@@ -57,11 +57,10 @@ public:
// 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<std::shared_ptr<NACP>, VirtualFile> GetControlMetadata() const;
+ std::pair<std::unique_ptr<NACP>, VirtualFile> GetControlMetadata() const;
// Version of GetControlMetadata that takes an arbitrary NCA
- std::pair<std::shared_ptr<NACP>, VirtualFile> ParseControlNCA(
- const std::shared_ptr<NCA>& nca) const;
+ std::pair<std::unique_ptr<NACP>, VirtualFile> ParseControlNCA(const NCA& nca) const;
private:
u64 title_id;
diff --git a/src/core/loader/nsp.cpp b/src/core/loader/nsp.cpp
index 5534ce01c..13e57848d 100644
--- a/src/core/loader/nsp.cpp
+++ b/src/core/loader/nsp.cpp
@@ -35,7 +35,7 @@ AppLoader_NSP::AppLoader_NSP(FileSys::VirtualFile file)
return;
std::tie(nacp_file, icon_file) =
- FileSys::PatchManager(nsp->GetProgramTitleID()).ParseControlNCA(control_nca);
+ FileSys::PatchManager(nsp->GetProgramTitleID()).ParseControlNCA(*control_nca);
}
AppLoader_NSP::~AppLoader_NSP() = default;
diff --git a/src/core/loader/nsp.h b/src/core/loader/nsp.h
index b006594a6..db91cd01e 100644
--- a/src/core/loader/nsp.h
+++ b/src/core/loader/nsp.h
@@ -49,7 +49,7 @@ private:
std::unique_ptr<AppLoader> secondary_loader;
FileSys::VirtualFile icon_file;
- std::shared_ptr<FileSys::NACP> nacp_file;
+ std::unique_ptr<FileSys::NACP> nacp_file;
u64 title_id;
};
diff --git a/src/core/loader/xci.cpp b/src/core/loader/xci.cpp
index ee5452eb9..7a619acb4 100644
--- a/src/core/loader/xci.cpp
+++ b/src/core/loader/xci.cpp
@@ -30,7 +30,7 @@ AppLoader_XCI::AppLoader_XCI(FileSys::VirtualFile file)
return;
std::tie(nacp_file, icon_file) =
- FileSys::PatchManager(xci->GetProgramTitleID()).ParseControlNCA(control_nca);
+ FileSys::PatchManager(xci->GetProgramTitleID()).ParseControlNCA(*control_nca);
}
AppLoader_XCI::~AppLoader_XCI() = default;
diff --git a/src/core/loader/xci.h b/src/core/loader/xci.h
index 770ed1437..46f8dfc9e 100644
--- a/src/core/loader/xci.h
+++ b/src/core/loader/xci.h
@@ -49,7 +49,7 @@ private:
std::unique_ptr<AppLoader_NCA> nca_loader;
FileSys::VirtualFile icon_file;
- std::shared_ptr<FileSys::NACP> nacp_file;
+ std::unique_ptr<FileSys::NACP> nacp_file;
};
} // namespace Loader
diff --git a/src/yuzu/game_list_worker.cpp b/src/yuzu/game_list_worker.cpp
index d2b3de683..8f99a1c78 100644
--- a/src/yuzu/game_list_worker.cpp
+++ b/src/yuzu/game_list_worker.cpp
@@ -27,9 +27,8 @@
#include "yuzu/ui_settings.h"
namespace {
-void GetMetadataFromControlNCA(const FileSys::PatchManager& patch_manager,
- const std::shared_ptr<FileSys::NCA>& nca, std::vector<u8>& icon,
- std::string& name) {
+void GetMetadataFromControlNCA(const FileSys::PatchManager& patch_manager, const FileSys::NCA& nca,
+ std::vector<u8>& icon, std::string& name) {
auto [nacp, icon_file] = patch_manager.ParseControlNCA(nca);
if (icon_file != nullptr)
icon = icon_file->ReadAllBytes();
@@ -110,7 +109,7 @@ void GameListWorker::AddInstalledTitlesToGameList() {
const FileSys::PatchManager patch{program_id};
const auto& control = cache->GetEntry(game.title_id, FileSys::ContentRecordType::Control);
if (control != nullptr)
- GetMetadataFromControlNCA(patch, control, icon, name);
+ GetMetadataFromControlNCA(patch, *control, icon, name);
auto it = FindMatchingCompatibilityEntry(compatibility_list, program_id);
@@ -197,8 +196,8 @@ void GameListWorker::AddFstEntriesToGameList(const std::string& dir_path, unsign
res2 == Loader::ResultStatus::Success) {
// Use from metadata pool.
if (nca_control_map.find(program_id) != nca_control_map.end()) {
- const auto nca = nca_control_map[program_id];
- GetMetadataFromControlNCA(patch, nca, icon, name);
+ const auto& nca = nca_control_map[program_id];
+ GetMetadataFromControlNCA(patch, *nca, icon, name);
}
}