[Scummvm-cvs-logs] SF.net SVN: scummvm:[42243] scummvm/branches/gsoc2009-draci/engines/draci/ animation.cpp

dkasak13 at users.sourceforge.net dkasak13 at users.sourceforge.net
Tue Jul 7 23:11:36 CEST 2009


Revision: 42243
          http://scummvm.svn.sourceforge.net/scummvm/?rev=42243&view=rev
Author:   dkasak13
Date:     2009-07-07 21:11:36 +0000 (Tue, 07 Jul 2009)

Log Message:
-----------
* 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.

Modified Paths:
--------------
    scummvm/branches/gsoc2009-draci/engines/draci/animation.cpp

Modified: scummvm/branches/gsoc2009-draci/engines/draci/animation.cpp
===================================================================
--- scummvm/branches/gsoc2009-draci/engines/draci/animation.cpp	2009-07-07 20:57:14 UTC (rev 42242)
+++ scummvm/branches/gsoc2009-draci/engines/draci/animation.cpp	2009-07-07 21:11:36 UTC (rev 42243)
@@ -48,10 +48,14 @@
 
 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 @@
 
 	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 @@
 }
 
 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) {


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list