From acfd13633d97a121fe5581544feba692aa81b5a8 Mon Sep 17 00:00:00 2001 From: Alyssa Milburn Date: Sat, 16 Jul 2011 00:56:18 +0200 Subject: COMPOSER: Always handle multiple resource entries in pipes. --- engines/composer/composer.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'engines') diff --git a/engines/composer/composer.cpp b/engines/composer/composer.cpp index cde2e0bb0a..936f1ff595 100644 --- a/engines/composer/composer.cpp +++ b/engines/composer/composer.cpp @@ -226,11 +226,16 @@ Common::SeekableReadStream *Pipe::getResource(uint32 tag, uint16 id, bool buffer const PipeResource &res = resMap[id]; - if (!buffering) { - assert(res.entries.size() == 1); - return new Common::SeekableSubReadStream(_stream, res.entries[0].offset, res.entries[0].offset + res.entries[0].size); + if (res.entries.size() == 1) { + Common::SeekableReadStream *stream = new Common::SeekableSubReadStream(_stream, + res.entries[0].offset, res.entries[0].offset + res.entries[0].size); + if (buffering) + _types[tag].erase(id); + return stream; } + // If there are multiple entries in the pipe, we have to concaternate them together. + uint32 size = 0; for (uint i = 0; i < res.entries.size(); i++) size += res.entries[i].size; @@ -242,7 +247,8 @@ Common::SeekableReadStream *Pipe::getResource(uint32 tag, uint16 id, bool buffer _stream->read(buffer + offset, res.entries[i].size); offset += res.entries[i].size; } - _types[tag].erase(id); + if (buffering) + _types[tag].erase(id); return new Common::MemoryReadStream(buffer, size, DisposeAfterUse::YES); } -- cgit v1.2.3