diff options
-rw-r--r-- | engines/director/archive.cpp | 10 | ||||
-rw-r--r-- | engines/director/archive.h | 4 |
2 files changed, 9 insertions, 5 deletions
diff --git a/engines/director/archive.cpp b/engines/director/archive.cpp index 340db3d9c1..bcd064b420 100644 --- a/engines/director/archive.cpp +++ b/engines/director/archive.cpp @@ -248,6 +248,8 @@ Common::SeekableSubReadStreamEndian *MacArchive::getResource(uint32 tag, uint16 bool RIFFArchive::openStream(Common::SeekableReadStream *stream, uint32 startOffset) { close(); + _startOffset = startOffset; + stream->seek(startOffset); if (convertTagToUppercase(stream->readUint32BE()) != MKTAG('R', 'I', 'F', 'F')) @@ -289,11 +291,11 @@ bool RIFFArchive::openStream(Common::SeekableReadStream *stream, uint32 startOff stream->seek(startResPos); - debug(3, "Found RIFF resource '%s' %d: %d @ 0x%08x", tag2str(tag), id, size, startOffset + offset); + debug(3, "Found RIFF resource '%s' %d: %d @ 0x%08x (0x%08x)", tag2str(tag), id, size, offset, startOffset + offset); ResourceMap &resMap = _types[tag]; Resource &res = resMap[id]; - res.offset = offset + startOffset; + res.offset = offset; res.size = size; res.name = name; } @@ -317,7 +319,7 @@ Common::SeekableSubReadStreamEndian *RIFFArchive::getResource(uint32 tag, uint16 uint32 offset = res.offset + 12; uint32 size = res.size - 4; // Skip the Pascal string - _stream->seek(offset); + _stream->seek(_startOffset + offset); byte stringSize = _stream->readByte(); // 1 for this byte offset += stringSize + 1; @@ -329,7 +331,7 @@ Common::SeekableSubReadStreamEndian *RIFFArchive::getResource(uint32 tag, uint16 size--; } - return new Common::SeekableSubReadStreamEndian(_stream, offset, offset + size, true, DisposeAfterUse::NO); + return new Common::SeekableSubReadStreamEndian(_stream, _startOffset + offset, _startOffset + offset + size, true, DisposeAfterUse::NO); } // RIFX Archive code diff --git a/engines/director/archive.h b/engines/director/archive.h index 40b15d51dc..28be6cf03c 100644 --- a/engines/director/archive.h +++ b/engines/director/archive.h @@ -94,11 +94,13 @@ private: class RIFFArchive : public Archive { public: - RIFFArchive() : Archive() {} + RIFFArchive() : Archive() { _startOffset = 0; } ~RIFFArchive() {} bool openStream(Common::SeekableReadStream *stream, uint32 startOffset = 0); Common::SeekableSubReadStreamEndian *getResource(uint32 tag, uint16 id); + + uint32 _startOffset; }; class RIFXArchive : public Archive { |