[Scummvm-git-logs] scummvm master -> d76e876e7a4ff663fd0ac174781935e4a016e377

djsrv dservilla at gmail.com
Thu Jun 11 16:03:58 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:
d76e876e7a DIRECTOR: LINGO: Load shared cast with loadArchive


Commit: d76e876e7a4ff663fd0ac174781935e4a016e377
    https://github.com/scummvm/scummvm/commit/d76e876e7a4ff663fd0ac174781935e4a016e377
Author: djsrv (dservilla at gmail.com)
Date: 2020-06-11T12:02:47-04:00

Commit Message:
DIRECTOR: LINGO: Load shared cast with loadArchive

Changed paths:
    engines/director/director.cpp
    engines/director/resource.cpp
    engines/director/score-loading.cpp
    engines/director/score.h
    engines/director/tests.cpp


diff --git a/engines/director/director.cpp b/engines/director/director.cpp
index a47bde07f1..46ed11ac12 100644
--- a/engines/director/director.cpp
+++ b/engines/director/director.cpp
@@ -230,7 +230,7 @@ Common::Error DirectorEngine::run() {
 			debug(0, "@@@@   Score name '%s' in '%s'", _currentScore->getMacName().c_str(), _currentPath.c_str());
 			debug(0, "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n");
 
-			bool goodMovie = _currentScore->loadArchive();
+			bool goodMovie = _currentScore->loadArchive(false);
 
 			// If we came in a loop, then skip as requested
 			if (!_nextMovie.frameS.empty()) {
diff --git a/engines/director/resource.cpp b/engines/director/resource.cpp
index 2be6b588b7..16d279408d 100644
--- a/engines/director/resource.cpp
+++ b/engines/director/resource.cpp
@@ -281,8 +281,6 @@ void DirectorEngine::loadSharedCastsFrom(Common::String filename) {
 			return;
 	}
 
-	Common::SeekableSubReadStreamEndian *r;
-
 	clearSharedCast();
 
 	Archive *sharedCast = createArchive();
@@ -303,78 +301,7 @@ void DirectorEngine::loadSharedCastsFrom(Common::String filename) {
 	_lingo->_archiveIndex = 1;
 	_sharedScore = new Score(this);
 	_sharedScore->setArchive(sharedCast);
-
-	if (sharedCast->hasResource(MKTAG('F', 'O', 'N', 'D'), -1)) {
-		debug("loadSharedCastsFrom(): Shared cast has fonts. Loading....");
-
-		_wm->_fontMan->loadFonts(filename);
-	}
-
-	_sharedScore->loadConfig(*(r = sharedCast->getResource(MKTAG('V','W','C','F'), 1024)));
-	delete r;
-
-	if (getVersion() < 4) {
-		_sharedScore->_castIDoffset = sharedCast->getResourceIDList(MKTAG('V', 'W', 'C', 'R'))[0];
-		_sharedScore->loadCastDataVWCR(*(r = sharedCast->getResource(MKTAG('V','W','C','R'), _sharedScore->_castIDoffset)));
-		delete r;
-	}
-
-	// Try to load script context
-	if (getVersion() >= 4) {
-		Common::Array<uint16> lctx = sharedCast->getResourceIDList(MKTAG('L','c','t','x'));
-		if (lctx.size() > 0) {
-			debugC(2, kDebugLoading, "****** Loading %d Lctx resources", lctx.size());
-
-			for (Common::Array<uint16>::iterator iterator = lctx.begin(); iterator != lctx.end(); ++iterator) {
-				_sharedScore->loadLingoContext(*(r = sharedCast->getResource(MKTAG('L','c','t','x'), *iterator)));
-				delete r;
-			}
-		}
-	}
-
-	// Try to load script name lists
-	if (getVersion() >= 4) {
-		Common::Array<uint16> lnam = sharedCast->getResourceIDList(MKTAG('L','n','a','m'));
-		if (lnam.size() > 0) {
-
-			int maxLnam = -1;
-			for (Common::Array<uint16>::iterator iterator = lnam.begin(); iterator != lnam.end(); ++iterator) {
-				maxLnam = MAX(maxLnam, (int)*iterator);
-			}
-			debugC(2, kDebugLoading, "****** Loading Lnam resource with highest ID (%d)", maxLnam);
-			_sharedScore->loadLingoNames(*(r = sharedCast->getResource(MKTAG('L','n','a','m'), maxLnam)));
-			delete r;
-		}
-	}
-
-	Common::Array<uint16> vwci = sharedCast->getResourceIDList(MKTAG('V', 'W', 'C', 'I'));
-	if (vwci.size() > 0) {
-		debug(0, "****** Loading %d CastInfo resources", vwci.size());
-
-		for (Common::Array<uint16>::iterator iterator = vwci.begin(); iterator != vwci.end(); ++iterator) {
-			_sharedScore->loadCastInfo(*(r = sharedCast->getResource(MKTAG('V', 'W', 'C', 'I'), *iterator)), *iterator);
-			delete r;
-		}
-	}
-
-	Common::Array<uint16> cast = sharedCast->getResourceIDList(MKTAG('C', 'A', 'S', 't'));
-	if (!_sharedScore->_loadedCast)
-		_sharedScore->_loadedCast = new Common::HashMap<int, Cast *>();
-
-	if (cast.size() > 0) {
-		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(*stream, *iterator, &res);
-			delete stream;
-		}
-	}
-
-	_sharedScore->setSpriteCasts();
-	_sharedScore->loadSpriteImages(true);
-
+	_sharedScore->loadArchive(true);
 	_lingo->_archiveIndex = 0;
 }
 
diff --git a/engines/director/score-loading.cpp b/engines/director/score-loading.cpp
index 8b9bb0fb54..533018d32a 100644
--- a/engines/director/score-loading.cpp
+++ b/engines/director/score-loading.cpp
@@ -77,7 +77,7 @@ void Score::setArchive(Archive *archive) {
 	}
 }
 
-bool Score::loadArchive() {
+bool Score::loadArchive(bool isSharedCast) {
 	Common::Array<uint16> clutList = _movieArchive->getResourceIDList(MKTAG('C', 'L', 'U', 'T'));
 	Common::SeekableSubReadStreamEndian *r = nullptr;
 
@@ -98,16 +98,20 @@ bool Score::loadArchive() {
 
 	// Font Directory
 	if (_movieArchive->hasResource(MKTAG('F', 'O', 'N', 'D'), -1)) {
-		debug("STUB: Unhandled FOND resource");
+		debug("Score::loadArchive(): Movie has fonts. Loading....");
+
+		g_director->_wm->_fontMan->loadFonts(_movieArchive->getFileName());
 	}
 
 	// Score
-	if (!_movieArchive->hasResource(MKTAG('V', 'W', 'S', 'C'), -1)) {
-		warning("Score::loadArchive(): Wrong movie format. VWSC resource missing");
-		return false;
+	if (!isSharedCast) {
+		if (!_movieArchive->hasResource(MKTAG('V', 'W', 'S', 'C'), -1)) {
+			warning("Score::loadArchive(): Wrong movie format. VWSC resource missing");
+			return false;
+		}
+		loadFrames(*(r = _movieArchive->getFirstResource(MKTAG('V', 'W', 'S', 'C'))));
+		delete r;
 	}
-	loadFrames(*(r = _movieArchive->getFirstResource(MKTAG('V', 'W', 'S', 'C'))));
-	delete r;
 
 	// Configuration Information
 	if (_movieArchive->hasResource(MKTAG('V', 'W', 'C', 'F'), -1)) {
@@ -250,8 +254,8 @@ bool Score::loadArchive() {
 	copyCastStxts();
 
 	setSpriteCasts();
-	loadSpriteImages(false);
-	loadSpriteSounds(false);
+	loadSpriteImages(isSharedCast);
+	loadSpriteSounds(isSharedCast);
 	setSpriteBboxes();
 
 	return true;
diff --git a/engines/director/score.h b/engines/director/score.h
index dea4df24f1..0c38a2daf9 100644
--- a/engines/director/score.h
+++ b/engines/director/score.h
@@ -99,7 +99,7 @@ public:
 
 	static Common::Rect readRect(Common::ReadStreamEndian &stream);
 	static int compareLabels(const void *a, const void *b);
-	bool loadArchive();
+	bool loadArchive(bool isSharedCast);
 	void setStartToLabel(Common::String label);
 	void gotoLoop();
 	void gotoNext();
diff --git a/engines/director/tests.cpp b/engines/director/tests.cpp
index 6bfd92c9a0..0b352f5041 100644
--- a/engines/director/tests.cpp
+++ b/engines/director/tests.cpp
@@ -286,7 +286,7 @@ void DirectorEngine::runTests() {
 	_mainArchive->openStream(stream, 0);
 	_currentScore = new Score(this);
 	_currentScore->setArchive(_mainArchive);
-	_currentScore->loadArchive();
+	_currentScore->loadArchive(false);
 
 	if (debugChannelSet(-1, kDebugText)) {
 		testFontScaling();




More information about the Scummvm-git-logs mailing list