From 9246e9cf4a6f6a561274274019309b16ae1b96c4 Mon Sep 17 00:00:00 2001 From: Denis Kasak Date: Tue, 7 Jul 2009 21:11:36 +0000 Subject: * Added some more animation debug info * Reordered Animation::nextFrame() a bit to make sure the timings are correct (particularly the last frame) * Added checks to AnimationManager::play() and AnimationManager::stop() so it doesn't dereference a null pointer. svn-id: r42243 --- engines/draci/animation.cpp | 43 ++++++++++++++++++++++++++++--------------- 1 file changed, 28 insertions(+), 15 deletions(-) (limited to 'engines/draci/animation.cpp') diff --git a/engines/draci/animation.cpp b/engines/draci/animation.cpp index 09ee48ab55..d48560a550 100644 --- a/engines/draci/animation.cpp +++ b/engines/draci/animation.cpp @@ -48,10 +48,14 @@ bool Animation::isLooping() { void Animation::setLooping(bool looping) { _looping = looping; + debugC(7, kDraciAnimationDebugLevel, "Setting looping to %d on animation %d", + looping, _id); } void Animation::setDelay(uint delay) { _delay = delay; + debugC(7, kDraciAnimationDebugLevel, "Setting delay to %u on animation %d", + delay, _id); } void Animation::nextFrame(bool force) { @@ -62,23 +66,22 @@ void Animation::nextFrame(bool force) { Common::Rect frameRect = _frames[_currentFrame]->getRect(); - // If we are at the last frame and not looping, stop the animation - // The animation is also restarted to frame zero - if ((_currentFrame == nextFrameNum() - 1) && !_looping) { - _currentFrame = 0; - _playing = false; - return; - } - if (force || (_tick + _delay <= _vm->_system->getMillis())) { - _vm->_screen->getSurface()->markDirtyRect(frameRect); - _currentFrame = nextFrameNum(); - _tick = _vm->_system->getMillis(); + // If we are at the last frame and not looping, stop the animation + // The animation is also restarted to frame zero + if ((_currentFrame == getFramesNum() - 1) && !_looping) { + _currentFrame = 0; + _playing = false; + } else { + _vm->_screen->getSurface()->markDirtyRect(frameRect); + _currentFrame = nextFrameNum(); + _tick += _delay; + } } debugC(6, kDraciAnimationDebugLevel, - "tick=%d delay=%d tick+delay=%d currenttime=%d frame=%d framenum=%d", - _tick, _delay, _tick + _delay, _vm->_system->getMillis(), _currentFrame, _frames.size()); + "anim=%d tick=%d delay=%d tick+delay=%d currenttime=%d frame=%d framenum=%d", + _id, _tick, _delay, _tick + _delay, _vm->_system->getMillis(), _currentFrame, _frames.size()); } uint Animation::nextFrameNum() { @@ -157,11 +160,21 @@ Animation *AnimationManager::addAnimation(int id, uint z, bool playing) { } void AnimationManager::play(int id) { - getAnimation(id)->setPlaying(true); + Animation *anim = getAnimation(id); + + if (anim) + anim->setPlaying(true); + + debugC(5, kDraciAnimationDebugLevel, "Playing animation %d...", id); } void AnimationManager::stop(int id) { - getAnimation(id)->setPlaying(false); + Animation *anim = getAnimation(id); + + if (anim) + anim->setPlaying(false); + + debugC(5, kDraciAnimationDebugLevel, "Stopping animation %d...", id); } Animation *AnimationManager::getAnimation(int id) { -- cgit v1.2.3