yuzu-emu
/
yuzu
Archived
1
0
Fork 0

patch_manager: Add DLC recognition to PatchManager

This commit is contained in:
Zach Hilman 2018-09-26 22:15:05 -04:00
parent 8f2ad3a66d
commit 32fc31fb13
2 changed files with 27 additions and 0 deletions

View File

@ -18,6 +18,7 @@
namespace FileSys {
constexpr u64 SINGLE_BYTE_MODULUS = 0x100;
constexpr u64 DLC_BASE_TITLE_ID_MASK = 0xFFFFFFFFFFFFE000;
std::string FormatTitleVersion(u32 version, TitleVersionFormat format) {
std::array<u8, sizeof(u32)> bytes{};
@ -35,6 +36,7 @@ std::string FormatTitleVersion(u32 version, TitleVersionFormat format) {
constexpr std::array<const char*, 2> PATCH_TYPE_NAMES{
"Update",
"LayeredFS",
"DLC",
};
std::string FormatPatchTypeName(PatchType type) {
@ -139,6 +141,7 @@ std::map<PatchType, std::string> PatchManager::GetPatchVersionNames() const {
std::map<PatchType, std::string> out;
const auto installed = Service::FileSystem::GetUnionContents();
// Update
const auto update_tid = GetUpdateTitleID(title_id);
PatchManager update{update_tid};
auto [nacp, discard_icon_file] = update.GetControlMetadata();
@ -161,6 +164,29 @@ std::map<PatchType, std::string> PatchManager::GetPatchVersionNames() const {
if (lfs_dir != nullptr && lfs_dir->GetSize() > 0)
out.insert_or_assign(PatchType::LayeredFS, "");
// DLC
const auto dlc_entries = installed->ListEntriesFilter(TitleType::AOC, ContentRecordType::Data);
std::vector<RegisteredCacheEntry> 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;
});
if (!dlc_match.empty()) {
// Ensure sorted so DLC IDs show in order.
std::sort(dlc_match.begin(), dlc_match.end());
std::string list;
for (size_t i = 0; i < dlc_match.size() - 1; ++i)
list += fmt::format("{}, ", dlc_match[i].title_id & 0x7FF);
list += fmt::format("{}", dlc_match.back().title_id & 0x7FF);
out[PatchType::DLC] = list;
}
return out;
}

View File

@ -27,6 +27,7 @@ std::string FormatTitleVersion(u32 version,
enum class PatchType {
Update,
LayeredFS,
DLC,
};
std::string FormatPatchTypeName(PatchType type);