diff options
author | Robert Špalek | 2009-09-27 21:25:34 +0000 |
---|---|---|
committer | Robert Špalek | 2009-09-27 21:25:34 +0000 |
commit | a04881072a0ab0f537aa01aa5df5aeee750f8b03 (patch) | |
tree | 4293ab6b58d21989f03d78f228e51cf835a71ebd | |
parent | 7971d77dd6bfbe788a01ec2985d1b73847c0dd44 (diff) | |
download | scummvm-rg350-a04881072a0ab0f537aa01aa5df5aeee750f8b03.tar.gz scummvm-rg350-a04881072a0ab0f537aa01aa5df5aeee750f8b03.tar.bz2 scummvm-rg350-a04881072a0ab0f537aa01aa5df5aeee750f8b03.zip |
Reduce code duplication when cleaning animations
svn-id: r44422
-rw-r--r-- | engines/draci/game.cpp | 50 | ||||
-rw-r--r-- | engines/draci/game.h | 2 |
2 files changed, 22 insertions, 30 deletions
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; |