diff options
| author | Pokechu22 <pokechu022@gmail.com> | 2022-10-29 12:34:00 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-10-29 12:34:00 -0700 |
| commit | 6dcf8a6fc98a1aa4451d6ed40cd057bf9e6430be (patch) | |
| tree | cdc0e576e82d202bfa307972b0dac74afea5d4b4 /Source/Core/Common/Debug/MemoryPatches.cpp | |
| parent | aeb0fcb8abdcd8cec3aa36b0c43753ecdf876800 (diff) | |
| parent | e2f4400f4941def98af3e2b30696f531baada7a7 (diff) | |
Merge pull request #11201 from JoshuaMKW/fix-instruction-patches
MemoryPatches: Fix instruction patches
Diffstat (limited to 'Source/Core/Common/Debug/MemoryPatches.cpp')
| -rw-r--r-- | Source/Core/Common/Debug/MemoryPatches.cpp | 15 |
1 files changed, 5 insertions, 10 deletions
diff --git a/Source/Core/Common/Debug/MemoryPatches.cpp b/Source/Core/Common/Debug/MemoryPatches.cpp index cbe7258bed..8dd9b5716d 100644 --- a/Source/Core/Common/Debug/MemoryPatches.cpp +++ b/Source/Core/Common/Debug/MemoryPatches.cpp @@ -32,6 +32,7 @@ void MemoryPatches::SetPatch(u32 address, u32 value) void MemoryPatches::SetPatch(u32 address, std::vector<u8> value) { + UnsetPatch(address); const std::size_t index = m_patches.size(); m_patches.emplace_back(address, std::move(value)); Patch(index); @@ -44,20 +45,14 @@ const std::vector<MemoryPatch>& MemoryPatches::GetPatches() const void MemoryPatches::UnsetPatch(u32 address) { - const auto it = std::remove_if(m_patches.begin(), m_patches.end(), - [address](const auto& patch) { return patch.address == address; }); + const auto it = std::find_if(m_patches.begin(), m_patches.end(), + [address](const auto& patch) { return patch.address == address; }); if (it == m_patches.end()) return; - const std::size_t size = m_patches.size(); - std::size_t index = size - std::distance(it, m_patches.end()); - while (index < size) - { - DisablePatch(index); - ++index; - } - m_patches.erase(it, m_patches.end()); + const std::size_t index = std::distance(m_patches.begin(), it); + RemovePatch(index); } void MemoryPatches::EnablePatch(std::size_t index) |
