[Scummvm-git-logs] scummvm master -> 40861f3dd8c89c0b1825c372d3174b873369201e

djsrv dservilla at gmail.com
Thu Jul 23 15:38:38 UTC 2020


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

Summary:
5656716fe2 DIRECTOR: Don't read nonexistent sound data
40861f3dd8 DIRECTOR: Move flags1 to common cast loading


Commit: 5656716fe291ae8a7411ddc1a765aff774640c7a
    https://github.com/scummvm/scummvm/commit/5656716fe291ae8a7411ddc1a765aff774640c7a
Author: djsrv (dservilla at gmail.com)
Date: 2020-07-23T11:38:13-04:00

Commit Message:
DIRECTOR: Don't read nonexistent sound data

Changed paths:
    engines/director/castmember.cpp


diff --git a/engines/director/castmember.cpp b/engines/director/castmember.cpp
index 099b3fd5a2..564457951b 100644
--- a/engines/director/castmember.cpp
+++ b/engines/director/castmember.cpp
@@ -292,13 +292,6 @@ SoundCastMember::SoundCastMember(Cast *cast, uint16 castId, Common::SeekableRead
 	_type = kCastSound;
 	_audio = nullptr;
 	_looping = 0;
-
-	if (version == 4) {
-		for (int i = 0; i < 0xf; i++) {
-			stream.readByte();
-		}
-		_looping = stream.readByte() & 0x10 ? 0 : 1;
-	}
 }
 
 TextCastMember::TextCastMember(Cast *cast, uint16 castId, Common::SeekableReadStreamEndian &stream, uint16 version, bool asButton)


Commit: 40861f3dd8c89c0b1825c372d3174b873369201e
    https://github.com/scummvm/scummvm/commit/40861f3dd8c89c0b1825c372d3174b873369201e
Author: djsrv (dservilla at gmail.com)
Date: 2020-07-23T11:38:13-04:00

Commit Message:
DIRECTOR: Move flags1 to common cast loading

This seems to be present in pretty much every cast member even though
it's usually unused.

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


diff --git a/engines/director/cast.cpp b/engines/director/cast.cpp
index fc835aa2c4..62dbdf31a6 100644
--- a/engines/director/cast.cpp
+++ b/engines/director/cast.cpp
@@ -624,9 +624,16 @@ void Cast::loadCastDataVWCR(Common::SeekableSubReadStreamEndian &stream) {
 		if (debugChannelSet(5, kDebugLoading))
 			stream.hexdump(size);
 
+		// these bytes are common but included in cast size
 		uint8 castType = stream.readByte();
+		size -= 1;
+		uint8 flags1 = 0;
+		if (size) {
+			flags1 = stream.readByte();
+			size -= 1;
+		}
 
-		int returnPos = stream.pos() + size - 1;
+		int returnPos = stream.pos() + size;
 		switch (castType) {
 		case kCastBitmap:
 			debugC(3, kDebugLoading, "Cast::loadCastDataVWCR(): CastTypes id: %d(%s) BitmapCastMember", id, numToCastNum(id));
@@ -637,11 +644,11 @@ void Cast::loadCastDataVWCR(Common::SeekableSubReadStreamEndian &stream) {
 			else
 				error("Cast::loadCastDataVWCR(): non-existent reference to BitmapCastMember");
 
-			_loadedCast->setVal(id, new BitmapCastMember(this, id, stream, tag, _vm->getVersion()));
+			_loadedCast->setVal(id, new BitmapCastMember(this, id, stream, tag, _vm->getVersion(), flags1));
 			break;
 		case kCastText:
 			debugC(3, kDebugLoading, "Cast::loadCastDataVWCR(): CastTypes id: %d(%s) TextCastMember", id, numToCastNum(id));
-			_loadedCast->setVal(id, new TextCastMember(this, id, stream, _vm->getVersion()));
+			_loadedCast->setVal(id, new TextCastMember(this, id, stream, _vm->getVersion(), flags1));
 			break;
 		case kCastShape:
 			debugC(3, kDebugLoading, "Cast::loadCastDataVWCR(): CastTypes id: %d(%s) ShapeCastMember", id, numToCastNum(id));
@@ -649,7 +656,7 @@ void Cast::loadCastDataVWCR(Common::SeekableSubReadStreamEndian &stream) {
 			break;
 		case kCastButton:
 			debugC(3, kDebugLoading, "Cast::loadCastDataVWCR(): CastTypes id: %d(%s) ButtonCast", id, numToCastNum(id));
-			_loadedCast->setVal(id, new TextCastMember(this, id, stream, _vm->getVersion(), true));
+			_loadedCast->setVal(id, new TextCastMember(this, id, stream, _vm->getVersion(), flags1, true));
 			break;
 		case kCastSound:
 			debugC(3, kDebugLoading, "Cast::loadCastDataVWCR(): CastTypes id: %d(%s) SoundCastMember", id, numToCastNum(id));
@@ -702,7 +709,7 @@ void Cast::loadCastData(Common::SeekableSubReadStreamEndian &stream, uint16 id,
 		stream.hexdump(stream.size());
 
 	uint32 castSize, castInfoSize, size3, castType, castSizeToRead;
-	byte unk1 = 0, unk2 = 0, unk3 = 0;
+	byte flags1 = 0, unk1 = 0, unk2 = 0, unk3 = 0;
 
 	// D2-3 cast members should be loaded in loadCastDataVWCR
 #if 0
@@ -720,10 +727,17 @@ void Cast::loadCastData(Common::SeekableSubReadStreamEndian &stream, uint16 id,
 
 	if (_vm->getVersion() == 4) {
 		castSize = stream.readUint16();
-		castSizeToRead = castSize - 1; // the first byte is castType
+		castSizeToRead = castSize;
 		castInfoSize = stream.readUint32();
 		size3 = 0;
+
+		// these bytes are common but included in cast size
 		castType = stream.readByte();
+		castSizeToRead -= 1;
+		if (castSizeToRead) {
+			flags1 = stream.readByte();
+			castSizeToRead -= 1;
+		}
 	} else if (_vm->getVersion() == 5) {
 		castType = stream.readUint32();
 		size3 = stream.readUint32();
@@ -754,7 +768,7 @@ void Cast::loadCastData(Common::SeekableSubReadStreamEndian &stream, uint16 id,
 	switch (castType) {
 	case kCastBitmap:
 		debugC(3, kDebugLoading, "Cast::loadCastData(): loading kCastBitmap (%d children)", res->children.size());
-		_loadedCast->setVal(id, new BitmapCastMember(this, id, castStream, res->tag, _vm->getVersion()));
+		_loadedCast->setVal(id, new BitmapCastMember(this, id, castStream, res->tag, _vm->getVersion(), flags1));
 		break;
 	case kCastSound:
 		debugC(3, kDebugLoading, "Cast::loadCastData(): loading kCastSound (%d children)", res->children.size());
@@ -762,7 +776,7 @@ void Cast::loadCastData(Common::SeekableSubReadStreamEndian &stream, uint16 id,
 		break;
 	case kCastText:
 		debugC(3, kDebugLoading, "Cast::loadCastData(): loading kCastText (%d children)", res->children.size());
-		_loadedCast->setVal(id, new TextCastMember(this, id, castStream, _vm->getVersion()));
+		_loadedCast->setVal(id, new TextCastMember(this, id, castStream, _vm->getVersion(), flags1));
 		break;
 	case kCastShape:
 		debugC(3, kDebugLoading, "Cast::loadCastData(): loading kCastShape (%d children)", res->children.size());
@@ -770,7 +784,7 @@ void Cast::loadCastData(Common::SeekableSubReadStreamEndian &stream, uint16 id,
 		break;
 	case kCastButton:
 		debugC(3, kDebugLoading, "Cast::loadCastData(): loading kCastButton (%d children)", res->children.size());
-		_loadedCast->setVal(id, new TextCastMember(this, id, castStream, _vm->getVersion(), true));
+		_loadedCast->setVal(id, new TextCastMember(this, id, castStream, _vm->getVersion(), flags1, true));
 		break;
 	case kCastLingoScript:
 		debugC(3, kDebugLoading, "Cast::loadCastData(): loading kCastLingoScript");
diff --git a/engines/director/castmember.cpp b/engines/director/castmember.cpp
index 564457951b..69673cc279 100644
--- a/engines/director/castmember.cpp
+++ b/engines/director/castmember.cpp
@@ -50,7 +50,7 @@ CastMember::~CastMember() {
 		delete _widget;
 }
 
-BitmapCastMember::BitmapCastMember(Cast *cast, uint16 castId, Common::SeekableReadStreamEndian &stream, uint32 castTag, uint16 version)
+BitmapCastMember::BitmapCastMember(Cast *cast, uint16 castId, Common::SeekableReadStreamEndian &stream, uint32 castTag, uint16 version, uint8 flags1)
 		: CastMember(cast, castId, stream) {
 	_type = kCastBitmap;
 	_img = nullptr;
@@ -64,7 +64,7 @@ BitmapCastMember::BitmapCastMember(Cast *cast, uint16 castId, Common::SeekableRe
 	_bitsPerPixel = 0;
 
 	if (version < 4) {
-		_flags1 = stream.readByte();	// region: 0 - auto, 1 - matte, 2 - disabled, 8 - no auto
+		_flags1 = flags1;	// region: 0 - auto, 1 - matte, 2 - disabled, 8 - no auto
 		if (_flags1 >> 4 == 0x0)
 			_autoHilite = true;
 
@@ -87,7 +87,7 @@ BitmapCastMember::BitmapCastMember(Cast *cast, uint16 castId, Common::SeekableRe
 			_pitch += 16 - (_initialRect.width() % 16);
 
 	} else if (version == 4) {
-		_flags1 = stream.readByte();
+		_flags1 = flags1;
 		_pitch = stream.readUint16();
 		_pitch &= 0x0fff;
 
@@ -243,7 +243,7 @@ DigitalVideoCastMember::DigitalVideoCastMember(Cast *cast, uint16 castId, Common
 
 	if (version < 4) {
 		warning("STUB: DigitalVideoCastMember: unhandled properties data");
-		for (int i = 0; i < 0xd; i++) {
+		for (int i = 0; i < 0xc; i++) {
 			stream.readByte();
 		}
 		_frameRate = 12;
@@ -294,7 +294,7 @@ SoundCastMember::SoundCastMember(Cast *cast, uint16 castId, Common::SeekableRead
 	_looping = 0;
 }
 
-TextCastMember::TextCastMember(Cast *cast, uint16 castId, Common::SeekableReadStreamEndian &stream, uint16 version, bool asButton)
+TextCastMember::TextCastMember(Cast *cast, uint16 castId, Common::SeekableReadStreamEndian &stream, uint16 version, uint8 flags1, bool asButton)
 		: CastMember(cast, castId, stream) {
 	_type = kCastText;
 
@@ -319,7 +319,7 @@ TextCastMember::TextCastMember(Cast *cast, uint16 castId, Common::SeekableReadSt
 	_fgpalinfo1 = _fgpalinfo2 = _fgpalinfo3 = 0xff;
 
 	if (version <= 3) {
-		_flags1 = stream.readByte(); // region: 0 - auto, 1 - matte, 2 - disabled
+		_flags1 = flags1; // region: 0 - auto, 1 - matte, 2 - disabled
 		_borderSize = static_cast<SizeType>(stream.readByte());
 		_gutterSize = static_cast<SizeType>(stream.readByte());
 		_boxShadow = static_cast<SizeType>(stream.readByte());
@@ -365,7 +365,7 @@ TextCastMember::TextCastMember(Cast *cast, uint16 castId, Common::SeekableReadSt
 			_initialRect.debugPrint(2, "TextCastMember(): rect:");
 		}
 	} else if (version == 4) {
-		_flags1 = stream.readByte();
+		_flags1 = flags1;
 		_borderSize = static_cast<SizeType>(stream.readByte());
 		_gutterSize = static_cast<SizeType>(stream.readByte());
 		_boxShadow = static_cast<SizeType>(stream.readByte());
@@ -560,7 +560,6 @@ ShapeCastMember::ShapeCastMember(Cast *cast, uint16 castId, Common::SeekableRead
 	_ink = kInkTypeCopy;
 
 	if (version < 4) {
-		flags = stream.readByte();
 		unk1 = stream.readByte();
 		_shapeType = static_cast<ShapeType>(stream.readByte());
 		_initialRect = Movie::readRect(stream);
@@ -573,7 +572,6 @@ ShapeCastMember::ShapeCastMember(Cast *cast, uint16 castId, Common::SeekableRead
 		_lineThickness = stream.readByte();
 		_lineDirection = stream.readByte();
 	} else if (version == 4) {
-		flags = stream.readByte();
 		unk1 = stream.readByte();
 		_shapeType = static_cast<ShapeType>(stream.readByte());
 		_initialRect = Movie::readRect(stream);
@@ -585,7 +583,7 @@ ShapeCastMember::ShapeCastMember(Cast *cast, uint16 castId, Common::SeekableRead
 		_lineThickness = stream.readByte();
 		_lineDirection = stream.readByte();
 	} else {
-		flags = stream.readByte();
+		flags = stream.readByte(); // FIXME: Was this copied from D4 by mistake?
 		unk1 = stream.readByte();
 
 		_initialRect = Movie::readRect(stream);
@@ -615,7 +613,6 @@ ScriptCastMember::ScriptCastMember(Cast *cast, uint16 castId, Common::SeekableRe
 	if (version < 4) {
 		error("Unhandled Script cast");
 	} else if (version == 4) {
-		byte flags = stream.readByte();
 		byte unk1 = stream.readByte();
 		byte type = stream.readByte();
 
@@ -630,7 +627,7 @@ ScriptCastMember::ScriptCastMember(Cast *cast, uint16 castId, Common::SeekableRe
 			error("ScriptCastMember: Unprocessed script type: %d", type);
 		}
 
-		debugC(3, kDebugLoading, "CASt: Script type: %s (%d), flags: (%x), unk1: %d", scriptType2str(_scriptType), type, flags, unk1);
+		debugC(3, kDebugLoading, "CASt: Script type: %s (%d), unk1: %d", scriptType2str(_scriptType), type, unk1);
 
 		stream.readByte(); // There should be no more data
 		assert(stream.eos());
diff --git a/engines/director/castmember.h b/engines/director/castmember.h
index 1b08adf480..8698ef14b8 100644
--- a/engines/director/castmember.h
+++ b/engines/director/castmember.h
@@ -90,7 +90,7 @@ private:
 
 class BitmapCastMember : public CastMember {
 public:
-	BitmapCastMember(Cast *cast, uint16 castId, Common::SeekableReadStreamEndian &stream, uint32 castTag, uint16 version);
+	BitmapCastMember(Cast *cast, uint16 castId, Common::SeekableReadStreamEndian &stream, uint32 castTag, uint16 version, uint8 flags1 = 0);
 	~BitmapCastMember();
 	virtual void createWidget() override;
 
@@ -160,7 +160,7 @@ private:
 
 class TextCastMember : public CastMember {
 public:
-	TextCastMember(Cast *cast, uint16 castId, Common::SeekableReadStreamEndian &stream, uint16 version, bool asButton = false);
+	TextCastMember(Cast *cast, uint16 castId, Common::SeekableReadStreamEndian &stream, uint16 version, uint8 flags1 = 0, bool asButton = false);
 	virtual void setColors(int *fgcolor, int *bgcolor) override;
 
 	void setText(const char *text);




More information about the Scummvm-git-logs mailing list