[Scummvm-cvs-logs] SF.net SVN: scummvm:[44422] scummvm/trunk/engines/draci

spalek at users.sourceforge.net spalek at users.sourceforge.net
Sun Sep 27 23:25:35 CEST 2009


Revision: 44422
          http://scummvm.svn.sourceforge.net/scummvm/?rev=44422&view=rev
Author:   spalek
Date:     2009-09-27 21:25:34 +0000 (Sun, 27 Sep 2009)

Log Message:
-----------
Reduce code duplication when cleaning animations

Modified Paths:
--------------
    scummvm/trunk/engines/draci/game.cpp
    scummvm/trunk/engines/draci/game.h

Modified: scummvm/trunk/engines/draci/game.cpp
===================================================================
--- scummvm/trunk/engines/draci/game.cpp	2009-09-27 21:00:45 UTC (rev 44421)
+++ scummvm/trunk/engines/draci/game.cpp	2009-09-27 21:25:34 UTC (rev 44422)
@@ -953,21 +953,7 @@
 	// Run the dialogue program
 	_vm->_script->run(prog, offset);
 	
-	// Delete all animations loaded after the marked one 
-	// (from objects and from the AnimationManager)
-	for (uint i = 0; i < getNumObjects(); ++i) {
-		GameObject *obj = &_objects[i];
-
-		for (uint j = 0; j < obj->_anims.size(); ++j) {
-			Animation *anim;
-
-			anim = _vm->_anims->getAnimation(obj->_anims[j]);
-			if (anim != NULL && anim->getIndex() > lastAnimIndex)
-				obj->_anims.remove_at(j);
-		}
-	}
-
-	_vm->_anims->deleteAfterIndex(lastAnimIndex);
+	deleteAnimationsAfterIndex(lastAnimIndex);
 }
 
 bool Game::isDialogueBegin() const {
@@ -1408,22 +1394,8 @@
 	// Run gate program
 	_vm->_script->run(_currentRoom._program, _currentRoom._gates[gate]);
 	
-	// Delete all animations loaded after the marked one 
-	// (from objects and from the AnimationManager)
-	for (uint i = 0; i < getNumObjects(); ++i) {
-		GameObject *obj = &_objects[i];
+	deleteAnimationsAfterIndex(lastAnimIndex);
 
-		for (uint j = 0; j < obj->_anims.size(); ++j) {
-			Animation *anim;
-
-			anim = _vm->_anims->getAnimation(obj->_anims[j]);
-			if (anim != NULL && anim->getIndex() > lastAnimIndex)
-				obj->_anims.remove_at(j);
-		}
-	}
-
-	_vm->_anims->deleteAfterIndex(lastAnimIndex);
-
 	setExitLoop(false);
 }
 
@@ -1513,6 +1485,24 @@
 	return _markedAnimationIndex;
 }
 
+void Game::deleteAnimationsAfterIndex(int lastAnimIndex) {
+	// Delete all animations loaded after the marked one 
+	// (from objects and from the AnimationManager)
+	for (uint i = 0; i < getNumObjects(); ++i) {
+		GameObject *obj = &_objects[i];
+
+		for (uint j = 0; j < obj->_anims.size(); ++j) {
+			Animation *anim;
+
+			anim = _vm->_anims->getAnimation(obj->_anims[j]);
+			if (anim != NULL && anim->getIndex() > lastAnimIndex)
+				obj->_anims.remove_at(j);
+		}
+	}
+
+	_vm->_anims->deleteAfterIndex(lastAnimIndex);
+}
+
 /**
  * See Game::getMarkedAnimationIndex().
  */

Modified: scummvm/trunk/engines/draci/game.h
===================================================================
--- scummvm/trunk/engines/draci/game.h	2009-09-27 21:00:45 UTC (rev 44421)
+++ scummvm/trunk/engines/draci/game.h	2009-09-27 21:25:34 UTC (rev 44422)
@@ -340,6 +340,8 @@
 	int getScheduledPalette() const;
 
 private:
+	void deleteAnimationsAfterIndex(int lastAnimIndex);
+
 	DraciEngine *_vm;
 
 	GameInfo _info;


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