Skip to content

Commit

Permalink
Cheats: Allow hex literal in option ranges
Browse files Browse the repository at this point in the history
  • Loading branch information
stenzek committed Oct 27, 2024
1 parent 218df62 commit 1d21ca6
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/core/cheats.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1371,8 +1371,10 @@ bool Cheats::ParseOptionRange(const std::string_view value, u16* out_range_start
// OptionRange = 0:255
if (const std::string_view::size_type pos = value.rfind(':'); pos != std::string_view::npos)
{
const std::optional<u32> start = StringUtil::FromChars<u32>(StringUtil::StripWhitespace(value.substr(0, pos)));
const std::optional<u32> end = StringUtil::FromChars<u32>(StringUtil::StripWhitespace(value.substr(pos + 1)));
const std::optional<u32> start =
StringUtil::FromCharsWithOptionalBase<u32>(StringUtil::StripWhitespace(value.substr(0, pos)));
const std::optional<u32> end =
StringUtil::FromCharsWithOptionalBase<u32>(StringUtil::StripWhitespace(value.substr(pos + 1)));
if (start.has_value() && end.has_value() && start.value() <= std::numeric_limits<u16>::max() &&
end.value() <= std::numeric_limits<u16>::max() && end.value() > start.value())
{
Expand Down Expand Up @@ -1961,7 +1963,7 @@ std::unique_ptr<Cheats::GamesharkCheatCode> Cheats::GamesharkCheatCode::Parse(Me
}

size_t next_offset = 0;
while (next_offset < next.size() && !StringUtil::IsHexDigit(next[next_offset]))
while (next_offset < next.size() && next[next_offset] != '?' && !StringUtil::IsHexDigit(next[next_offset]))
next_offset++;
next = (next_offset < next.size()) ? next.substr(next_offset) : std::string_view();

Expand Down

0 comments on commit 1d21ca6

Please sign in to comment.