From 9e127a10327ced6e7172efbb237672b07df4a0a0 Mon Sep 17 00:00:00 2001 From: Alyssa Milburn Date: Sat, 16 Jul 2011 00:59:00 +0200 Subject: COMPOSER: Don't die on missing/bad anims. --- engines/composer/composer.cpp | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'engines/composer') diff --git a/engines/composer/composer.cpp b/engines/composer/composer.cpp index 6228292676..cafb5e7bd9 100644 --- a/engines/composer/composer.cpp +++ b/engines/composer/composer.cpp @@ -296,6 +296,10 @@ void ComposerEngine::playAnimation(uint16 animId, int16 x, int16 y, int16 eventP // If we didn't find it, try the libraries. if (!stream) { + if (!hasResource(ID_ANIM, animId)) { + warning("ignoring attempt to play invalid anim %d", animId); + return; + } stream = getResource(ID_ANIM, animId); uint32 type = 0; @@ -350,6 +354,12 @@ void ComposerEngine::processAnimFrame() { for (Common::List::iterator i = _anims.begin(); i != _anims.end(); i++) { Animation *anim = *i; + anim->seekToCurrPos(); + if (anim->_stream->pos() == anim->_stream->size()) { + warning("anim with id %d ended too soon", anim->_id); + anim->_state = 0; + } + if (anim->_state <= 1) { if (anim->_state == 1) { runEvent(2, anim->_id, anim->_eventParam, 0); @@ -363,8 +373,6 @@ void ComposerEngine::processAnimFrame() { continue; } - anim->seekToCurrPos(); - for (uint j = 0; j < anim->_entries.size(); j++) { AnimationEntry &entry = anim->_entries[j]; if (entry.op != 1) @@ -679,8 +687,9 @@ void ComposerEngine::loadLibrary(uint id) { Common::hexdump(buf, stream->size()); delete stream;*/ - // TODO: set background properly - addSprite(1000, 0, 0, Common::Point()); + // add background sprite, if it exists + if (hasResource(ID_BMAP, 1000)) + addSprite(1000, 0, -1, Common::Point()); // TODO: better CTBL logic loadCTBL(1000, 100); -- cgit v1.2.3