aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthew Hoops2013-10-26 18:03:44 -0400
committerEugene Sandulenko2016-08-03 23:40:36 +0200
commit30de1f34ca9c5816dd17f452fbc59c785ca42c93 (patch)
tree80775db60023002b721c87daff7947b1e4dae050
parent5e0874797817ac62e583963ff0bb16f5766070f1 (diff)
downloadscummvm-rg350-30de1f34ca9c5816dd17f452fbc59c785ca42c93.tar.gz
scummvm-rg350-30de1f34ca9c5816dd17f452fbc59c785ca42c93.tar.bz2
scummvm-rg350-30de1f34ca9c5816dd17f452fbc59c785ca42c93.zip
DIRECTOR: Fix getting RIFF resources
-rw-r--r--engines/director/resource.cpp30
-rw-r--r--engines/director/resource.h1
2 files changed, 31 insertions, 0 deletions
diff --git a/engines/director/resource.cpp b/engines/director/resource.cpp
index b9e6b1de8a..1c4bd33a19 100644
--- a/engines/director/resource.cpp
+++ b/engines/director/resource.cpp
@@ -248,6 +248,36 @@ bool RIFFArchive::openStream(Common::SeekableReadStream *stream) {
return true;
}
+Common::SeekableReadStream *RIFFArchive::getResource(uint32 tag, uint16 id) {
+ if (!_types.contains(tag))
+ error("Archive does not contain '%s' %04x", tag2str(tag), id);
+
+ const ResourceMap &resMap = _types[tag];
+
+ if (!resMap.contains(id))
+ error("Archive does not contain '%s' %04x", tag2str(tag), id);
+
+ const Resource &res = resMap[id];
+
+ // Adjust to skip the resource header
+ uint32 offset = res.offset + 12;
+ uint32 size = res.size - 12;
+
+ // Skip the Pascal string
+ _stream->seek(offset);
+ byte stringSize = _stream->readByte() + 1; // 1 for this byte
+ offset += stringSize;
+ size -= stringSize;
+
+ // Align to nearest word boundary
+ if (offset & 1) {
+ offset++;
+ size--;
+ }
+
+ return new Common::SeekableSubReadStream(_stream, offset, offset + size);
+}
+
// RIFX Archive code
diff --git a/engines/director/resource.h b/engines/director/resource.h
index f757c9c0ee..055abe98f0 100644
--- a/engines/director/resource.h
+++ b/engines/director/resource.h
@@ -92,6 +92,7 @@ public:
~RIFFArchive() {}
bool openStream(Common::SeekableReadStream *stream);
+ Common::SeekableReadStream *getResource(uint32 tag, uint16 id);
};
class RIFXArchive : public Archive {