From 881bf37554b1d33b3c77bf7a6718b98c7766fd83 Mon Sep 17 00:00:00 2001 From: Robert Špalek Date: Fri, 6 Nov 2009 16:48:37 +0000 Subject: Add safe-guard against collision of animation IDs. When debugging another issue, I preloaded all animations, and horrible things happened that I debugged for a few hours. svn-id: r45695 --- engines/draci/animation.cpp | 3 +++ engines/draci/game.cpp | 7 +++++++ 2 files changed, 10 insertions(+) diff --git a/engines/draci/animation.cpp b/engines/draci/animation.cpp index 2bbb960fb1..674e2473df 100644 --- a/engines/draci/animation.cpp +++ b/engines/draci/animation.cpp @@ -63,6 +63,9 @@ void Animation::setLooping(bool looping) { } void Animation::markDirtyRect(Surface *surface) const { + if (getFrameCount() == 0) + return; + // Fetch the current frame's rectangle Drawable *frame = _frames[_currentFrame]; Common::Rect frameRect = frame->getRect(_displacement); diff --git a/engines/draci/game.cpp b/engines/draci/game.cpp index 7516da3c03..0d9e41f125 100644 --- a/engines/draci/game.cpp +++ b/engines/draci/game.cpp @@ -1166,6 +1166,13 @@ void Game::loadRoom(int roomNum) { } int Game::loadAnimation(uint animNum, uint z) { + // Make double-sure that an animation isn't loaded more than twice, + // otherwise horrible things happen in the AnimationManager, because + // they use a simple link-list without duplicate checking. This should + // never happen unless there is a bug in the game, because all GPL2 + // commands are guarded. + assert(!_vm->_anims->getAnimation(animNum)); + const BAFile *animFile = _vm->_animationsArchive->getFile(animNum); Common::MemoryReadStream animationReader(animFile->_data, animFile->_length); -- cgit v1.2.3