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

sev- sev at scummvm.org
Tue Jul 7 20:32:29 UTC 2020


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

Summary:
390297b410 DIRECTOR: Improve debug info on resource loading
be388e644a COMMON: Give direct access to Data fork in MacResMan
45be27a1f9 DIRECTOR: Check if RIFX archives are in MacBinary format


Commit: 390297b410eb29c0c8107432d6def530855b33c8
    https://github.com/scummvm/scummvm/commit/390297b410eb29c0c8107432d6def530855b33c8
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2020-07-07T22:31:13+02:00

Commit Message:
DIRECTOR: Improve debug info on resource loading

Changed paths:
    engines/director/archive.cpp


diff --git a/engines/director/archive.cpp b/engines/director/archive.cpp
index 9a9bafca32..65e984b98c 100644
--- a/engines/director/archive.cpp
+++ b/engines/director/archive.cpp
@@ -45,6 +45,7 @@ bool Archive::openFile(const Common::String &fileName) {
 	Common::File *file = new Common::File();
 
 	if (!file->open(fileName)) {
+		warning("Archive::openFile(): Error opening file %s", fileName.c_str());
 		delete file;
 		return false;
 	}
@@ -52,6 +53,7 @@ bool Archive::openFile(const Common::String &fileName) {
 	_fileName = fileName;
 
 	if (!openStream(file)) {
+		warning("Archive::openFile(): Error loading stream from file %s", fileName.c_str());
 		close();
 		return false;
 	}
@@ -237,6 +239,7 @@ bool MacArchive::openStream(Common::SeekableReadStream *stream, uint32 startOffs
 	stream->seek(startOffset);
 
 	if (!_resFork->loadFromMacBinary(*stream)) {
+		warning("MacArchive::openStream(): Error loading Mac Binary");
 		close();
 		return false;
 	}
@@ -287,16 +290,22 @@ bool RIFFArchive::openStream(Common::SeekableReadStream *stream, uint32 startOff
 
 	stream->seek(startOffset);
 
-	if (convertTagToUppercase(stream->readUint32BE()) != MKTAG('R', 'I', 'F', 'F'))
+	if (convertTagToUppercase(stream->readUint32BE()) != MKTAG('R', 'I', 'F', 'F')) {
+		warning("RIFFArchive::openStream(): RIFF expected but not found");
 		return false;
+	}
 
 	stream->readUint32LE(); // size
 
-	if (convertTagToUppercase(stream->readUint32BE()) != MKTAG('R', 'M', 'M', 'P'))
+	if (convertTagToUppercase(stream->readUint32BE()) != MKTAG('R', 'M', 'M', 'P')) {
+		warning("RIFFArchive::openStream(): RMMP expected but not found");
 		return false;
+	}
 
-	if (convertTagToUppercase(stream->readUint32BE()) != MKTAG('C', 'F', 'T', 'C'))
+	if (convertTagToUppercase(stream->readUint32BE()) != MKTAG('C', 'F', 'T', 'C')) {
+		warning("RIFFArchive::openStream(): CFTC expected but not found");
 		return false;
+	}
 
 	uint32 cftcSize = stream->readUint32LE();
 	uint32 startPos = stream->pos();
@@ -379,12 +388,14 @@ bool RIFXArchive::openStream(Common::SeekableReadStream *stream, uint32 startOff
 
 	uint32 headerTag = stream->readUint32BE();
 
-	if (headerTag == MKTAG('R', 'I', 'F', 'X'))
+	if (headerTag == MKTAG('R', 'I', 'F', 'X')) {
 		_isBigEndian = true;
-	else if (SWAP_BYTES_32(headerTag) == MKTAG('R', 'I', 'F', 'X'))
+	} else if (SWAP_BYTES_32(headerTag) == MKTAG('R', 'I', 'F', 'X')) {
 		_isBigEndian = false;
-	else
+	} else {
+		warning("RIFXArchive::openStream(): RIFX or XFIR expected but %s found", tag2str(headerTag));
 		return false;
+	}
 
 	Common::SeekableSubReadStreamEndian subStream(stream, startOffset + 4, stream->size(), _isBigEndian, DisposeAfterUse::NO);
 
@@ -433,8 +444,10 @@ bool RIFXArchive::openStream(Common::SeekableReadStream *stream, uint32 startOff
 
 	subStream.seek(mmapOffset);
 
-	if (subStream.readUint32() != MKTAG('m', 'm', 'a', 'p'))
+	if (subStream.readUint32() != MKTAG('m', 'm', 'a', 'p')) {
+		warning("RIFXArchive::openStream(): mmap expected but not found");
 		return false;
+	}
 
 	subStream.readUint32(); // mmap length
 	subStream.readUint16(); // unknown
@@ -481,7 +494,7 @@ bool RIFXArchive::openStream(Common::SeekableReadStream *stream, uint32 startOff
 	}
 
 	if (ConfMan.getBool("dump_scripts")) {
-		debug("Dumping %d resources", resources.size());
+		debug("RIFXArchive::openStream(): Dumping %d resources", resources.size());
 
 		byte *data = nullptr;
 		uint dataSize = 0;


Commit: be388e644ada9cd67e0fd795870417a643075080
    https://github.com/scummvm/scummvm/commit/be388e644ada9cd67e0fd795870417a643075080
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2020-07-07T22:31:13+02:00

Commit Message:
COMMON: Give direct access to Data fork in MacResMan

Changed paths:
    common/macresman.cpp
    common/macresman.h


diff --git a/common/macresman.cpp b/common/macresman.cpp
index 7f12f3207b..f6a4f9f370 100644
--- a/common/macresman.cpp
+++ b/common/macresman.cpp
@@ -37,7 +37,6 @@
 
 namespace Common {
 
-#define MBI_INFOHDR 128
 #define MBI_ZERO1 0
 #define MBI_NAMELEN 1
 #define MBI_ZERO2 74
diff --git a/common/macresman.h b/common/macresman.h
index 48850ee92d..f2bec46d94 100644
--- a/common/macresman.h
+++ b/common/macresman.h
@@ -49,6 +49,8 @@ typedef Array<uint32> MacResTagArray;
  */
 class MacResManager {
 
+#define MBI_INFOHDR 128
+
 public:
 	MacResManager();
 	~MacResManager();
@@ -139,6 +141,8 @@ public:
 	 */
 	SeekableReadStream *getDataFork();
 
+	static int getDataForkOffset() { return MBI_INFOHDR; }
+
 	/**
 	 * Get the name of a given resource
 	 * @param typeID FourCC of the type
@@ -188,6 +192,12 @@ public:
 	 */
 	 void dumpRaw();
 
+	/**
+	 * Check if the given stream is in the MacBinary format.
+	 * @param stream The stream we're checking
+	 */
+	static bool isMacBinary(SeekableReadStream &stream);
+
 private:
 	SeekableReadStream *_stream;
 	String _baseFileName;
@@ -200,12 +210,6 @@ private:
 	static String constructAppleDoubleName(String name);
 	static String disassembleAppleDoubleName(String name, bool *isAppleDouble);
 
-	/**
-	 * Check if the given stream is in the MacBinary format.
-	 * @param stream The stream we're checking
-	 */
-	static bool isMacBinary(SeekableReadStream &stream);
-
 	/**
 	 * Do a sanity check whether the given stream is a raw resource fork.
 	 *


Commit: 45be27a1f9f6ae69a23ad168f4b1a0034e34c103
    https://github.com/scummvm/scummvm/commit/45be27a1f9f6ae69a23ad168f4b1a0034e34c103
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2020-07-07T22:31:13+02:00

Commit Message:
DIRECTOR: Check if RIFX archives are in MacBinary format

Changed paths:
    engines/director/archive.cpp


diff --git a/engines/director/archive.cpp b/engines/director/archive.cpp
index 65e984b98c..58b32dfa6f 100644
--- a/engines/director/archive.cpp
+++ b/engines/director/archive.cpp
@@ -380,7 +380,6 @@ Common::SeekableSubReadStreamEndian *RIFFArchive::getResource(uint32 tag, uint16
 }
 
 // RIFX Archive code
-
 bool RIFXArchive::openStream(Common::SeekableReadStream *stream, uint32 startOffset) {
 	close();
 
@@ -388,6 +387,22 @@ bool RIFXArchive::openStream(Common::SeekableReadStream *stream, uint32 startOff
 
 	uint32 headerTag = stream->readUint32BE();
 
+	if (headerTag != MKTAG('R', 'I', 'F', 'X') &&
+		headerTag != MKTAG('X', 'F', 'I', 'R')) {
+		// Check if it is MacBinary
+
+		stream->seek(startOffset);
+
+		if (Common::MacResManager::isMacBinary(*stream)) {
+			warning("RIFXArchive::openStream(): MacBinary detected, overriding");
+
+			startOffset += Common::MacResManager::getDataForkOffset();
+			stream->seek(startOffset);
+
+			headerTag = stream->readUint32BE();
+		}
+	}
+
 	if (headerTag == MKTAG('R', 'I', 'F', 'X')) {
 		_isBigEndian = true;
 	} else if (SWAP_BYTES_32(headerTag) == MKTAG('R', 'I', 'F', 'X')) {
@@ -438,7 +453,7 @@ bool RIFXArchive::openStream(Common::SeekableReadStream *stream, uint32 startOff
 
 	subStream.readUint32(); // imap length
 	subStream.readUint32(); // unknown
-	uint32 mmapOffset = subStream.readUint32() - startOffset - 4;
+	uint32 mmapOffset = subStream.readUint32() - 4;
 	uint32 version = subStream.readUint32(); // 0 for 4.0, 0x4c1 for 5.0, 0x4c7 for 6.0, 0x708 for 8.5, 0x742 for 10.0
 	warning("RIFX: version: %x type: %s", version, tag2str(rifxType));
 
@@ -467,7 +482,7 @@ bool RIFXArchive::openStream(Common::SeekableReadStream *stream, uint32 startOff
 	for (uint32 i = 0; i < resCount; i++) {
 		uint32 tag = subStream.readUint32();
 		uint32 size = subStream.readUint32();
-		uint32 offset = subStream.readUint32();
+		uint32 offset = subStream.readUint32() + startOffset;
 		uint16 flags = subStream.readUint16();
 		uint16 unk1 = subStream.readUint16();
 		uint32 unk2 = subStream.readUint32();




More information about the Scummvm-git-logs mailing list