diff options
| author | Tilka <tilkax@gmail.com> | 2023-12-12 20:07:44 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-12-12 20:07:44 +0000 |
| commit | c92e4024544d4b0553f5cb6e922891b39de0b605 (patch) | |
| tree | 1882e9131cb9fa6fb8b225c9a2250cc85d2a526b /Source/Core/DiscIO/RiivolutionPatcher.cpp | |
| parent | 198a53e7dfe72f6016adb3271c530f9969975faa (diff) | |
| parent | b728e370862ea157f33672e8a88d55f28e8f0cf8 (diff) | |
Merge pull request #12398 from lioncash/parse
RiivolutionParser: Make use of std::span where applicable
Diffstat (limited to 'Source/Core/DiscIO/RiivolutionPatcher.cpp')
| -rw-r--r-- | Source/Core/DiscIO/RiivolutionPatcher.cpp | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/Source/Core/DiscIO/RiivolutionPatcher.cpp b/Source/Core/DiscIO/RiivolutionPatcher.cpp index 175ee18f17..4a6f7bb2ad 100644 --- a/Source/Core/DiscIO/RiivolutionPatcher.cpp +++ b/Source/Core/DiscIO/RiivolutionPatcher.cpp @@ -15,6 +15,7 @@ #include "Common/IOFile.h" #include "Common/StringUtil.h" #include "Core/Config/AchievementSettings.h" +#include "Core/Core.h" #include "Core/HLE/HLE.h" #include "Core/HW/Memmap.h" #include "Core/IOS/FS/FileSystem.h" @@ -490,8 +491,8 @@ 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<Patch>& patches, PatchIndex index, - std::vector<DiscIO::FSTBuilderNode>* fst, DiscIO::FSTBuilderNode* dol_node) +void ApplyPatchesToFiles(std::span<const Patch> patches, PatchIndex index, + std::vector<FSTBuilderNode>* fst, FSTBuilderNode* dol_node) { for (const auto& patch : patches) { @@ -509,7 +510,7 @@ void ApplyPatchesToFiles(const std::vector<Patch>& patches, PatchIndex index, } static bool MemoryMatchesAt(const Core::CPUThreadGuard& guard, u32 offset, - const std::vector<u8>& value) + std::span<const u8> value) { for (u32 i = 0; i < value.size(); ++i) { @@ -521,7 +522,7 @@ static bool MemoryMatchesAt(const Core::CPUThreadGuard& guard, u32 offset, } static void ApplyMemoryPatch(const Core::CPUThreadGuard& guard, u32 offset, - const std::vector<u8>& value, const std::vector<u8>& original) + std::span<const u8> value, std::span<const u8> original) { #ifdef USE_RETRO_ACHIEVEMENTS if (::Config::Get(::Config::RA_HARDCORE_ENABLED)) @@ -534,7 +535,7 @@ static void ApplyMemoryPatch(const Core::CPUThreadGuard& guard, u32 offset, if (!original.empty() && !MemoryMatchesAt(guard, offset, original)) return; - auto& system = Core::System::GetInstance(); + auto& system = guard.GetSystem(); const u32 size = static_cast<u32>(value.size()); for (u32 i = 0; i < size; ++i) PowerPC::MMU::HostTryWriteU8(guard, value[i], offset + i); @@ -590,7 +591,7 @@ static void ApplyOcarinaMemoryPatch(const Core::CPUThreadGuard& guard, const Pat if (value.empty()) return; - auto& system = Core::System::GetInstance(); + auto& system = guard.GetSystem(); for (u32 i = 0; i < length; i += 4) { // first find the pattern @@ -622,10 +623,10 @@ static void ApplyOcarinaMemoryPatch(const Core::CPUThreadGuard& guard, const Pat } } -void ApplyGeneralMemoryPatches(const Core::CPUThreadGuard& guard, const std::vector<Patch>& patches) +void ApplyGeneralMemoryPatches(const Core::CPUThreadGuard& guard, std::span<const Patch> patches) { - auto& system = Core::System::GetInstance(); - auto& system_memory = system.GetMemory(); + const auto& system = guard.GetSystem(); + const auto& system_memory = system.GetMemory(); for (const auto& patch : patches) { @@ -642,8 +643,8 @@ void ApplyGeneralMemoryPatches(const Core::CPUThreadGuard& guard, const std::vec } } -void ApplyApploaderMemoryPatches(const Core::CPUThreadGuard& guard, - const std::vector<Patch>& patches, u32 ram_address, u32 ram_length) +void ApplyApploaderMemoryPatches(const Core::CPUThreadGuard& guard, std::span<const Patch> patches, + u32 ram_address, u32 ram_length) { for (const auto& patch : patches) { @@ -660,8 +661,7 @@ void ApplyApploaderMemoryPatches(const Core::CPUThreadGuard& guard, } } -std::optional<SavegameRedirect> -ExtractSavegameRedirect(const std::vector<Patch>& riivolution_patches) +std::optional<SavegameRedirect> ExtractSavegameRedirect(std::span<const Patch> riivolution_patches) { for (const auto& patch : riivolution_patches) { |
