aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthew Hoops2010-09-17 03:55:41 +0000
committerMatthew Hoops2010-09-17 03:55:41 +0000
commit7835ce5cb8bef41e8c5c40914834a3c623ee6cfa (patch)
tree482a46dcc2ff36b9b0ccebdd5e34ae5341f44093
parentc7b38c45101cfcaafc60aaec4a8817c45dffca7c (diff)
downloadscummvm-rg350-7835ce5cb8bef41e8c5c40914834a3c623ee6cfa.tar.gz
scummvm-rg350-7835ce5cb8bef41e8c5c40914834a3c623ee6cfa.tar.bz2
scummvm-rg350-7835ce5cb8bef41e8c5c40914834a3c623ee6cfa.zip
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. svn-id: r52756
-rw-r--r--common/macresman.cpp24
-rw-r--r--common/macresman.h11
2 files changed, 34 insertions, 1 deletions
diff --git a/common/macresman.cpp b/common/macresman.cpp
index eb6a5939b6..641702b5ec 100644
--- a/common/macresman.cpp
+++ b/common/macresman.cpp
@@ -110,6 +110,7 @@ bool MacResManager::open(Common::String filename) {
_baseFileName = filename;
return true;
}
+
delete macResForkRawStream;
#endif
@@ -169,6 +170,7 @@ bool MacResManager::open(Common::FSNode path, Common::String filename) {
_baseFileName = filename;
return true;
}
+
delete macResForkRawStream;
#endif
@@ -466,6 +468,28 @@ Common::SeekableReadStream *MacResManager::getResource(const Common::String &fil
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);
diff --git a/common/macresman.h b/common/macresman.h
index 2168235670..d47b0ca329 100644
--- a/common/macresman.h
+++ b/common/macresman.h
@@ -57,7 +57,7 @@ public:
/**
* 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 @@ public:
/**
* 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();