From 7f82b0eafa1663c6f8a46ba62f267cfef85dd2c5 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sun, 18 May 2014 23:00:04 +0200 Subject: [PATCH] MADS: Rework removePlayerSprites(), get rid of another TODO --- engines/mads/animation.h | 2 ++ engines/mads/nebular/nebular_scenes2.cpp | 2 +- engines/mads/player.cpp | 11 +++++++---- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/engines/mads/animation.h b/engines/mads/animation.h index 0556c3aa197..a1d957ee459 100644 --- a/engines/mads/animation.h +++ b/engines/mads/animation.h @@ -217,6 +217,8 @@ public: bool freeFlag() const { return _freeFlag; } bool getAnimMode() const { return _header._animMode; } int roomNumber() const { return _header._roomNumber; } + + void resetSpriteSetsCount() { _header._spriteSetsCount = 0; } // CHECKME: See if it doesn't leak the memory when the destructor is called }; } // End of namespace MADS diff --git a/engines/mads/nebular/nebular_scenes2.cpp b/engines/mads/nebular/nebular_scenes2.cpp index b423b9f9efe..0f8af57651b 100644 --- a/engines/mads/nebular/nebular_scenes2.cpp +++ b/engines/mads/nebular/nebular_scenes2.cpp @@ -1340,7 +1340,7 @@ void Scene205::actions() { _vm->_sound->command(27); } else if (_game._trigger == 1) { if (_scene->_activeAnimation != nullptr) - warning("scene->_activeAnimation._spriteSetsCount = 0;"); + _scene->_activeAnimation->resetSpriteSetsCount(); _vm->_dialogs->show(20516); _scene->_reloadSceneFlag = true; diff --git a/engines/mads/player.cpp b/engines/mads/player.cpp index edec92ad74c..3672c80f326 100644 --- a/engines/mads/player.cpp +++ b/engines/mads/player.cpp @@ -767,17 +767,20 @@ void Player::synchronize(Common::Serializer &s) { } void Player::removePlayerSprites() { + Scene &scene = _vm->_game->_scene; int heroSpriteId = _spritesStart; for (int i = 0; i < 8; i++) { if (_spriteSetsPresent[i]) { - _vm->_game->_scene._sprites.remove(heroSpriteId++); + scene._sprites.remove(heroSpriteId++); _spriteSetsPresent[i] = false; } } - _vm->_game->_scene._spriteSlots.clear(); - _vm->_game->_scene._spriteSlots.fullRefresh(); - _vm->_game->_player._visible = false; + if (scene._activeAnimation != nullptr) + scene._activeAnimation->resetSpriteSetsCount(); + + scene._spriteSlots.fullRefresh(); + _visible = false; } } // End of namespace MADS