From e0242a46543a798e4ed3d58f70c8abea16309034 Mon Sep 17 00:00:00 2001 From: Morph <39850852+Morph1984@users.noreply.github.com> Date: Thu, 28 Nov 2019 01:17:17 -0500 Subject: [PATCH] patch_manager: Adds check for disabled cheats to prevent them from being enabled (#3178) * Adds check for disabled cheats to prevent them from being added to the CheatList * Address feedback --- src/core/file_sys/patch_manager.cpp | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/core/file_sys/patch_manager.cpp b/src/core/file_sys/patch_manager.cpp index df0ecb15c5..e226e9711f 100644 --- a/src/core/file_sys/patch_manager.cpp +++ b/src/core/file_sys/patch_manager.cpp @@ -76,7 +76,7 @@ VirtualDir PatchManager::PatchExeFS(VirtualDir exefs) const { const auto& disabled = Settings::values.disabled_addons[title_id]; const auto update_disabled = - std::find(disabled.begin(), disabled.end(), "Update") != disabled.end(); + std::find(disabled.cbegin(), disabled.cend(), "Update") != disabled.cend(); // Game Updates const auto update_tid = GetUpdateTitleID(title_id); @@ -127,7 +127,7 @@ std::vector PatchManager::CollectPatches(const std::vector out; out.reserve(patch_dirs.size()); for (const auto& subdir : patch_dirs) { - if (std::find(disabled.begin(), disabled.end(), subdir->GetName()) != disabled.end()) + if (std::find(disabled.cbegin(), disabled.cend(), subdir->GetName()) != disabled.cend()) continue; auto exefs_dir = subdir->GetSubdirectory("exefs"); @@ -284,12 +284,17 @@ std::vector PatchManager::CreateCheatList( return {}; } + const auto& disabled = Settings::values.disabled_addons[title_id]; auto patch_dirs = load_dir->GetSubdirectories(); std::sort(patch_dirs.begin(), patch_dirs.end(), [](const VirtualDir& l, const VirtualDir& r) { return l->GetName() < r->GetName(); }); std::vector out; for (const auto& subdir : patch_dirs) { + if (std::find(disabled.cbegin(), disabled.cend(), subdir->GetName()) != disabled.cend()) { + continue; + } + auto cheats_dir = subdir->GetSubdirectory("cheats"); if (cheats_dir != nullptr) { auto res = ReadCheatFileFromFolder(system, title_id, build_id_, cheats_dir, true); @@ -331,8 +336,9 @@ static void ApplyLayeredFS(VirtualFile& romfs, u64 title_id, ContentRecordType t layers.reserve(patch_dirs.size() + 1); layers_ext.reserve(patch_dirs.size() + 1); for (const auto& subdir : patch_dirs) { - if (std::find(disabled.begin(), disabled.end(), subdir->GetName()) != disabled.end()) + if (std::find(disabled.cbegin(), disabled.cend(), subdir->GetName()) != disabled.cend()) { continue; + } auto romfs_dir = subdir->GetSubdirectory("romfs"); if (romfs_dir != nullptr) @@ -381,7 +387,7 @@ VirtualFile PatchManager::PatchRomFS(VirtualFile romfs, u64 ivfc_offset, Content const auto& disabled = Settings::values.disabled_addons[title_id]; const auto update_disabled = - std::find(disabled.begin(), disabled.end(), "Update") != disabled.end(); + std::find(disabled.cbegin(), disabled.cend(), "Update") != disabled.cend(); if (!update_disabled && update != nullptr) { const auto new_nca = std::make_shared(update, romfs, ivfc_offset); @@ -431,7 +437,7 @@ std::map> PatchManager::GetPatchVersionNam auto [nacp, discard_icon_file] = update.GetControlMetadata(); const auto update_disabled = - std::find(disabled.begin(), disabled.end(), "Update") != disabled.end(); + std::find(disabled.cbegin(), disabled.cend(), "Update") != disabled.cend(); const auto update_label = update_disabled ? "[D] Update" : "Update"; if (nacp != nullptr) {