[Scummvm-git-logs] scummvm master -> 92195687929c067bc91d3147a37ee008de076e2b
sev-
sev at scummvm.org
Sun Jul 26 22:48:56 UTC 2020
This automated email contains information about 2 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
30e6f0a01d DIRECTOR: LINGO: Add scripts to the correct cast
9219568792 DIRECTOR: LINGO: Revert use lctxIndex in lscr dumps
Commit: 30e6f0a01d5111826b793932e18cc150e73e11e0
https://github.com/scummvm/scummvm/commit/30e6f0a01d5111826b793932e18cc150e73e11e0
Author: Roland van Laar (roland at rolandvanlaar.nl)
Date: 2020-07-27T00:48:51+02:00
Commit Message:
DIRECTOR: LINGO: Add scripts to the correct cast
Repair the castIds of script when the scripts are loaded.
The castIds that are defined in the scripts can be wrong.
A better way to link scripts with casts is via the scriptId.
To achieve this casts need to be fetched by their scriptId.
This commit implements the necessary getCastMemberByScript functions
to enable fetching a cast by it's scriptId.
Also removes the old way of repairing the castId coupling.
Changed paths:
engines/director/cast.cpp
engines/director/cast.h
engines/director/lingo/lingo-bytecode.cpp
engines/director/movie.cpp
engines/director/movie.h
diff --git a/engines/director/cast.cpp b/engines/director/cast.cpp
index 9dd0901f51..69312d6014 100644
--- a/engines/director/cast.cpp
+++ b/engines/director/cast.cpp
@@ -121,6 +121,13 @@ CastMember *Cast::getCastMemberByName(const Common::String &name) {
return result;
}
+CastMember *Cast::getCastMemberByScriptId(int scriptId) {
+ CastMember *result = nullptr;
+ if (_castsScriptIds.contains(scriptId))
+ result = _loadedCast->getVal(_castsScriptIds[scriptId]);
+ return result;
+}
+
CastMemberInfo *Cast::getCastMemberInfo(int castId) {
CastMemberInfo *result = nullptr;
@@ -930,28 +937,6 @@ void Cast::loadLingoContext(Common::SeekableSubReadStreamEndian &stream) {
delete r;
}
- // repair script type + cast ID
- for (Common::HashMap<uint16, CastMemberInfo *>::iterator it = _castsInfo.begin(); it != _castsInfo.end(); ++it) {
- if (it->_value->scriptId == 0)
- continue;
-
- ScriptType type = kCastScript;
- CastMember *member = _loadedCast->getVal(it->_key);
- if (member->_type == kCastLingoScript) {
- type = static_cast<ScriptCastMember *>(member)->_scriptType;
- }
-
- if (!_lingoArchive->lctxContexts.contains(it->_value->scriptId)) {
- warning("Cast::loadLingoContext: %s %d has invalid script ID %d", scriptType2str(type), it->_key, it->_value->scriptId);
- continue;
- }
-
- ScriptContext *script = _lingoArchive->lctxContexts[it->_value->scriptId];
- debugC(1, kDebugCompile, "Cast::loadLingoContext: Repairing script %d: %s %d -> %s %d", it->_value->scriptId, scriptType2str(script->_scriptType), script->_id, scriptType2str(type), it->_key);
- script->_scriptType = type;
- script->_id = it->_key;
- }
-
// actually define scripts
for (ScriptContextHash::iterator it = _lingoArchive->lctxContexts.begin(); it != _lingoArchive->lctxContexts.end(); ++it) {
ScriptContext *script = it->_value;
@@ -1104,6 +1089,8 @@ void Cast::loadCastInfo(Common::SeekableSubReadStreamEndian &stream, uint16 id)
}
ci->scriptId = castInfo.scriptId;
+ if (ci->scriptId != 0)
+ _castsScriptIds[ci->scriptId] = id;
_castsInfo[id] = ci;
}
diff --git a/engines/director/cast.h b/engines/director/cast.h
index a4c3db710f..0ddb358fc9 100644
--- a/engines/director/cast.h
+++ b/engines/director/cast.h
@@ -71,6 +71,7 @@ public:
void setCastMemberModified(int castId);
CastMember *getCastMember(int castId);
CastMember *getCastMemberByName(const Common::String &name);
+ CastMember *getCastMemberByScriptId(int scriptId);
CastMemberInfo *getCastMemberInfo(int castId);
const Stxt *getStxt(int castId);
@@ -107,6 +108,7 @@ private:
Common::HashMap<uint16, CastMemberInfo *> _castsInfo;
Common::HashMap<Common::String, int, Common::IgnoreCase_Hash, Common::IgnoreCase_EqualTo> _castsNames;
+ Common::HashMap<uint16, int> _castsScriptIds;
};
} // End of namespace Director
diff --git a/engines/director/lingo/lingo-bytecode.cpp b/engines/director/lingo/lingo-bytecode.cpp
index c8ce021c8b..410e319301 100644
--- a/engines/director/lingo/lingo-bytecode.cpp
+++ b/engines/director/lingo/lingo-bytecode.cpp
@@ -898,7 +898,10 @@ ScriptContext *Lingo::compileLingoV4(Common::SeekableSubReadStreamEndian &stream
for (uint32 i = 0; i < 0x4; i++) {
stream.readByte();
}
- uint16 castId = stream.readUint16();
+ /* uint16 castId = */ stream.readUint16();
+ // The script is coupled with to a Cast via the script ID.
+ // This castId isn't always correct.
+
int16 factoryNameId = stream.readSint16();
// offset 50 - contents map
@@ -928,15 +931,18 @@ ScriptContext *Lingo::compileLingoV4(Common::SeekableSubReadStreamEndian &stream
// initialise the script
ScriptType scriptType = kCastScript;
Common::String castName;
- CastMember *member = g_director->getCurrentMovie()->getCastMember(castId);
+ CastMember *member = g_director->getCurrentMovie()->getCastMemberByScriptId(lctxIndex + 1);
+ uint16 castId;
if (member) {
if (member->_type == kCastLingoScript)
scriptType = ((ScriptCastMember *)member)->_scriptType;
+ castId = member->getID();
CastMemberInfo *info = g_director->getCurrentMovie()->getCastMemberInfo(castId);
if (info)
castName = info->name;
} else {
+ castId = -1;
warning("Script %d has invalid cast member %d", lctxIndex, castId);
}
diff --git a/engines/director/movie.cpp b/engines/director/movie.cpp
index 7dac046c6e..6919664b49 100644
--- a/engines/director/movie.cpp
+++ b/engines/director/movie.cpp
@@ -288,6 +288,14 @@ CastMember *Movie::getCastMemberByName(const Common::String &name) {
return result;
}
+CastMember *Movie::getCastMemberByScriptId(int scriptId) {
+ CastMember *result = _cast->getCastMemberByScriptId(scriptId);
+ if (result == nullptr && _sharedCast) {
+ result = _sharedCast->getCastMemberByScriptId(scriptId);
+ }
+ return result;
+}
+
CastMemberInfo *Movie::getCastMemberInfo(int castId) {
CastMemberInfo *result = _cast->getCastMemberInfo(castId);
if (result == nullptr && _sharedCast) {
diff --git a/engines/director/movie.h b/engines/director/movie.h
index 34eaab1857..757891c4ec 100644
--- a/engines/director/movie.h
+++ b/engines/director/movie.h
@@ -104,6 +104,7 @@ public:
CastMember *getCastMember(int castId);
CastMember *getCastMemberByName(const Common::String &name);
+ CastMember *getCastMemberByScriptId(int scriptId);
CastMemberInfo *getCastMemberInfo(int castId);
const Stxt *getStxt(int castId);
Commit: 92195687929c067bc91d3147a37ee008de076e2b
https://github.com/scummvm/scummvm/commit/92195687929c067bc91d3147a37ee008de076e2b
Author: Roland van Laar (roland at rolandvanlaar.nl)
Date: 2020-07-27T00:48:51+02:00
Commit Message:
DIRECTOR: LINGO: Revert use lctxIndex in lscr dumps
This reverts commit 274be0598648ae836f0c335ef33caa78b25258bb.
The castIds are repaired during the loading of the scripts
and thus can be dumped based on their castId again.
Changed paths:
engines/director/lingo/lingo-bytecode.cpp
diff --git a/engines/director/lingo/lingo-bytecode.cpp b/engines/director/lingo/lingo-bytecode.cpp
index 410e319301..04ae42760f 100644
--- a/engines/director/lingo/lingo-bytecode.cpp
+++ b/engines/director/lingo/lingo-bytecode.cpp
@@ -1154,7 +1154,7 @@ ScriptContext *Lingo::compileLingoV4(Common::SeekableSubReadStreamEndian &stream
bool skipdump = false;
if (ConfMan.getBool("dump_scripts")) {
- Common::String buf = dumpScriptName(archName.c_str(), scriptType, lctxIndex, "lscr");
+ Common::String buf = dumpScriptName(archName.c_str(), scriptType, castId, "lscr");
if (!out.open(buf, true)) {
warning("Lingo::addCodeV4(): Can not open dump file %s", buf.c_str());
More information about the Scummvm-git-logs
mailing list