From a04881072a0ab0f537aa01aa5df5aeee750f8b03 Mon Sep 17 00:00:00 2001 From: Robert Špalek Date: Sun, 27 Sep 2009 21:25:34 +0000 Subject: Reduce code duplication when cleaning animations svn-id: r44422 --- engines/draci/game.cpp | 50 ++++++++++++++++++++------------------------------ engines/draci/game.h | 2 ++ 2 files changed, 22 insertions(+), 30 deletions(-) (limited to 'engines/draci') diff --git a/engines/draci/game.cpp b/engines/draci/game.cpp index 5348b7c7fc..a3f73aaac6 100644 --- a/engines/draci/game.cpp +++ b/engines/draci/game.cpp @@ -953,21 +953,7 @@ void Game::runDialogueProg(GPL2Program prog, int offset) { // 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,21 +1394,7 @@ void Game::runGateProgram(int gate) { // 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]; - - 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); setExitLoop(false); } @@ -1513,6 +1485,24 @@ int Game::getMarkedAnimationIndex() const { 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(). */ diff --git a/engines/draci/game.h b/engines/draci/game.h index a3129fdaec..7324322467 100644 --- a/engines/draci/game.h +++ b/engines/draci/game.h @@ -340,6 +340,8 @@ public: int getScheduledPalette() const; private: + void deleteAnimationsAfterIndex(int lastAnimIndex); + DraciEngine *_vm; GameInfo _info; -- cgit v1.2.3