diff options
-rw-r--r-- | common/macresman.cpp | 24 | ||||
-rw-r--r-- | common/macresman.h | 11 |
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(); |