clean up the code for update checks, had unnecessary checks for multi update entries
This commit is contained in:
parent
ffd4de289d
commit
367835e7bd
|
|
@ -152,7 +152,7 @@ VirtualDir PatchManager::PatchExeFS(VirtualDir exefs) const {
|
|||
if (external_provider) {
|
||||
const auto update_versions = external_provider->ListUpdateVersions(update_tid);
|
||||
|
||||
if (update_versions.size() > 1) {
|
||||
if (!update_versions.empty()) {
|
||||
checked_external = true;
|
||||
for (const auto& update_entry : update_versions) {
|
||||
std::string disabled_key = fmt::format("Update@{}", update_entry.version);
|
||||
|
|
@ -162,12 +162,6 @@ VirtualDir PatchManager::PatchExeFS(VirtualDir exefs) const {
|
|||
break;
|
||||
}
|
||||
}
|
||||
} else if (update_versions.size() == 1) {
|
||||
checked_external = true;
|
||||
if (std::find(disabled.cbegin(), disabled.cend(), "Update") == disabled.cend()) {
|
||||
update_disabled = false;
|
||||
enabled_version = update_versions[0].version;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -178,7 +172,7 @@ VirtualDir PatchManager::PatchExeFS(VirtualDir exefs) const {
|
|||
if (manual_provider) {
|
||||
const auto manual_update_versions = manual_provider->ListUpdateVersions(update_tid);
|
||||
|
||||
if (manual_update_versions.size() > 1) {
|
||||
if (!manual_update_versions.empty()) {
|
||||
checked_manual = true;
|
||||
for (const auto& update_entry : manual_update_versions) {
|
||||
std::string disabled_key = fmt::format("Update@{}", update_entry.version);
|
||||
|
|
@ -188,12 +182,6 @@ VirtualDir PatchManager::PatchExeFS(VirtualDir exefs) const {
|
|||
break;
|
||||
}
|
||||
}
|
||||
} else if (manual_update_versions.size() == 1) {
|
||||
checked_manual = true;
|
||||
if (std::find(disabled.cbegin(), disabled.cend(), "Update") == disabled.cend()) {
|
||||
update_disabled = false;
|
||||
enabled_version = manual_update_versions[0].version;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -562,7 +550,7 @@ VirtualFile PatchManager::PatchRomFS(const NCA* base_nca, VirtualFile base_romfs
|
|||
if (external_provider) {
|
||||
const auto update_versions = external_provider->ListUpdateVersions(update_tid);
|
||||
|
||||
if (update_versions.size() > 1) {
|
||||
if (!update_versions.empty()) {
|
||||
checked_external = true;
|
||||
for (const auto& update_entry : update_versions) {
|
||||
std::string disabled_key = fmt::format("Update@{}", update_entry.version);
|
||||
|
|
@ -573,13 +561,6 @@ VirtualFile PatchManager::PatchRomFS(const NCA* base_nca, VirtualFile base_romfs
|
|||
break;
|
||||
}
|
||||
}
|
||||
} else if (update_versions.size() == 1) {
|
||||
checked_external = true;
|
||||
if (std::find(disabled.cbegin(), disabled.cend(), "Update") == disabled.cend()) {
|
||||
update_disabled = false;
|
||||
enabled_version = update_versions[0].version;
|
||||
update_raw = external_provider->GetEntryForVersion(update_tid, type, update_versions[0].version);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -589,7 +570,7 @@ VirtualFile PatchManager::PatchRomFS(const NCA* base_nca, VirtualFile base_romfs
|
|||
if (manual_provider) {
|
||||
const auto manual_update_versions = manual_provider->ListUpdateVersions(update_tid);
|
||||
|
||||
if (manual_update_versions.size() > 1) {
|
||||
if (!manual_update_versions.empty()) {
|
||||
checked_manual = true;
|
||||
for (const auto& update_entry : manual_update_versions) {
|
||||
std::string disabled_key = fmt::format("Update@{}", update_entry.version);
|
||||
|
|
@ -600,13 +581,6 @@ VirtualFile PatchManager::PatchRomFS(const NCA* base_nca, VirtualFile base_romfs
|
|||
break;
|
||||
}
|
||||
}
|
||||
} else if (manual_update_versions.size() == 1) {
|
||||
checked_manual = true;
|
||||
if (std::find(disabled.cbegin(), disabled.cend(), "Update") == disabled.cend()) {
|
||||
update_disabled = false;
|
||||
enabled_version = manual_update_versions[0].version;
|
||||
update_raw = manual_provider->GetEntryForVersion(update_tid, type, manual_update_versions[0].version);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -660,6 +634,8 @@ std::vector<Patch> PatchManager::GetPatches(VirtualFile update_raw) const {
|
|||
// Game Updates
|
||||
const auto update_tid = GetUpdateTitleID(title_id);
|
||||
|
||||
std::vector<Patch> external_update_patches;
|
||||
|
||||
const auto* content_union = dynamic_cast<const ContentProviderUnion*>(&content_provider);
|
||||
|
||||
if (content_union) {
|
||||
|
|
@ -668,48 +644,15 @@ std::vector<Patch> PatchManager::GetPatches(VirtualFile update_raw) const {
|
|||
if (external_provider) {
|
||||
const auto update_versions = external_provider->ListUpdateVersions(update_tid);
|
||||
|
||||
if (update_versions.size() > 1) {
|
||||
for (const auto& update_entry : update_versions) {
|
||||
std::string version_str = update_entry.version_string;
|
||||
if (version_str.empty()) {
|
||||
version_str = FormatTitleVersion(update_entry.version);
|
||||
}
|
||||
|
||||
std::string patch_name = "Update";
|
||||
|
||||
std::string disabled_key = fmt::format("Update@{}", update_entry.version);
|
||||
const auto update_disabled =
|
||||
std::find(disabled.cbegin(), disabled.cend(), disabled_key) != disabled.cend();
|
||||
|
||||
Patch update_patch = {.enabled = !update_disabled,
|
||||
.name = patch_name,
|
||||
.version = version_str,
|
||||
.type = PatchType::Update,
|
||||
.program_id = title_id,
|
||||
.title_id = update_tid,
|
||||
.source = PatchSource::External,
|
||||
.numeric_version = update_entry.version};
|
||||
|
||||
out.push_back(update_patch);
|
||||
}
|
||||
} else if (update_versions.size() == 1) {
|
||||
const auto& update_entry = update_versions[0];
|
||||
|
||||
for (const auto& update_entry : update_versions) {
|
||||
std::string version_str = update_entry.version_string;
|
||||
|
||||
if (version_str.empty()) {
|
||||
const auto metadata = GetControlMetadata();
|
||||
if (metadata.first) {
|
||||
version_str = metadata.first->GetVersionString();
|
||||
}
|
||||
}
|
||||
|
||||
if (version_str.empty()) {
|
||||
version_str = FormatTitleVersion(update_entry.version);
|
||||
}
|
||||
|
||||
std::string disabled_key = fmt::format("Update@{}", update_entry.version);
|
||||
const auto update_disabled =
|
||||
std::find(disabled.cbegin(), disabled.cend(), "Update") != disabled.cend();
|
||||
std::find(disabled.cbegin(), disabled.cend(), disabled_key) != disabled.cend();
|
||||
|
||||
Patch update_patch = {.enabled = !update_disabled,
|
||||
.name = "Update",
|
||||
|
|
@ -720,57 +663,25 @@ std::vector<Patch> PatchManager::GetPatches(VirtualFile update_raw) const {
|
|||
.source = PatchSource::External,
|
||||
.numeric_version = update_entry.version};
|
||||
|
||||
out.push_back(update_patch);
|
||||
external_update_patches.push_back(update_patch);
|
||||
}
|
||||
}
|
||||
|
||||
const auto* manual_provider = dynamic_cast<const ManualContentProvider*>(
|
||||
content_union->GetSlotProvider(ContentProviderUnionSlot::FrontendManual));
|
||||
if (manual_provider && out.empty()) {
|
||||
if (manual_provider && external_update_patches.empty()) {
|
||||
const auto manual_update_versions = manual_provider->ListUpdateVersions(update_tid);
|
||||
|
||||
if (manual_update_versions.size() > 1) {
|
||||
for (const auto& update_entry : manual_update_versions) {
|
||||
std::string version_str = update_entry.version_string;
|
||||
if (version_str.empty()) {
|
||||
version_str = FormatTitleVersion(update_entry.version);
|
||||
}
|
||||
|
||||
std::string patch_name = "Update";
|
||||
|
||||
std::string disabled_key = fmt::format("Update@{}", update_entry.version);
|
||||
const auto update_disabled =
|
||||
std::find(disabled.cbegin(), disabled.cend(), disabled_key) != disabled.cend();
|
||||
|
||||
Patch update_patch = {.enabled = !update_disabled,
|
||||
.name = patch_name,
|
||||
.version = version_str,
|
||||
.type = PatchType::Update,
|
||||
.program_id = title_id,
|
||||
.title_id = update_tid,
|
||||
.source = PatchSource::External,
|
||||
.numeric_version = update_entry.version};
|
||||
|
||||
out.push_back(update_patch);
|
||||
}
|
||||
} else if (manual_update_versions.size() == 1) {
|
||||
const auto& update_entry = manual_update_versions[0];
|
||||
|
||||
for (const auto& update_entry : manual_update_versions) {
|
||||
std::string version_str = update_entry.version_string;
|
||||
|
||||
if (version_str.empty()) {
|
||||
const auto metadata = GetControlMetadata();
|
||||
if (metadata.first) {
|
||||
version_str = metadata.first->GetVersionString();
|
||||
}
|
||||
}
|
||||
|
||||
if (version_str.empty()) {
|
||||
version_str = FormatTitleVersion(update_entry.version);
|
||||
}
|
||||
|
||||
std::string disabled_key = fmt::format("Update@{}", update_entry.version);
|
||||
const auto update_disabled =
|
||||
std::find(disabled.cbegin(), disabled.cend(), "Update") != disabled.cend();
|
||||
std::find(disabled.cbegin(), disabled.cend(), disabled_key) != disabled.cend();
|
||||
|
||||
|
||||
Patch update_patch = {.enabled = !update_disabled,
|
||||
.name = "Update",
|
||||
|
|
@ -781,10 +692,27 @@ std::vector<Patch> PatchManager::GetPatches(VirtualFile update_raw) const {
|
|||
.source = PatchSource::External,
|
||||
.numeric_version = update_entry.version};
|
||||
|
||||
out.push_back(update_patch);
|
||||
external_update_patches.push_back(update_patch);
|
||||
}
|
||||
}
|
||||
|
||||
if (external_update_patches.size() > 1) {
|
||||
bool found_enabled = false;
|
||||
for (auto& patch : external_update_patches) {
|
||||
if (patch.enabled) {
|
||||
if (found_enabled) {
|
||||
patch.enabled = false;
|
||||
} else {
|
||||
found_enabled = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (auto& patch : external_update_patches) {
|
||||
out.push_back(std::move(patch));
|
||||
}
|
||||
|
||||
const auto all_updates = content_union->ListEntriesFilterOrigin(
|
||||
std::nullopt, std::nullopt, ContentRecordType::Program, update_tid);
|
||||
|
||||
|
|
|
|||
|
|
@ -160,28 +160,7 @@ void ConfigurePerGameAddons::LoadConfiguration() {
|
|||
|
||||
std::vector<FileSys::Patch> patches = pm.GetPatches(update_raw);
|
||||
|
||||
size_t multi_version_update_count = 0;
|
||||
for (const auto& patch : patches) {
|
||||
if (patch.type == FileSys::PatchType::Update && patch.numeric_version != 0) {
|
||||
multi_version_update_count++;
|
||||
}
|
||||
}
|
||||
|
||||
bool has_saved_multi_version_settings = false;
|
||||
if (multi_version_update_count > 1) {
|
||||
for (const auto& patch : patches) {
|
||||
if (patch.type == FileSys::PatchType::Update && patch.numeric_version != 0) {
|
||||
std::string disabled_key = fmt::format("Update@{}", patch.numeric_version);
|
||||
if (std::find(disabled.begin(), disabled.end(), disabled_key) != disabled.end()) {
|
||||
has_saved_multi_version_settings = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool has_enabled_update = false;
|
||||
bool is_first_multi_version_update = true;
|
||||
|
||||
for (const auto& patch : patches) {
|
||||
const auto name = QString::fromStdString(patch.name);
|
||||
|
|
@ -195,14 +174,9 @@ void ConfigurePerGameAddons::LoadConfiguration() {
|
|||
}
|
||||
|
||||
bool patch_disabled = false;
|
||||
if (patch.type == FileSys::PatchType::Update && patch.numeric_version != 0 && multi_version_update_count > 1) {
|
||||
if (has_saved_multi_version_settings) {
|
||||
std::string disabled_key = fmt::format("Update@{}", patch.numeric_version);
|
||||
patch_disabled = std::find(disabled.begin(), disabled.end(), disabled_key) != disabled.end();
|
||||
} else {
|
||||
patch_disabled = !is_first_multi_version_update;
|
||||
}
|
||||
is_first_multi_version_update = false;
|
||||
if (patch.type == FileSys::PatchType::Update && patch.numeric_version != 0) {
|
||||
std::string disabled_key = fmt::format("Update@{}", patch.numeric_version);
|
||||
patch_disabled = std::find(disabled.begin(), disabled.end(), disabled_key) != disabled.end();
|
||||
} else {
|
||||
patch_disabled = std::find(disabled.begin(), disabled.end(), name.toStdString()) != disabled.end();
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue