[Scummvm-git-logs] scummvm master -> 45c49b1195389046f6ac2b0d9d7a8d288f490a3f

sev- sev at scummvm.org
Fri Aug 21 08:52:25 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:
45c49b1195 DIRECTOR: Load DVs only on demand


Commit: 45c49b1195389046f6ac2b0d9d7a8d288f490a3f
    https://github.com/scummvm/scummvm/commit/45c49b1195389046f6ac2b0d9d7a8d288f490a3f
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2020-08-21T10:52:08+02:00

Commit Message:
DIRECTOR: Load DVs only on demand

Changed paths:
    engines/director/cast.cpp
    engines/director/cast.h
    engines/director/channel.cpp


diff --git a/engines/director/cast.cpp b/engines/director/cast.cpp
index f0787eb8cb..cf2cfabceb 100644
--- a/engines/director/cast.cpp
+++ b/engines/director/cast.cpp
@@ -340,7 +340,6 @@ bool Cast::loadArchive() {
 
 	loadCastChildren();
 	loadSoundCasts();
-	loadDigitalVideoCasts();
 
 	return true;
 }
@@ -641,51 +640,47 @@ void Cast::loadSoundCasts() {
 	}
 }
 
-void Cast::loadDigitalVideoCasts() {
-	debugC(1, kDebugLoading, "****** Preloading digital video casts");
+Common::String Cast::getVideoPath(int castId) {
+	Common::String res;
+	CastMember *cast = _loadedCast->getVal(castId);
 
-	for (Common::HashMap<int, CastMember *>::iterator c = _loadedCast->begin(); c != _loadedCast->end(); ++c) {
-		if (!c->_value)
-			continue;
+	if (cast->_type != kCastDigitalVideo)
+		return res;
 
-		if (c->_value->_type != kCastDigitalVideo)
-			continue;
+	DigitalVideoCastMember *digitalVideoCast = (DigitalVideoCastMember *)cast;
+	uint32 tag = MKTAG('M', 'o', 'o', 'V');
+	uint16 videoId = (uint16)(castId + _castIDoffset);
 
-		DigitalVideoCastMember *digitalVideoCast = (DigitalVideoCastMember *)c->_value;
-		uint32 tag = MKTAG('M', 'o', 'o', 'V');
-		uint16 videoId = (uint16)(c->_key + _castIDoffset);
-
-		if (_vm->getVersion() >= 400 && digitalVideoCast->_children.size() > 0) {
-			videoId = digitalVideoCast->_children[0].index;
-			tag = digitalVideoCast->_children[0].tag;
-		}
+	if (_vm->getVersion() >= 400 && digitalVideoCast->_children.size() > 0) {
+		videoId = digitalVideoCast->_children[0].index;
+		tag = digitalVideoCast->_children[0].tag;
+	}
 
-		Common::SeekableReadStreamEndian *videoData = NULL;
+	Common::SeekableReadStreamEndian *videoData = NULL;
 
-		switch (tag) {
-		case MKTAG('M', 'o', 'o', 'V'):
-			if (_castArchive->hasResource(MKTAG('M', 'o', 'o', 'V'), videoId)) {
-				debugC(2, kDebugLoading, "****** Loading 'MooV' id: %d", videoId);
-				videoData = _castArchive->getResource(MKTAG('M', 'o', 'o', 'V'), videoId);
-			}
-			break;
+	switch (tag) {
+	case MKTAG('M', 'o', 'o', 'V'):
+		if (_castArchive->hasResource(MKTAG('M', 'o', 'o', 'V'), videoId)) {
+			debugC(2, kDebugLoading, "****** Loading 'MooV' id: %d", videoId);
+			videoData = _castArchive->getResource(MKTAG('M', 'o', 'o', 'V'), videoId);
 		}
+		break;
+	}
 
-		if (videoData == NULL || videoData->size() == 0) {
-			// video file is linked, load from the filesystem
+	if (videoData == NULL || videoData->size() == 0) {
+		// video file is linked, load from the filesystem
 
-			Common::String filename = _castsInfo[c->_key]->fileName;
-			Common::String directory = _castsInfo[c->_key]->directory;
-			if (!digitalVideoCast->loadVideo(pathMakeRelative(directory + "\\" + filename))) {
-				warning("Cast::loadDigitalVideoCasts: failed to load QuickTime file for cast member %d", videoId);
-			}
-		} else {
-			warning("STUB: Cast::loadDigitalVideoCasts: unsupported non-zero MooV block");
-		}
-		if (videoData)
-			delete videoData;
+		Common::String filename = _castsInfo[castId]->fileName;
+		Common::String directory = _castsInfo[castId]->directory;
+
+		res = directory + "\\" + filename;
+	} else {
+		warning("STUB: Cast::getVideoPath(%d): unsupported non-zero MooV block", castId);
 	}
+	if (videoData)
+		delete videoData;
 
+	return res;
 }
 
 PaletteV4 Cast::loadPalette(Common::SeekableReadStreamEndian &stream) {
diff --git a/engines/director/cast.h b/engines/director/cast.h
index 15fa8bf562..95ba8f576c 100644
--- a/engines/director/cast.h
+++ b/engines/director/cast.h
@@ -64,7 +64,6 @@ public:
 
 	void loadCastChildren();
 	void loadSoundCasts();
-	void loadDigitalVideoCasts();
 
 	void copyCastStxts();
 	Common::Rect getCastMemberInitialRect(int castId);
@@ -74,6 +73,7 @@ public:
 	CastMember *getCastMemberByScriptId(int scriptId);
 	CastMemberInfo *getCastMemberInfo(int castId);
 	const Stxt *getStxt(int castId);
+	Common::String getVideoPath(int castId);
 
 	void dumpScript(const char *script, ScriptType type, uint16 id);
 
diff --git a/engines/director/channel.cpp b/engines/director/channel.cpp
index a880650db5..7a36e64c56 100644
--- a/engines/director/channel.cpp
+++ b/engines/director/channel.cpp
@@ -24,6 +24,7 @@
 #include "director/movie.h"
 #include "director/score.h"
 #include "director/cursor.h"
+#include "director/cast.h"
 #include "director/channel.h"
 #include "director/sprite.h"
 #include "director/castmember.h"
@@ -275,8 +276,14 @@ void Channel::setClean(Sprite *nextSprite, int spriteId, bool partial) {
 
 	if (nextSprite) {
 		if (_sprite->_castId != nextSprite->_castId && nextSprite->_cast) {
-			if (nextSprite->_cast->_type == kCastDigitalVideo)
-				((DigitalVideoCastMember *)nextSprite->_cast)->startVideo(this);
+			if (nextSprite->_cast->_type == kCastDigitalVideo) {
+				Common::String path = nextSprite->_cast->getCast()->getVideoPath(nextSprite->_castId);
+
+				if (!path.empty()) {
+					((DigitalVideoCastMember *)nextSprite->_cast)->loadVideo(pathMakeRelative(path));
+					((DigitalVideoCastMember *)nextSprite->_cast)->startVideo(this);
+				}
+			}
 		}
 
 		if (_sprite->_puppet || partial) {




More information about the Scummvm-git-logs mailing list