[Scummvm-git-logs] scummvm master -> 2ba468c14ca55131e69739d362208732b81f0cde
sev-
noreply at scummvm.org
Tue Feb 14 00:19:49 UTC 2023
This automated email contains information about 3 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
de02a174b0 DIRECTOR: Fix debug formatting of text cast members
c98da77cdd DIRECTOR: Fix tempo when waiting on a video cast member
2ba468c14c DIRECTOR: Fix D2 script parsing
Commit: de02a174b0ef9e2b9961b60adfde54b154eaf2c3
https://github.com/scummvm/scummvm/commit/de02a174b0ef9e2b9961b60adfde54b154eaf2c3
Author: Scott Percival (code at moral.net.au)
Date: 2023-02-14T01:19:44+01:00
Commit Message:
DIRECTOR: Fix debug formatting of text cast members
Changed paths:
engines/director/castmember.cpp
diff --git a/engines/director/castmember.cpp b/engines/director/castmember.cpp
index 7737b635552..cfe53e28aee 100644
--- a/engines/director/castmember.cpp
+++ b/engines/director/castmember.cpp
@@ -1434,6 +1434,12 @@ void TextCastMember::updateFromWidget(Graphics::MacWidget *widget) {
}
Common::String TextCastMember::formatInfo() {
+ Common::String format = _ptext.encode();
+ for (int i = 0; i < (int)format.size(); i++) {
+ if (format[i] == '\r')
+ format.replace(i, 1, "\n");
+ }
+
return Common::String::format(
"initialRect: %dx%d@%d,%d, boundingRect: %dx%d@%d,%d, foreColor: %d, backColor: %d, editable: %d, text: \"%s\"",
_initialRect.width(), _initialRect.height(),
@@ -1441,7 +1447,7 @@ Common::String TextCastMember::formatInfo() {
_boundingRect.width(), _boundingRect.height(),
_boundingRect.left, _boundingRect.top,
getForeColor(), getBackColor(),
- _editable, _ptext.encode().c_str()
+ _editable, format.c_str()
);
}
Commit: c98da77cdd80b21255b23b47bf639ba0159abf3d
https://github.com/scummvm/scummvm/commit/c98da77cdd80b21255b23b47bf639ba0159abf3d
Author: Scott Percival (code at moral.net.au)
Date: 2023-02-14T01:19:44+01:00
Commit Message:
DIRECTOR: Fix tempo when waiting on a video cast member
Director 3 has a slider that goes up to a delay of 120, but it actually
stops working after 95, as this overlaps with the IDs used for waiting
for a video cast member.
Fixes conversation animations in Wrath of the Gods.
Changed paths:
engines/director/score.cpp
diff --git a/engines/director/score.cpp b/engines/director/score.cpp
index d288ec9b1bf..b7c9df7882b 100644
--- a/engines/director/score.cpp
+++ b/engines/director/score.cpp
@@ -450,29 +450,41 @@ void Score::update() {
if (tempo) {
const bool waitForClickOnly = _vm->getVersion() < 300;
- const int maxDelay = _vm->getVersion() < 400 ? 120 : 60;
+ int maxDelay = 60;
+ if (_vm->getVersion() < 300) {
+ maxDelay = 120;
+ } else if (_vm->getVersion() < 400) {
+ // Director 3 has a slider that goes up to 120, but any value
+ // beyond 95 gets converted into a video wait instruction.
+ maxDelay = 95;
+ }
if (tempo >= 256 - maxDelay) {
// Delay
_nextFrameTime = g_system->getMillis() + (256 - tempo) * 1000;
+ debugC(5, kDebugLoading, "Score::update(): setting _nextFrameTime to %d based on a delay of %d", _nextFrameTime, 256 - tempo);
} else if (tempo <= 120) {
// FPS
_currentFrameRate = tempo;
_nextFrameTime = g_system->getMillis() + 1000.0 / (float)_currentFrameRate;
+ debugC(5, kDebugLoading, "Score::update(): setting _nextFrameTime to %d based on a framerate of %d", _nextFrameTime, tempo);
} else {
if (tempo == 128) {
_waitForClick = true;
_waitForClickCursor = false;
renderCursor(_movie->getWindow()->getMousePos());
+ debugC(5, kDebugLoading, "Score::update(): waiting for mouse click before next frame");
} else if (!waitForClickOnly && tempo == 135) {
// Wait for sound channel 1
_waitForChannel = 1;
+ debugC(5, kDebugLoading, "Score::update(): waiting for sound channel 1 before next frame");
} else if (!waitForClickOnly && tempo == 134) {
// Wait for sound channel 2
_waitForChannel = 2;
-
+ debugC(5, kDebugLoading, "Score::update(): waiting for sound channel 2 before next frame");
} else if (!waitForClickOnly && tempo >= 136 && tempo <= 135 + _numChannelsDisplayed) {
// Wait for a digital video in a channel to finish playing
_waitForVideoChannel = tempo - 135;
+ debugC(5, kDebugLoading, "Score::update(): waiting for video in channel %d before next frame", _waitForVideoChannel);
} else {
warning("Unhandled tempo instruction: %d", tempo);
}
Commit: 2ba468c14ca55131e69739d362208732b81f0cde
https://github.com/scummvm/scummvm/commit/2ba468c14ca55131e69739d362208732b81f0cde
Author: Scott Percival (code at moral.net.au)
Date: 2023-02-14T01:19:44+01:00
Commit Message:
DIRECTOR: Fix D2 script parsing
When being read in D2 mode, scripts must start with a --,
then everything up until the first macro block is ignored.
Fixes meeting Hercules in Wrath of the Gods.
Changed paths:
engines/director/cast.cpp
engines/director/cast.h
engines/director/lingo/lingo-codegen.cpp
engines/director/lingo/lingo-codegen.h
engines/director/lingo/lingo-preprocessor.cpp
engines/director/lingo/lingo.cpp
engines/director/lingo/lingo.h
engines/director/types.h
diff --git a/engines/director/cast.cpp b/engines/director/cast.cpp
index 6478ca91606..b305fef730a 100644
--- a/engines/director/cast.cpp
+++ b/engines/director/cast.cpp
@@ -589,7 +589,7 @@ void Cast::loadCast() {
if (debugChannelSet(-1, kDebugFewFramesOnly))
warning("Compiling STXT %d", *iterator);
- loadScriptText(*(r = _castArchive->getResource(MKTAG('S','T','X','T'), *iterator)), *iterator - _castIDoffset);
+ loadScriptV2(*(r = _castArchive->getResource(MKTAG('S','T','X','T'), *iterator)), *iterator - _castIDoffset);
delete r;
}
@@ -1244,7 +1244,12 @@ void Cast::loadLingoContext(Common::SeekableReadStreamEndian &stream) {
}
}
-void Cast::loadScriptText(Common::SeekableReadStreamEndian &stream, uint16 id) {
+void Cast::loadScriptV2(Common::SeekableReadStreamEndian &stream, uint16 id) {
+ // In Director 2 (and Director 3 with compatibility mode), any text cast
+ // member which begins with a comment "--" gets parsed as a movie script.
+ // In this mode, fewer top-level keywords are recognised; this is indicated
+ // by passing kLPPForceD2 to the Lingo preprocessor.
+
/*uint32 unk1 = */ stream.readUint32();
uint32 strLen = stream.readUint32();
/*uin32 dataLen = */ stream.readUint32();
@@ -1258,10 +1263,7 @@ void Cast::loadScriptText(Common::SeekableReadStreamEndian &stream, uint16 id) {
if (ConfMan.getBool("dump_scripts"))
dumpScript(script.c_str(), kMovieScript, id);
- if (script.contains("\nmenu:") || script.hasPrefix("menu:"))
- return;
-
- _lingoArchive->addCode(script.decode(Common::kMacRoman), kMovieScript, id);
+ _lingoArchive->addCode(script.decode(Common::kMacRoman), kMovieScript, id, nullptr, kLPPForceD2);
}
void Cast::dumpScript(const char *script, ScriptType type, uint16 id) {
diff --git a/engines/director/cast.h b/engines/director/cast.h
index abf7bacef63..2829e5fc3bc 100644
--- a/engines/director/cast.h
+++ b/engines/director/cast.h
@@ -125,7 +125,7 @@ public:
Common::String formatCastSummary(int castId);
private:
- void loadScriptText(Common::SeekableReadStreamEndian &stream, uint16 id);
+ void loadScriptV2(Common::SeekableReadStreamEndian &stream, uint16 id);
void loadFontMap(Common::SeekableReadStreamEndian &stream);
void loadFontMapV4(Common::SeekableReadStreamEndian &stream);
void loadFXmp(Common::SeekableReadStreamEndian &stream);
diff --git a/engines/director/lingo/lingo-codegen.cpp b/engines/director/lingo/lingo-codegen.cpp
index 413b512c993..43be69168a8 100644
--- a/engines/director/lingo/lingo-codegen.cpp
+++ b/engines/director/lingo/lingo-codegen.cpp
@@ -116,7 +116,7 @@ ScriptContext *LingoCompiler::compileAnonymous(const Common::U32String &code) {
return compileLingo(code, nullptr, kNoneScript, CastMemberID(0, 0), "[anonymous]", true);
}
-ScriptContext *LingoCompiler::compileLingo(const Common::U32String &code, LingoArchive *archive, ScriptType type, CastMemberID id, const Common::String &scriptName, bool anonymous) {
+ScriptContext *LingoCompiler::compileLingo(const Common::U32String &code, LingoArchive *archive, ScriptType type, CastMemberID id, const Common::String &scriptName, bool anonymous, uint32 preprocFlags) {
_assemblyArchive = archive;
_assemblyAST = nullptr;
ScriptContext *mainContext = _assemblyContext = new ScriptContext(scriptName, type, id.member);
@@ -127,7 +127,7 @@ ScriptContext *LingoCompiler::compileLingo(const Common::U32String &code, LingoA
_hadError = false;
// Preprocess the code for ease of the parser
- Common::String codeNorm = codePreprocessor(code, archive, type, id).encode(Common::kUtf8);
+ Common::String codeNorm = codePreprocessor(code, archive, type, id, preprocFlags).encode(Common::kUtf8);
const char *utf8Code = codeNorm.c_str();
// Parse the Lingo and build an AST
diff --git a/engines/director/lingo/lingo-codegen.h b/engines/director/lingo/lingo-codegen.h
index b821006abf0..f0d5e2ce98c 100644
--- a/engines/director/lingo/lingo-codegen.h
+++ b/engines/director/lingo/lingo-codegen.h
@@ -34,7 +34,7 @@ public:
virtual ~LingoCompiler() {}
ScriptContext *compileAnonymous(const Common::U32String &code);
- ScriptContext *compileLingo(const Common::U32String &code, LingoArchive *archive, ScriptType type, CastMemberID id, const Common::String &scriptName, bool anonyomous = false);
+ ScriptContext *compileLingo(const Common::U32String &code, LingoArchive *archive, ScriptType type, CastMemberID id, const Common::String &scriptName, bool anonyomous = false, uint32 preprocFlags = kLPPNone);
ScriptContext *compileLingoV4(Common::SeekableReadStreamEndian &stream, uint16 lctxIndex, LingoArchive *archive, const Common::String &archName, uint16 version);
int code1(inst code) { _currentAssembly->push_back(code); return _currentAssembly->size() - 1; }
@@ -128,7 +128,7 @@ private:
public:
// lingo-preprocessor.cpp
- Common::U32String codePreprocessor(const Common::U32String &code, LingoArchive *archive, ScriptType type, CastMemberID id, bool simple = false);
+ Common::U32String codePreprocessor(const Common::U32String &code, LingoArchive *archive, ScriptType type, CastMemberID id, uint32 flags);
// lingo-patcher.cpp
Common::U32String patchLingoCode(const Common::U32String &line, LingoArchive *archive, ScriptType type, CastMemberID id, int linenumber);
diff --git a/engines/director/lingo/lingo-preprocessor.cpp b/engines/director/lingo/lingo-preprocessor.cpp
index bfbf1373261..b11be73f2d8 100644
--- a/engines/director/lingo/lingo-preprocessor.cpp
+++ b/engines/director/lingo/lingo-preprocessor.cpp
@@ -62,7 +62,7 @@ static Common::U32String nexttok(const Common::u32char_type_t *s, const Common::
return res;
}
-Common::U32String LingoCompiler::codePreprocessor(const Common::U32String &code, LingoArchive *archive, ScriptType type, CastMemberID id, bool simple) {
+Common::U32String LingoCompiler::codePreprocessor(const Common::U32String &code, LingoArchive *archive, ScriptType type, CastMemberID id, uint32 flags) {
const Common::u32char_type_t *s = code.c_str();
Common::U32String res;
@@ -161,7 +161,7 @@ Common::U32String LingoCompiler::codePreprocessor(const Common::U32String &code,
s++;
}
- if (simple)
+ if (flags & kLPPSimple)
return res;
tmp = res;
@@ -193,9 +193,15 @@ Common::U32String LingoCompiler::codePreprocessor(const Common::U32String &code,
if (!defFound && (type == kMovieScript || type == kCastScript) && (g_director->getVersion() < 400 || g_director->getCurrentMovie()->_allowOutdatedLingo)) {
tok = nexttok(line.c_str());
- if (tok.equals(macro) || tok.equals(factory) || tok.equals(on) || tok.equals(global) || tok.equals(property)) {
+ if (tok.equals(macro) || tok.equals(factory)) {
defFound = true;
- } else {
+ } else if (!(flags & kLPPForceD2)) {
+ if (tok.equals(on) || tok.equals(global) || tok.equals(property)) {
+ defFound = true;
+ }
+ }
+
+ if (!defFound) {
debugC(2, kDebugParse | kDebugPreprocess, "skipping line before first definition");
for (int i = 0; i < continuationCount; i++) {
res += CONTINUATION;
diff --git a/engines/director/lingo/lingo.cpp b/engines/director/lingo/lingo.cpp
index 3e85f4751d6..cb6d7794e26 100644
--- a/engines/director/lingo/lingo.cpp
+++ b/engines/director/lingo/lingo.cpp
@@ -322,7 +322,7 @@ Symbol Lingo::getHandler(const Common::String &name) {
return sym;
}
-void LingoArchive::addCode(const Common::U32String &code, ScriptType type, uint16 id, const char *scriptName) {
+void LingoArchive::addCode(const Common::U32String &code, ScriptType type, uint16 id, const char *scriptName, uint32 preprocFlags) {
debugC(1, kDebugCompile, "Add code for type %s(%d) with id %d in '%s%s'\n"
"***********\n%s\n\n***********", scriptType2str(type), type, id, utf8ToPrintable(g_director->getCurrentPath()).c_str(), utf8ToPrintable(cast->getMacName()).c_str(), code.encode().c_str());
@@ -340,7 +340,7 @@ void LingoArchive::addCode(const Common::U32String &code, ScriptType type, uint1
else
contextName = Common::String::format("%d", id);
- ScriptContext *sc = g_lingo->_compiler->compileLingo(code, this, type, CastMemberID(id, cast->_castLibID), contextName);
+ ScriptContext *sc = g_lingo->_compiler->compileLingo(code, this, type, CastMemberID(id, cast->_castLibID), contextName, false, preprocFlags);
if (sc) {
scriptContexts[type][id] = sc;
*sc->_refCount += 1;
diff --git a/engines/director/lingo/lingo.h b/engines/director/lingo/lingo.h
index 04268942a39..0f07759dc74 100644
--- a/engines/director/lingo/lingo.h
+++ b/engines/director/lingo/lingo.h
@@ -284,7 +284,7 @@ struct LingoArchive {
Common::String getName(uint16 id);
Common::String formatFunctionList(const char *prefix);
- void addCode(const Common::U32String &code, ScriptType type, uint16 id, const char *scriptName = nullptr);
+ void addCode(const Common::U32String &code, ScriptType type, uint16 id, const char *scriptName = nullptr, uint32 preprocFlags = kLPPNone);
void removeCode(ScriptType type, uint16 id);
void replaceCode(const Common::U32String &code, ScriptType type, uint16 id, const char *scriptName = nullptr);
void addCodeV4(Common::SeekableReadStreamEndian &stream, uint16 lctxIndex, const Common::String &archName, uint16 version);
diff --git a/engines/director/types.h b/engines/director/types.h
index df7931b2a6b..c1fc76cba2c 100644
--- a/engines/director/types.h
+++ b/engines/director/types.h
@@ -375,6 +375,12 @@ enum VarType {
kVarLocal
};
+enum LPPFlag {
+ kLPPNone = 0,
+ kLPPSimple = 1 << 0,
+ kLPPForceD2 = 1 << 1,
+};
+
struct CastMemberID {
int member;
int castLib;
More information about the Scummvm-git-logs
mailing list