mirror of
https://git.suyu.dev/suyu/suyu.git
synced 2024-11-29 18:22:47 +01:00
patch_manager: Add DLC recognition to PatchManager
This commit is contained in:
parent
8f2ad3a66d
commit
32fc31fb13
2 changed files with 27 additions and 0 deletions
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -27,6 +27,7 @@ std::string FormatTitleVersion(u32 version,
|
|||
enum class PatchType {
|
||||
Update,
|
||||
LayeredFS,
|
||||
DLC,
|
||||
};
|
||||
|
||||
std::string FormatPatchTypeName(PatchType type);
|
||||
|
|
Loading…
Reference in a new issue