aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Gilbert2014-03-08 08:59:10 -0500
committerPaul Gilbert2014-03-08 08:59:10 -0500
commit0f214e4c9d72d088ccf088496710b20576ec73f5 (patch)
treef70f9f0c78159885dae2fff419fe7023ef10a520
parent8d3857c0536e47a6a03497346424c111b5bebd7b (diff)
downloadscummvm-rg350-0f214e4c9d72d088ccf088496710b20576ec73f5.tar.gz
scummvm-rg350-0f214e4c9d72d088ccf088496710b20576ec73f5.tar.bz2
scummvm-rg350-0f214e4c9d72d088ccf088496710b20576ec73f5.zip
MADS: Fix for loading animation data
-rw-r--r--engines/mads/animation.cpp7
-rw-r--r--engines/mads/compression.h10
2 files changed, 12 insertions, 5 deletions
diff --git a/engines/mads/animation.cpp b/engines/mads/animation.cpp
index 3508631690..90f1331d92 100644
--- a/engines/mads/animation.cpp
+++ b/engines/mads/animation.cpp
@@ -207,10 +207,11 @@ void Animation::load(MSurface &depthSurface, InterfaceSurface &interfaceSurface,
for (int i = 0; i < _header._spriteSetsCount; ++i)
_spriteListIndexes.push_back(-1);
+ int streamIndex = 1;
_messages.clear();
if (_header._messagesCount > 0) {
// Chunk 2: Following is a list of any messages for the animation
- Common::SeekableReadStream *msgStream = madsPack.getItemStream(1);
+ Common::SeekableReadStream *msgStream = madsPack.getItemStream(streamIndex++);
for (int i = 0; i < _header._messagesCount; ++i) {
AnimMessage rec;
@@ -224,7 +225,7 @@ void Animation::load(MSurface &depthSurface, InterfaceSurface &interfaceSurface,
_frameEntries.clear();
if (_header._frameEntriesCount > 0) {
// Chunk 3: animation frame info
- Common::SeekableReadStream *frameStream = madsPack.getItemStream(2);
+ Common::SeekableReadStream *frameStream = madsPack.getItemStream(streamIndex++);
for (int i = 0; i < _header._frameEntriesCount; i++) {
AnimFrameEntry rec;
@@ -238,7 +239,7 @@ void Animation::load(MSurface &depthSurface, InterfaceSurface &interfaceSurface,
_miscEntries.clear();
if (_header._miscEntriesCount > 0) {
// Chunk 4: Misc Data
- Common::SeekableReadStream *miscStream = madsPack.getItemStream(3);
+ Common::SeekableReadStream *miscStream = madsPack.getItemStream(streamIndex++);
for (int i = 0; i < _header._miscEntriesCount; ++i) {
AnimMiscEntry rec;
diff --git a/engines/mads/compression.h b/engines/mads/compression.h
index bf690dcc46..aa1f0d9bdc 100644
--- a/engines/mads/compression.h
+++ b/engines/mads/compression.h
@@ -54,9 +54,15 @@ public:
~MadsPack();
int getCount() const { return _count; }
- MadsPackEntry &getItem(int index) const { return _items[index]; }
- MadsPackEntry &operator[](int index) const { return _items[index]; }
+ MadsPackEntry &getItem(int index) const {
+ assert(index < _count);
+ return _items[index]; }
+ MadsPackEntry &operator[](int index) const {
+ assert(index < _count);
+ return _items[index];
+ }
Common::MemoryReadStream *getItemStream(int index) {
+ assert(index < _count);
return new Common::MemoryReadStream(_items[index].data, _items[index].size,
DisposeAfterUse::NO);
}