[Scummvm-git-logs] scummvm master -> 2776981c7942470c64319371a16d31d8387bd72e
whoozle
noreply at scummvm.org
Wed Jul 15 08:17:21 UTC 2026
This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://api.github.com/repos/scummvm/scummvm .
Summary:
2776981c79 PHOENIXVR: Fix NUL char handling in scripts
Commit: 2776981c7942470c64319371a16d31d8387bd72e
https://github.com/scummvm/scummvm/commit/2776981c7942470c64319371a16d31d8387bd72e
Author: Vladimir Menshakov (vladimir.menshakov at gmail.com)
Date: 2026-07-15T09:16:45+01:00
Commit Message:
PHOENIXVR: Fix NUL char handling in scripts
Fix game breaking Amerzone issue in Chapter 4.
Some variables have been skipped because Stream::readLine() actually stops at \0.
Replace script case-independent comparison and readLine with faster and simpler equivalents.
Changed paths:
engines/phoenixvr/script.cpp
diff --git a/engines/phoenixvr/script.cpp b/engines/phoenixvr/script.cpp
index c96ab17becd..55fd722dd9c 100644
--- a/engines/phoenixvr/script.cpp
+++ b/engines/phoenixvr/script.cpp
@@ -53,7 +53,17 @@ public:
bool peek(const Common::String &prefix) {
skip();
- return scumm_strnicmp(_line.c_str() + _pos, prefix.c_str(), prefix.size()) == 0;
+ if (_pos + prefix.size() > _line.size())
+ return false;
+
+ auto n = prefix.size();
+ auto *ch0 = _line.c_str() + _pos;
+ auto *ch1 = prefix.c_str();
+ while (n--) {
+ if (tolower(*ch0++) != tolower(*ch1++))
+ return false;
+ }
+ return true;
}
bool maybe(const Common::String &prefix) {
@@ -312,10 +322,20 @@ Script::TestPtr Script::Warp::getLastTest(int idx) const {
}
Script::Script(Common::SeekableReadStream &s) {
+ s.seek(0);
+ Common::Array<char> text(s.size());
+ if (s.read(text.data(), text.size()) != text.size())
+ error("script: short read");
uint lineno = 1;
- while (!s.eos()) {
- auto line = s.readLine();
- parseLine(line, lineno++);
+ uint lineStartOffset = 0;
+ auto textSize = text.size();
+ while (lineStartOffset < textSize) {
+ auto lineStart = text.begin() + lineStartOffset;
+ auto lineEnd = Common::find(lineStart, text.end(), '\n');
+ parseLine({lineStart, lineEnd}, lineno++);
+ lineStartOffset += Common::distance(lineStart, lineEnd) + 1;
+ if (lineStartOffset < textSize && text[lineStartOffset] == '\r')
+ ++lineStartOffset;
}
}
@@ -328,7 +348,7 @@ void Script::parseLine(const Common::String &line, uint lineno) {
return;
if (p.maybe('[')) {
- if (p.maybe("bool]=") || p.maybe("bool)=") || p.maybe("b\x00\x00ool]=")) {
+ if (p.maybe("bool]=") || p.maybe("bool)=") || p.maybe({"b\x00\x00ool]=", 8})) {
_vars.push_back(p.nextWord());
} else if (p.maybe("warp]=")) {
auto vr = p.nextWord();
More information about the Scummvm-git-logs
mailing list