[Scummvm-cvs-logs] SF.net SVN: scummvm:[52756] scummvm/trunk/common

mthreepwood at users.sourceforge.net mthreepwood at users.sourceforge.net
Fri Sep 17 05:55:41 CEST 2010


Revision: 52756
          http://scummvm.svn.sourceforge.net/scummvm/?rev=52756&view=rev
Author:   mthreepwood
Date:     2010-09-17 03:55:41 +0000 (Fri, 17 Sep 2010)

Log Message:
-----------
COMMON: Extend getting a Mac resource fork resource with a name

Resource names can be the same across types (ie. 'PICT' "Foo" and 'snd ' "Foo"), so this ensures that the right type is chosen in those cases.

Modified Paths:
--------------
    scummvm/trunk/common/macresman.cpp
    scummvm/trunk/common/macresman.h

Modified: scummvm/trunk/common/macresman.cpp
===================================================================
--- scummvm/trunk/common/macresman.cpp	2010-09-16 23:03:03 UTC (rev 52755)
+++ scummvm/trunk/common/macresman.cpp	2010-09-17 03:55:41 UTC (rev 52756)
@@ -110,6 +110,7 @@
 		_baseFileName = filename;
 		return true;
 	}
+
 	delete macResForkRawStream;
 #endif
 
@@ -169,6 +170,7 @@
 		_baseFileName = filename;
 		return true;
 	}
+
 	delete macResForkRawStream;
 #endif
 
@@ -466,6 +468,28 @@
 	return 0;
 }
 
+Common::SeekableReadStream *MacResManager::getResource(uint32 typeID, const Common::String &filename) {
+	for (uint32 i = 0; i < _resMap.numTypes; i++) {
+		if (_resTypes[i].id != typeID)
+			continue;
+
+		for (uint32 j = 0; j < _resTypes[i].items; j++) {
+			if (_resLists[i][j].nameOffset != -1 && filename.equalsIgnoreCase(_resLists[i][j].name)) {
+				_stream->seek(_dataOffset + _resLists[i][j].dataOffset);
+				uint32 len = _stream->readUint32BE();
+
+				// Ignore resources with 0 length
+				if (!len)
+					return 0;
+
+				return _stream->readStream(len);
+			}
+		}
+	}
+
+	return 0;
+}
+
 void MacResManager::readMap() {
 	_stream->seek(_mapOffset + 22);
 

Modified: scummvm/trunk/common/macresman.h
===================================================================
--- scummvm/trunk/common/macresman.h	2010-09-16 23:03:03 UTC (rev 52755)
+++ scummvm/trunk/common/macresman.h	2010-09-17 03:55:41 UTC (rev 52756)
@@ -57,7 +57,7 @@
 
 	/**
 	 * Read resource from the Mac Binary file
-	 * @param typeID FourCC with type ID
+	 * @param typeID FourCC of the type
 	 * @param resID Resource ID to fetch
 	 * @return Pointer to a SeekableReadStream with loaded resource
 	 */
@@ -65,11 +65,20 @@
 
 	/**
 	 * Read resource from the Mac Binary file
+	 * @note This will take the first resource that matches this name, regardless of type
 	 * @param filename filename of the resource
 	 * @return Pointer to a SeekableReadStream with loaded resource
 	 */
 	Common::SeekableReadStream *getResource(const Common::String &filename);
 
+	/**
+	 * Read resource from the Mac Binary file
+	 * @param typeID FourCC of the type
+	 * @param filename filename of the resource
+	 * @return Pointer to a SeekableReadStream with loaded resource
+	 */
+	Common::SeekableReadStream *getResource(uint32 typeID, const Common::String &filename);
+
 	Common::SeekableReadStream *getDataFork();
 	Common::String getResName(uint32 typeID, uint16 resID);
 	uint32 getResForkSize();


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list