aboutsummaryrefslogtreecommitdiff
path: root/engines/draci/animation.cpp
diff options
context:
space:
mode:
authorDenis Kasak2009-07-07 21:11:36 +0000
committerDenis Kasak2009-07-07 21:11:36 +0000
commit9246e9cf4a6f6a561274274019309b16ae1b96c4 (patch)
tree5a087171055c37479f6515562fd7a46e3aefae72 /engines/draci/animation.cpp
parentb6b1402368b8f33c825af095bec210829ad33cd3 (diff)
downloadscummvm-rg350-9246e9cf4a6f6a561274274019309b16ae1b96c4.tar.gz
scummvm-rg350-9246e9cf4a6f6a561274274019309b16ae1b96c4.tar.bz2
scummvm-rg350-9246e9cf4a6f6a561274274019309b16ae1b96c4.zip
* 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
Diffstat (limited to 'engines/draci/animation.cpp')
-rw-r--r--engines/draci/animation.cpp43
1 files changed, 28 insertions, 15 deletions
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) {