mirror of
https://git.eden-emu.dev/eden-emu/eden
synced 2026-10-20 21:09:37 +02:00
[ips_layer] remove trailing whitespace to fix hex parsing on TLTD mods (#4336)
Signed-off-by: lizzie <lizzie@eden-emu.dev> - [x] I have read and followed the [Contribution Guidelines](https://git.eden-emu.dev/eden-emu/eden/src/branch/master/CONTRIBUTING.md#code-contributions). - [x] I have read and followed the [AI Policy](https://git.eden-emu.dev/eden-emu/eden/src/branch/master/docs/policies/AI.md) - [x] I have read and followed the [Coding Guidelines](https://git.eden-emu.dev/eden-emu/eden/src/branch/master/docs/policies/Coding.md) to the best of my ability. ------------------- ...another edge case, this time with `00297f24 34008052 // 60FPS` would get parsed as `34008052 ` which isn't quite correct Reviewed-on: https://git.eden-emu.dev/eden-emu/eden/pulls/4336 Reviewed-by: CamilleLaVey <camillelavey99@gmail.com> Reviewed-by: Maufeat <sahyno1996@gmail.com>
This commit is contained in:
parent
20f9aa4cfe
commit
ed57836903
1 changed files with 12 additions and 5 deletions
|
|
@ -120,7 +120,7 @@ std::array<u8, 32> IPSwitchCompiler::GetBuildID() const {
|
||||||
|
|
||||||
static IPSwitchRecord EscapeStringSequences(std::string_view sv) {
|
static IPSwitchRecord EscapeStringSequences(std::string_view sv) {
|
||||||
IPSwitchRecord r{};
|
IPSwitchRecord r{};
|
||||||
for (auto it = sv.cbegin(); it != sv.cend(); ) {
|
for (auto it = sv.cbegin(); it < sv.cend(); ) {
|
||||||
if (*it == '\\' && it + 1 < sv.cend()) {
|
if (*it == '\\' && it + 1 < sv.cend()) {
|
||||||
switch (it[1]) {
|
switch (it[1]) {
|
||||||
case 'a': r.data[r.count] = '\a'; break;
|
case 'a': r.data[r.count] = '\a'; break;
|
||||||
|
|
@ -198,6 +198,8 @@ void IPSwitchCompiler::Parse(std::span<u8 const> bytes) {
|
||||||
LOG_WARNING(Loader, "Unknown flag {}", line);
|
LOG_WARNING(Loader, "Unknown flag {}", line);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
} else if (patches.empty()) {
|
||||||
|
LOG_WARNING(Loader, "Invalid line not in a patch {}", line);
|
||||||
} else {
|
} else {
|
||||||
size_t offset = size_t(std::strtoul(line.data(), nullptr, 16));
|
size_t offset = size_t(std::strtoul(line.data(), nullptr, 16));
|
||||||
offset += size_t(offset_shift);
|
offset += size_t(offset_shift);
|
||||||
|
|
@ -253,25 +255,30 @@ void IPSwitchCompiler::Parse(std::span<u8 const> bytes) {
|
||||||
// now make a nominal preprocessed line: remove comments
|
// now make a nominal preprocessed line: remove comments
|
||||||
char quote = '\0';
|
char quote = '\0';
|
||||||
auto const sline_start = p;
|
auto const sline_start = p;
|
||||||
|
auto last_char = p;
|
||||||
for (; p < sline.cend(); ) {
|
for (; p < sline.cend(); ) {
|
||||||
// we dont check for "//", IPS checks for '/' only...
|
// we dont check for "//", IPS checks for '/' only...
|
||||||
if ((!quote && p[0] == '/')
|
if (std::isspace(*p)) {
|
||||||
|
++p;
|
||||||
|
} else if ((!quote && p[0] == '/')
|
||||||
|| (!quote && p[0] == '#')) {
|
|| (!quote && p[0] == '#')) {
|
||||||
break;
|
break;
|
||||||
} else if (p[0] == '\"' || p[0] == '\'') {
|
} else if (p[0] == '\"' || p[0] == '\'') {
|
||||||
quote = (p[0] == quote) ? '\0' : p[0];
|
quote = (p[0] == quote) ? '\0' : p[0];
|
||||||
++p;
|
++p;
|
||||||
|
last_char = p;
|
||||||
} else if (p + 1 < sline.cend() && p[0] == '\\') {
|
} else if (p + 1 < sline.cend() && p[0] == '\\') {
|
||||||
p += 2;
|
p += 2;
|
||||||
|
last_char = p;
|
||||||
} else {
|
} else {
|
||||||
++p;
|
++p;
|
||||||
|
last_char = p;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// now we have the preprocessed string ;)
|
// now we have the preprocessed string ;)
|
||||||
std::string_view pp_str(sline_start, p);
|
std::string_view const pp_str(sline_start, last_char);
|
||||||
if (pp_str.size() > 0 && !parse_line(pp_str)) {
|
if (pp_str.size() > 0 && !parse_line(pp_str))
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue