diff --git a/Source/Core/Core/Boot/Boot.cpp b/Source/Core/Core/Boot/Boot.cpp index 86ea8e2179..94b66bd687 100644 --- a/Source/Core/Core/Boot/Boot.cpp +++ b/Source/Core/Core/Boot/Boot.cpp @@ -701,7 +701,8 @@ void AddRiivolutionPatches(BootParameters* boot_params, disc.volume = DiscIO::CreateDisc(DiscIO::DirectoryBlobReader::Create( std::move(disc.volume), [&](std::vector* fst, DiscIO::FSTBuilderNode* dol_node) { - DiscIO::Riivolution::ApplyPatchesToFiles(riivolution_patches, fst, dol_node); + DiscIO::Riivolution::ApplyPatchesToFiles( + riivolution_patches, DiscIO::Riivolution::PatchIndex::FileSystem, fst, dol_node); })); boot_params->riivolution_patches = std::move(riivolution_patches); } diff --git a/Source/Core/DiscIO/RiivolutionParser.cpp b/Source/Core/DiscIO/RiivolutionParser.cpp index 283e5876df..dacbbbcfc5 100644 --- a/Source/Core/DiscIO/RiivolutionParser.cpp +++ b/Source/Core/DiscIO/RiivolutionParser.cpp @@ -172,9 +172,10 @@ std::optional ParseString(std::string_view xml, std::string xml_path) for (const auto& patch_subnode : patch_node.children()) { const std::string_view patch_name(patch_subnode.name()); - if (patch_name == "file") + if (patch_name == "file" || patch_name == "dolphin_sys_file") { - auto& file = patch.m_file_patches.emplace_back(); + auto& file = patch_name == "dolphin_sys_file" ? patch.m_sys_file_patches.emplace_back() : + patch.m_file_patches.emplace_back(); file.m_disc = patch_subnode.attribute("disc").as_string(); file.m_external = patch_subnode.attribute("external").as_string(); file.m_resize = patch_subnode.attribute("resize").as_bool(true); @@ -183,9 +184,11 @@ std::optional ParseString(std::string_view xml, std::string xml_path) file.m_fileoffset = patch_subnode.attribute("fileoffset").as_uint(0); file.m_length = patch_subnode.attribute("length").as_uint(0); } - else if (patch_name == "folder") + else if (patch_name == "folder" || patch_name == "dolphin_sys_folder") { - auto& folder = patch.m_folder_patches.emplace_back(); + auto& folder = patch_name == "dolphin_sys_folder" ? + patch.m_sys_folder_patches.emplace_back() : + patch.m_folder_patches.emplace_back(); folder.m_disc = patch_subnode.attribute("disc").as_string(); folder.m_external = patch_subnode.attribute("external").as_string(); folder.m_resize = patch_subnode.attribute("resize").as_bool(true); diff --git a/Source/Core/DiscIO/RiivolutionParser.h b/Source/Core/DiscIO/RiivolutionParser.h index f9f03f67c1..9ec6c92959 100644 --- a/Source/Core/DiscIO/RiivolutionParser.h +++ b/Source/Core/DiscIO/RiivolutionParser.h @@ -166,6 +166,8 @@ struct Patch std::vector m_file_patches; std::vector m_folder_patches; + std::vector m_sys_file_patches; + std::vector m_sys_folder_patches; std::vector m_savegame_patches; std::vector m_memory_patches; diff --git a/Source/Core/DiscIO/RiivolutionPatcher.cpp b/Source/Core/DiscIO/RiivolutionPatcher.cpp index a9593dddcd..8ad65f8c57 100644 --- a/Source/Core/DiscIO/RiivolutionPatcher.cpp +++ b/Source/Core/DiscIO/RiivolutionPatcher.cpp @@ -458,15 +458,20 @@ static void ApplyFolderPatchToFST(const Patch& patch, const Folder& folder, ApplyFolderPatchToFST(patch, folder, fst, dol_node, folder.m_disc, folder.m_external); } -void ApplyPatchesToFiles(const std::vector& patches, +void ApplyPatchesToFiles(const std::vector& patches, PatchIndex index, std::vector* fst, DiscIO::FSTBuilderNode* dol_node) { for (const auto& patch : patches) { - for (const auto& file : patch.m_file_patches) + const auto& file_patches = + index == PatchIndex::DolphinSysFiles ? patch.m_sys_file_patches : patch.m_file_patches; + const auto& folder_patches = + index == PatchIndex::DolphinSysFiles ? patch.m_sys_folder_patches : patch.m_folder_patches; + + for (const auto& file : file_patches) ApplyFilePatchToFST(patch, file, fst, dol_node); - for (const auto& folder : patch.m_folder_patches) + for (const auto& folder : folder_patches) ApplyFolderPatchToFST(patch, folder, fst, dol_node); } } diff --git a/Source/Core/DiscIO/RiivolutionPatcher.h b/Source/Core/DiscIO/RiivolutionPatcher.h index 0f3de33caf..0a83ba9d13 100644 --- a/Source/Core/DiscIO/RiivolutionPatcher.h +++ b/Source/Core/DiscIO/RiivolutionPatcher.h @@ -65,7 +65,13 @@ private: std::string m_patch_root; }; -void ApplyPatchesToFiles(const std::vector& patches, +enum class PatchIndex +{ + FileSystem, + DolphinSysFiles, +}; + +void ApplyPatchesToFiles(const std::vector& patches, PatchIndex index, std::vector* fst, DiscIO::FSTBuilderNode* dol_node); void ApplyGeneralMemoryPatches(const std::vector& patches);