diff options
author | Denis Kasak | 2009-07-24 05:00:53 +0000 |
---|---|---|
committer | Denis Kasak | 2009-07-24 05:00:53 +0000 |
commit | c1ad0c3926f4d53a9c5fdefefde9344d4abb6f10 (patch) | |
tree | b6927f0a7416aa6148ea023d9bb0a5460fef00cf /engines/draci/script.cpp | |
parent | a2bca06b3fe00379d8accf29e7f442fe0a3cd781 (diff) | |
download | scummvm-rg350-c1ad0c3926f4d53a9c5fdefefde9344d4abb6f10.tar.gz scummvm-rg350-c1ad0c3926f4d53a9c5fdefefde9344d4abb6f10.tar.bz2 scummvm-rg350-c1ad0c3926f4d53a9c5fdefefde9344d4abb6f10.zip |
* Added tracking and deleting animations by index (which represents the order in which they were loaded). This is needed by some GPL commands.
* Added Game::getNumObjects() which returns the number of objects in the game
* Fixed segfault (accessing a null Animation *)
* Added some docs to various things
svn-id: r42683
Diffstat (limited to 'engines/draci/script.cpp')
-rw-r--r-- | engines/draci/script.cpp | 28 |
1 files changed, 26 insertions, 2 deletions
diff --git a/engines/draci/script.cpp b/engines/draci/script.cpp index 2d0a33db86..2dd5d9288a 100644 --- a/engines/draci/script.cpp +++ b/engines/draci/script.cpp @@ -78,8 +78,8 @@ void Script::setupCommandList() { { 18, 3, "StopMusic", 0, { 0 }, NULL }, { 18, 4, "FadeOutMusic", 1, { 1 }, NULL }, { 18, 5, "FadeInMusic", 1, { 1 }, NULL }, - { 19, 1, "Mark", 0, { 0 }, NULL }, - { 19, 2, "Release", 0, { 0 }, NULL }, + { 19, 1, "Mark", 0, { 0 }, &Script::mark }, + { 19, 2, "Release", 0, { 0 }, &Script::release }, { 20, 1, "Play", 0, { 0 }, NULL }, { 21, 1, "LoadMap", 1, { 2 }, NULL }, { 21, 2, "RoomMap", 0, { 0 }, NULL }, @@ -307,6 +307,30 @@ void Script::c_Let(Common::Queue<int> ¶ms) { _vm->_game->setVariable(var, value); } +void Script::mark(Common::Queue<int> ¶ms) { + _vm->_game->setMarkedAnimationIndex(_vm->_anims->getLastIndex()); +} + +void Script::release(Common::Queue<int> ¶ms) { + int markedIndex = _vm->_game->getMarkedAnimationIndex(); + + // Also delete those animations from the game's objects + for (uint i = 0; i < _vm->_game->getNumObjects(); ++i) { + GameObject *obj = _vm->_game->getObject(i); + + for (uint j = 0; j < obj->_anims.size(); ++j) { + Animation *anim; + + anim = _vm->_anims->getAnimation(obj->_anims[j]); + if (anim != NULL && anim->getIndex() > markedIndex) + obj->_anims.remove_at(j); + } + } + + // Delete animations which have an index greater than the marked index + _vm->_anims->deleteAfterIndex(markedIndex); +} + /** * @brief Evaluates mathematical expressions * @param reader Stream reader set to the beginning of the expression |