[Scummvm-git-logs] scummvm master -> 06e9fb125d89731453d2b90682c0d6ee6c8f9b3a

moralrecordings code at moral.net.au
Wed May 6 16:34:19 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:
06e9fb125d DIRECTOR: Fix cast indexing.


Commit: 06e9fb125d89731453d2b90682c0d6ee6c8f9b3a
    https://github.com/scummvm/scummvm/commit/06e9fb125d89731453d2b90682c0d6ee6c8f9b3a
Author: Scott Percival (code at moral.net.au)
Date: 2020-05-07T00:33:13+08:00

Commit Message:
DIRECTOR: Fix cast indexing.

The indexing of the cast list is stored relative to the position
of the first cast member. Previously it was assumed the list
started at 1, but this base offset is stored in the VWCF config.

Changed paths:
    engines/director/archive.cpp
    engines/director/resource.cpp
    engines/director/score.cpp


diff --git a/engines/director/archive.cpp b/engines/director/archive.cpp
index 37e4e411ef..d700aae890 100644
--- a/engines/director/archive.cpp
+++ b/engines/director/archive.cpp
@@ -533,7 +533,7 @@ bool RIFXArchive::openStream(Common::SeekableReadStream *stream, uint32 startOff
 
 			Resource &res = resources[index];
 			res.index = index;
-			res.castId = i + 1;
+			res.castId = i;
 			_types[castTag][res.castId] = res;
 		}
 		debugC(2, kDebugLoading, "]");
diff --git a/engines/director/resource.cpp b/engines/director/resource.cpp
index d85b01a868..c2f9c50df3 100644
--- a/engines/director/resource.cpp
+++ b/engines/director/resource.cpp
@@ -355,7 +355,7 @@ void DirectorEngine::loadSharedCastsFrom(Common::String filename) {
 		}
 	}
 
-	Common::Array<uint16> cast = sharedCast->getResourceIDList(MKTAG('C','A','S','t'));
+	Common::Array<uint16> cast = sharedCast->getResourceIDList(MKTAG('C', 'A', 'S', 't'));
 	if (!_sharedScore->_loadedCast)
 		_sharedScore->_loadedCast = new Common::HashMap<int, Cast *>();
 
@@ -363,8 +363,10 @@ void DirectorEngine::loadSharedCastsFrom(Common::String filename) {
 		debug(0, "****** Loading %d CASt resources", cast.size());
 
 		for (Common::Array<uint16>::iterator iterator = cast.begin(); iterator != cast.end(); ++iterator) {
+			Common::SeekableSubReadStreamEndian *stream = sharedCast->getResource(MKTAG('C', 'A', 'S', 't'), *iterator);
 			Resource res = sharedCast->getResourceDetail(MKTAG('C', 'A', 'S', 't'), *iterator);
-			_sharedScore->loadCastData(*sharedCast->getResource(MKTAG('C', 'A', 'S', 't'), *iterator), *iterator, &res);
+			_sharedScore->loadCastData(*stream, *iterator, &res);
+			delete stream;
 		}
 	}
 
diff --git a/engines/director/score.cpp b/engines/director/score.cpp
index 9ec016f74b..0d365b39a3 100644
--- a/engines/director/score.cpp
+++ b/engines/director/score.cpp
@@ -771,6 +771,9 @@ void Score::setSpriteCasts() {
 }
 
 void Score::loadCastData(Common::SeekableSubReadStreamEndian &stream, uint16 id, Resource *res) {
+	// IDs are stored as relative to the start of the cast array.
+	id += _castArrayStart;
+
 	// D4+ variant
 	if (stream.size() == 0)
 		return;




More information about the Scummvm-git-logs mailing list