mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2025-12-09 21:31:04 +00:00
Fix patches being applied multiple times redundantly (#3763)
This commit is contained in:
@@ -140,48 +140,39 @@ void ApplyPatchesFromXML(std::filesystem::path path) {
|
|||||||
if (!versionMatches && type != "mask" && type != "mask_jump32")
|
if (!versionMatches && type != "mask" && type != "mask_jump32")
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
std::string currentPatchName = it->attribute("Name").value();
|
std::string address = patchLineIt->attribute("Address").value();
|
||||||
|
std::string patchValue = patchLineIt->attribute("Value").value();
|
||||||
for (pugi::xml_node_iterator patchLineIt = patchList.children().begin();
|
std::string maskOffsetStr = patchLineIt->attribute("Offset").value();
|
||||||
patchLineIt != patchList.children().end(); ++patchLineIt) {
|
std::string targetStr = "";
|
||||||
|
std::string sizeStr = "";
|
||||||
std::string type = patchLineIt->attribute("Type").value();
|
if (type == "mask_jump32") {
|
||||||
std::string address = patchLineIt->attribute("Address").value();
|
targetStr = patchLineIt->attribute("Target").value();
|
||||||
std::string patchValue = patchLineIt->attribute("Value").value();
|
sizeStr = patchLineIt->attribute("Size").value();
|
||||||
std::string maskOffsetStr = patchLineIt->attribute("Offset").value();
|
} else {
|
||||||
std::string targetStr = "";
|
patchValue = convertValueToHex(type, patchValue);
|
||||||
std::string sizeStr = "";
|
|
||||||
if (type == "mask_jump32") {
|
|
||||||
targetStr = patchLineIt->attribute("Target").value();
|
|
||||||
sizeStr = patchLineIt->attribute("Size").value();
|
|
||||||
} else {
|
|
||||||
patchValue = convertValueToHex(type, patchValue);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool littleEndian = false;
|
|
||||||
|
|
||||||
if (type == "bytes16" || type == "bytes32" || type == "bytes64") {
|
|
||||||
littleEndian = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
MemoryPatcher::PatchMask patchMask = MemoryPatcher::PatchMask::None;
|
|
||||||
int maskOffsetValue = 0;
|
|
||||||
|
|
||||||
if (type == "mask")
|
|
||||||
patchMask = MemoryPatcher::PatchMask::Mask;
|
|
||||||
|
|
||||||
if (type == "mask_jump32")
|
|
||||||
patchMask = MemoryPatcher::PatchMask::Mask_Jump32;
|
|
||||||
|
|
||||||
if ((type == "mask" || type == "mask_jump32") &&
|
|
||||||
!maskOffsetStr.empty()) {
|
|
||||||
maskOffsetValue = std::stoi(maskOffsetStr, 0, 10);
|
|
||||||
}
|
|
||||||
|
|
||||||
MemoryPatcher::PatchMemory(currentPatchName, address, patchValue,
|
|
||||||
targetStr, sizeStr, false, littleEndian,
|
|
||||||
patchMask, maskOffsetValue);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool littleEndian = false;
|
||||||
|
if (type == "bytes16" || type == "bytes32" || type == "bytes64") {
|
||||||
|
littleEndian = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
MemoryPatcher::PatchMask patchMask = MemoryPatcher::PatchMask::None;
|
||||||
|
int maskOffsetValue = 0;
|
||||||
|
|
||||||
|
if (type == "mask")
|
||||||
|
patchMask = MemoryPatcher::PatchMask::Mask;
|
||||||
|
|
||||||
|
if (type == "mask_jump32")
|
||||||
|
patchMask = MemoryPatcher::PatchMask::Mask_Jump32;
|
||||||
|
|
||||||
|
if ((type == "mask" || type == "mask_jump32") && !maskOffsetStr.empty()) {
|
||||||
|
maskOffsetValue = std::stoi(maskOffsetStr, 0, 10);
|
||||||
|
}
|
||||||
|
|
||||||
|
MemoryPatcher::PatchMemory(currentPatchName, address, patchValue, targetStr,
|
||||||
|
sizeStr, false, littleEndian, patchMask,
|
||||||
|
maskOffsetValue);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user