summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorLioncash <mathew1800@gmail.com>2020-09-15 09:24:42 +0200
committerLioncash <mathew1800@gmail.com>2020-09-15 09:24:44 +0200
commit3a8464cde28bd89146aa44af836f80ff925c293c (patch)
tree5730a53f2b5e113ac254bc408d7ff968f9da5242 /src
parentcheat_engine: Remove unnecessary system argument to CheatParser's Parse function (diff)
downloadyuzu-3a8464cde28bd89146aa44af836f80ff925c293c.tar
yuzu-3a8464cde28bd89146aa44af836f80ff925c293c.tar.gz
yuzu-3a8464cde28bd89146aa44af836f80ff925c293c.tar.bz2
yuzu-3a8464cde28bd89146aa44af836f80ff925c293c.tar.lz
yuzu-3a8464cde28bd89146aa44af836f80ff925c293c.tar.xz
yuzu-3a8464cde28bd89146aa44af836f80ff925c293c.tar.zst
yuzu-3a8464cde28bd89146aa44af836f80ff925c293c.zip
Diffstat (limited to '')
-rw-r--r--src/core/memory/cheat_engine.cpp36
1 files changed, 17 insertions, 19 deletions
diff --git a/src/core/memory/cheat_engine.cpp b/src/core/memory/cheat_engine.cpp
index 68d09d350..29284a42d 100644
--- a/src/core/memory/cheat_engine.cpp
+++ b/src/core/memory/cheat_engine.cpp
@@ -19,10 +19,24 @@
#include "core/memory/cheat_engine.h"
namespace Core::Memory {
-
+namespace {
constexpr auto CHEAT_ENGINE_NS = std::chrono::nanoseconds{1000000000 / 12};
constexpr u32 KEYPAD_BITMASK = 0x3FFFFFF;
+std::string_view ExtractName(std::string_view data, std::size_t start_index, char match) {
+ auto end_index = start_index;
+ while (data[end_index] != match) {
+ ++end_index;
+ if (end_index > data.size() ||
+ (end_index - start_index - 1) > sizeof(CheatDefinition::readable_name)) {
+ return {};
+ }
+ }
+
+ return data.substr(start_index, end_index - start_index);
+}
+} // Anonymous namespace
+
StandardVmCallbacks::StandardVmCallbacks(Core::System& system, const CheatProcessMetadata& metadata)
: metadata(metadata), system(system) {}
@@ -82,22 +96,6 @@ CheatParser::~CheatParser() = default;
TextCheatParser::~TextCheatParser() = default;
-namespace {
-template <char match>
-std::string_view ExtractName(std::string_view data, std::size_t start_index) {
- auto end_index = start_index;
- while (data[end_index] != match) {
- ++end_index;
- if (end_index > data.size() ||
- (end_index - start_index - 1) > sizeof(CheatDefinition::readable_name)) {
- return {};
- }
- }
-
- return data.substr(start_index, end_index - start_index);
-}
-} // Anonymous namespace
-
std::vector<CheatEntry> TextCheatParser::Parse(std::string_view data) const {
std::vector<CheatEntry> out(1);
std::optional<u64> current_entry;
@@ -114,7 +112,7 @@ std::vector<CheatEntry> TextCheatParser::Parse(std::string_view data) const {
return {};
}
- const auto name = ExtractName<'}'>(data, i + 1);
+ const auto name = ExtractName(data, i + 1, '}');
if (name.empty()) {
return {};
}
@@ -131,7 +129,7 @@ std::vector<CheatEntry> TextCheatParser::Parse(std::string_view data) const {
current_entry = out.size();
out.emplace_back();
- const auto name = ExtractName<']'>(data, i + 1);
+ const auto name = ExtractName(data, i + 1, ']');
if (name.empty()) {
return {};
}