[Scummvm-git-logs] scummvm master -> 8727d0a800a9db652beba29236461eef79ed6396

djsrv dservilla at gmail.com
Tue Jul 14 22:18:26 UTC 2020


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

Summary:
8727d0a800 DIRECTOR: LINGO: Re-implement unused script list


Commit: 8727d0a800a9db652beba29236461eef79ed6396
    https://github.com/scummvm/scummvm/commit/8727d0a800a9db652beba29236461eef79ed6396
Author: djsrv (dservilla at gmail.com)
Date: 2020-07-14T18:16:19-04:00

Commit Message:
DIRECTOR: LINGO: Re-implement unused script list

List nodes are 0-indexed, and nodes can point to lower indices.

Changed paths:
    engines/director/cast.cpp


diff --git a/engines/director/cast.cpp b/engines/director/cast.cpp
index 60cc57911a..b8d2c80906 100644
--- a/engines/director/cast.cpp
+++ b/engines/director/cast.cpp
@@ -879,6 +879,17 @@ void Cast::loadLingoNames(Common::SeekableSubReadStreamEndian &stream) {
 	}
 }
 
+struct LingoContextEntry {
+	int32 index;
+	int16 nextUnused;
+	bool unused;
+
+	LingoContextEntry(int32 i, int16 n);
+};
+
+LingoContextEntry::LingoContextEntry(int32 i, int16 n)
+	: index(i), nextUnused(n), unused(false) {}
+
 void Cast::loadLingoContext(Common::SeekableSubReadStreamEndian &stream) {
 	if (_vm->getVersion() >= 4) {
 		debugC(1, kDebugCompile, "Add V4 script context");
@@ -902,9 +913,9 @@ void Cast::loadLingoContext(Common::SeekableSubReadStreamEndian &stream) {
 		/* uint32 nameTableId = */ stream.readUint32();
 		/* int16 validCount = */ stream.readSint16();
 		/* uint16 flags = */ stream.readUint16();
-		/* int16 firstUnused = */ stream.readSint16();
+		int16 firstUnused = stream.readSint16();
 
-		Common::Array<int16> lscr;
+		Common::Array<LingoContextEntry> entries;
 		stream.seek(itemsOffset);
 		for (int16 i = 1; i <= itemCount; i++) {
 			if (debugChannelSet(5, kDebugLoading)) {
@@ -915,16 +926,36 @@ void Cast::loadLingoContext(Common::SeekableSubReadStreamEndian &stream) {
 			stream.readUint32();
 			int32 index = stream.readSint32();
 			/* uint16 entryFlags = */ stream.readUint16();
-			/* int16 nextUnused = */ stream.readSint16();
-			lscr.push_back(index);
+			int16 nextUnused = stream.readSint16();
+			entries.push_back(LingoContextEntry(index, nextUnused));
 		}
 
-		for (int16 i = 0; i < (int16)lscr.size(); i++) {
-			if (lscr[i] >= 0) {
-				Common::SeekableSubReadStreamEndian *r;
-				_lingoArchive->addCodeV4(*(r = _castArchive->getResource(MKTAG('L', 's', 'c', 'r'), lscr[i])), i + 1, _macName);
-				delete r;
+		// mark unused entries
+		int16 nextUnused = firstUnused ;
+		while (0 <= nextUnused && nextUnused < (int16)entries.size()) {
+			LingoContextEntry &entry = entries[nextUnused];
+			entry.unused = true;
+			nextUnused = entry.nextUnused;
+		}
+
+		// compile scripts
+		for (int16 i = 1; i <= (int16)entries.size(); i++) {
+			LingoContextEntry &entry = entries[i - 1];
+			if (entry.unused && entry.index < 0) {
+				debugC(1, kDebugCompile, "Cast::loadLingoContext: Script %d is unused and empty", i);
+				continue;
+			}
+			if (entry.unused) {
+				debugC(1, kDebugCompile, "Cast::loadLingoContext: Script %d is unused but not empty", i);
+				continue;
 			}
+			if (entry.index < 0) {
+				debugC(1, kDebugCompile, "Cast::loadLingoContext: Script %d is used but empty", i);
+				continue;
+			}
+			Common::SeekableSubReadStreamEndian *r;
+			_lingoArchive->addCodeV4(*(r = _castArchive->getResource(MKTAG('L', 's', 'c', 'r'), entry.index)), i, _macName);
+			delete r;
 		}
 
 		// repair script type + cast ID




More information about the Scummvm-git-logs mailing list