[Scummvm-git-logs] scummvm master -> 38fe8034b714c971e9000a01a8cd4156d867328b

sev- noreply at scummvm.org
Sat Aug 16 22:25:17 UTC 2025


This automated email contains information about 2 new commits which have been
pushed to the 'scummvm' repo located at https://api.github.com/repos/scummvm/scummvm .

Summary:
66d239f56b DIRECTOR: Fix the fetching of cast member while dumping lingo scripts
38fe8034b7 DIRECTOR: Fix usage of `LingoDec::Script::castId` in `DT::getHandler()`


Commit: 66d239f56bd96f72b690f78e01e90c7e50ec2709
    https://github.com/scummvm/scummvm/commit/66d239f56bd96f72b690f78e01e90c7e50ec2709
Author: Malhar (themalharbdv2046 at gmail.com)
Date: 2025-08-17T00:25:13+02:00

Commit Message:
DIRECTOR: Fix the fetching of cast member while dumping lingo scripts

The cast id read in the Script data is unreliable
It could be something other than cast id
Hence, fetch the cast member from the script id, rather than relying
on the read value

Changed paths:
    engines/director/cast.cpp
    engines/director/lingo/lingodec/script.h


diff --git a/engines/director/cast.cpp b/engines/director/cast.cpp
index 0b72c55ae32..b0084f3c103 100644
--- a/engines/director/cast.cpp
+++ b/engines/director/cast.cpp
@@ -1651,7 +1651,7 @@ void Cast::loadLingoContext(Common::SeekableReadStreamEndian &stream) {
 		_lingodec->parseScripts();
 
 		for (auto it = _lingodec->scripts.begin(); it != _lingodec->scripts.end(); ++it) {
-			debugC(9, kDebugCompile, "[%d/%d] %s", it->second->castID, it->first, it->second->scriptText("\n", false).c_str());
+			debugC(9, kDebugCompile, "[%d/%d] %s", _castsScriptIds[it->first], it->first, it->second->scriptText("\n", false).c_str());
 		}
 
 		if (ConfMan.getBool("dump_scripts")) {
@@ -1659,17 +1659,15 @@ void Cast::loadLingoContext(Common::SeekableReadStreamEndian &stream) {
 				Common::DumpFile out;
 				ScriptType scriptType = kNoneScript;
 
-				if (_loadedCast->contains(it->second->castID)) {
-					CastMember *member = _loadedCast->getVal(it->second->castID);
-					if (member && member->_type == kCastLingoScript) {
-						scriptType = ((ScriptCastMember *)member)->_scriptType;
-					} else {
-						scriptType = kCastScript;
-					}
+				CastMember *member = getCastMemberByScriptId(it->first);
+				if (member && member->_type == kCastLingoScript) {
+					scriptType = ((ScriptCastMember *)member)->_scriptType;
+				} else if (member) {
+					scriptType = kCastScript;
 				}
 
 				Common::String filename = encodePathForDump(_macName);
-				Common::Path lingoPath(dumpScriptName(filename.c_str(), scriptType, it->second->castID, "lingo"));
+				Common::Path lingoPath(dumpScriptName(filename.c_str(), scriptType, _castsScriptIds[it->first], "lingo"));
 
 				if (out.open(lingoPath, true)) {
 					Common::String decompiled = it->second->scriptText("\n", false);
diff --git a/engines/director/lingo/lingodec/script.h b/engines/director/lingo/lingodec/script.h
index 591857c6124..71c40cfe310 100644
--- a/engines/director/lingo/lingodec/script.h
+++ b/engines/director/lingo/lingodec/script.h
@@ -46,6 +46,7 @@ struct Script {
 	/* 38 */ uint32 scriptFlags;
 	/* 42 */ int16 unk42;
 	/* 44 */ int16 unk43;
+	// This castID is not reliable
 	/* 46 */ int16 castID;
 	/* 48 */ int16 factoryNameID;
 	/* 50 */ uint16 handlerVectorsCount;


Commit: 38fe8034b714c971e9000a01a8cd4156d867328b
    https://github.com/scummvm/scummvm/commit/38fe8034b714c971e9000a01a8cd4156d867328b
Author: Malhar (themalharbdv2046 at gmail.com)
Date: 2025-08-17T00:25:13+02:00

Commit Message:
DIRECTOR: Fix usage of `LingoDec::Script::castId` in `DT::getHandler()`

The `LingoDec::Script::castId` read directly from readStream is
unreliable in the sense, it may or may not reflect the correct castId
of the cast member associated with it

Hence, instead of using this value, we can use the cast member info
read in `CASt` resource, which contains the cast id as well as the
script id for the cast and stored in `Cast::_castScriptIds`
This gives us the correct cast id of the script

Changed paths:
    engines/director/cast.cpp
    engines/director/cast.h
    engines/director/debugger/debugtools.cpp


diff --git a/engines/director/cast.cpp b/engines/director/cast.cpp
index b0084f3c103..be0e862197b 100644
--- a/engines/director/cast.cpp
+++ b/engines/director/cast.cpp
@@ -182,6 +182,13 @@ CastMember *Cast::getCastMemberByScriptId(int scriptId) {
 	return nullptr;
 }
 
+int Cast::getCastIdByScriptId(uint32 scriptId) const {
+	if (_castsScriptIds.contains(scriptId)) {
+		return _castsScriptIds.getVal(scriptId);
+	}
+	return -1;
+}
+
 CastMemberInfo *Cast::getCastMemberInfo(int castId) {
 	CastMemberInfo *result = nullptr;
 
diff --git a/engines/director/cast.h b/engines/director/cast.h
index 208a4e65509..a38bafdfe02 100644
--- a/engines/director/cast.h
+++ b/engines/director/cast.h
@@ -126,6 +126,7 @@ public:
 	CastMember *getCastMember(int castId, bool load = true);
 	CastMember *getCastMemberByNameAndType(const Common::String &name, CastType type);
 	CastMember *getCastMemberByScriptId(int scriptId);
+	int getCastIdByScriptId(uint32 scriptId) const;
 	CastMemberInfo *getCastMemberInfo(int castId);
 	const Stxt *getStxt(int castId);
 	Common::String getLinkedPath(int castId);
diff --git a/engines/director/debugger/debugtools.cpp b/engines/director/debugger/debugtools.cpp
index 15b12f061eb..63006a602dd 100644
--- a/engines/director/debugger/debugtools.cpp
+++ b/engines/director/debugger/debugtools.cpp
@@ -49,9 +49,9 @@ const LingoDec::Handler *getHandler(const Cast *cast, CastMemberID id, const Com
 	if (!cast->_lingodec)
 		return nullptr;
 	for (auto p : cast->_lingodec->scripts) {
-		if ((p.second->castID & 0xFFFF) != id.member)
+		if (cast->getCastIdByScriptId(p.first) != id.member)
 			continue;
-		;
+
 		for (const LingoDec::Handler &handler : p.second->handlers) {
 			if (handler.name == handlerId) {
 				return &handler;




More information about the Scummvm-git-logs mailing list