DiscIO/Riivolution: Add dolphin-specific extensions "dolphin_sys_file" and "dolphin_sys_folder" to patch sys files like you would patch regular files.
This commit is contained in:
parent
f5c132580c
commit
cc315cb7af
|
@ -701,7 +701,8 @@ void AddRiivolutionPatches(BootParameters* boot_params,
|
||||||
disc.volume = DiscIO::CreateDisc(DiscIO::DirectoryBlobReader::Create(
|
disc.volume = DiscIO::CreateDisc(DiscIO::DirectoryBlobReader::Create(
|
||||||
std::move(disc.volume),
|
std::move(disc.volume),
|
||||||
[&](std::vector<DiscIO::FSTBuilderNode>* fst, DiscIO::FSTBuilderNode* dol_node) {
|
[&](std::vector<DiscIO::FSTBuilderNode>* 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);
|
boot_params->riivolution_patches = std::move(riivolution_patches);
|
||||||
}
|
}
|
||||||
|
|
|
@ -172,9 +172,10 @@ std::optional<Disc> ParseString(std::string_view xml, std::string xml_path)
|
||||||
for (const auto& patch_subnode : patch_node.children())
|
for (const auto& patch_subnode : patch_node.children())
|
||||||
{
|
{
|
||||||
const std::string_view patch_name(patch_subnode.name());
|
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_disc = patch_subnode.attribute("disc").as_string();
|
||||||
file.m_external = patch_subnode.attribute("external").as_string();
|
file.m_external = patch_subnode.attribute("external").as_string();
|
||||||
file.m_resize = patch_subnode.attribute("resize").as_bool(true);
|
file.m_resize = patch_subnode.attribute("resize").as_bool(true);
|
||||||
|
@ -183,9 +184,11 @@ std::optional<Disc> ParseString(std::string_view xml, std::string xml_path)
|
||||||
file.m_fileoffset = patch_subnode.attribute("fileoffset").as_uint(0);
|
file.m_fileoffset = patch_subnode.attribute("fileoffset").as_uint(0);
|
||||||
file.m_length = patch_subnode.attribute("length").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_disc = patch_subnode.attribute("disc").as_string();
|
||||||
folder.m_external = patch_subnode.attribute("external").as_string();
|
folder.m_external = patch_subnode.attribute("external").as_string();
|
||||||
folder.m_resize = patch_subnode.attribute("resize").as_bool(true);
|
folder.m_resize = patch_subnode.attribute("resize").as_bool(true);
|
||||||
|
|
|
@ -166,6 +166,8 @@ struct Patch
|
||||||
|
|
||||||
std::vector<File> m_file_patches;
|
std::vector<File> m_file_patches;
|
||||||
std::vector<Folder> m_folder_patches;
|
std::vector<Folder> m_folder_patches;
|
||||||
|
std::vector<File> m_sys_file_patches;
|
||||||
|
std::vector<Folder> m_sys_folder_patches;
|
||||||
std::vector<Savegame> m_savegame_patches;
|
std::vector<Savegame> m_savegame_patches;
|
||||||
std::vector<Memory> m_memory_patches;
|
std::vector<Memory> m_memory_patches;
|
||||||
|
|
||||||
|
|
|
@ -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);
|
ApplyFolderPatchToFST(patch, folder, fst, dol_node, folder.m_disc, folder.m_external);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ApplyPatchesToFiles(const std::vector<Patch>& patches,
|
void ApplyPatchesToFiles(const std::vector<Patch>& patches, PatchIndex index,
|
||||||
std::vector<DiscIO::FSTBuilderNode>* fst, DiscIO::FSTBuilderNode* dol_node)
|
std::vector<DiscIO::FSTBuilderNode>* fst, DiscIO::FSTBuilderNode* dol_node)
|
||||||
{
|
{
|
||||||
for (const auto& patch : patches)
|
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);
|
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);
|
ApplyFolderPatchToFST(patch, folder, fst, dol_node);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -65,7 +65,13 @@ private:
|
||||||
std::string m_patch_root;
|
std::string m_patch_root;
|
||||||
};
|
};
|
||||||
|
|
||||||
void ApplyPatchesToFiles(const std::vector<Patch>& patches,
|
enum class PatchIndex
|
||||||
|
{
|
||||||
|
FileSystem,
|
||||||
|
DolphinSysFiles,
|
||||||
|
};
|
||||||
|
|
||||||
|
void ApplyPatchesToFiles(const std::vector<Patch>& patches, PatchIndex index,
|
||||||
std::vector<DiscIO::FSTBuilderNode>* fst,
|
std::vector<DiscIO::FSTBuilderNode>* fst,
|
||||||
DiscIO::FSTBuilderNode* dol_node);
|
DiscIO::FSTBuilderNode* dol_node);
|
||||||
void ApplyGeneralMemoryPatches(const std::vector<Patch>& patches);
|
void ApplyGeneralMemoryPatches(const std::vector<Patch>& patches);
|
||||||
|
|
Loading…
Reference in New Issue