aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--engines/mads/animation.cpp26
-rw-r--r--engines/mads/animation.h7
-rw-r--r--engines/mads/nebular/nebular_scenes1.cpp10
-rw-r--r--engines/mads/nebular/nebular_scenes2.cpp2
-rw-r--r--engines/mads/scene.cpp38
-rw-r--r--engines/mads/scene.h5
6 files changed, 45 insertions, 43 deletions
diff --git a/engines/mads/animation.cpp b/engines/mads/animation.cpp
index b2c257332e..ed274eb4a3 100644
--- a/engines/mads/animation.cpp
+++ b/engines/mads/animation.cpp
@@ -170,32 +170,6 @@ Animation::~Animation() {
}
}
-void Animation::free() {
- Scene &scene = _vm->_game->_scene;
- Player &player = _vm->_game->_player;
-
- if (!scene._freeAnimationFlag) {
- scene._spriteSlots.fullRefresh(true);
- scene._sequences.scan();
- }
-
- // Refresh the player
- if (player._visible) {
- player._forceRefresh = true;
- player.update();
- }
-
- // Remove any kernel messages in use by the animation
- for (uint i = 0; i < _messages.size(); ++i) {
- int msgIndex = _messages[i]._kernelMsgIndex;
- if (msgIndex >= 0)
- scene._kernelMessages.remove(msgIndex);
- }
-
- _resetFlag = false;
- delete this;
-}
-
void Animation::load(UserInterface &interfaceSurface, MSurface &depthSurface,
const Common::String &resName, int flags, Common::Array<RGB4> *palAnimData,
SceneInfo *sceneInfo) {
diff --git a/engines/mads/animation.h b/engines/mads/animation.h
index 1fff2c48d1..8afb8cfcef 100644
--- a/engines/mads/animation.h
+++ b/engines/mads/animation.h
@@ -137,7 +137,6 @@ private:
MADSEngine *_vm;
Scene *_scene;
- Common::Array<AnimMessage> _messages;
Common::Array<AnimMiscEntry> _miscEntries;
Common::Array<SpriteAsset *> _spriteSets;
Font *_font;
@@ -179,6 +178,7 @@ public:
Common::Array<int> _spriteListIndexes;
Common::Array<AnimFrameEntry> _frameEntries;
Common::Array<AnimUIEntry> _uiEntries;
+ Common::Array<AnimMessage> _messages;
bool _resetFlag;
int _oldFrameEntry;
@@ -189,11 +189,6 @@ public:
~Animation();
/**
- * Releases scene resources used by the animation, and then deletes it
- */
- void free();
-
- /**
* Loads animation data
*/
void load(UserInterface &interfaceSurface, MSurface &depthSurface, const Common::String &resName,
diff --git a/engines/mads/nebular/nebular_scenes1.cpp b/engines/mads/nebular/nebular_scenes1.cpp
index bb5229ef16..c7ab075d4f 100644
--- a/engines/mads/nebular/nebular_scenes1.cpp
+++ b/engines/mads/nebular/nebular_scenes1.cpp
@@ -1560,7 +1560,7 @@ void Scene104::step() {
switch (_game._trigger) {
case 0:
_scene->_kernelMessages.reset();
- _scene->_activeAnimation->free();
+ _scene->freeAnimation();
_scene->resetScene();
_game._player._stepEnabled = false;
_game._player._visible = false;
@@ -1590,7 +1590,7 @@ void Scene104::step() {
switch (_game._trigger) {
case 0:
_scene->_kernelMessages.reset();
- _scene->_activeAnimation->free();
+ _scene->freeAnimation();
_scene->resetScene();
_game._player._stepEnabled = false;
_game._player._visible = false;
@@ -1629,7 +1629,7 @@ void Scene104::step() {
switch (_game._trigger) {
case 0:
_scene->_kernelMessages.reset();
- _scene->_activeAnimation->free();
+ _scene->freeAnimation();
_scene->resetScene();
_game._player._stepEnabled = false;
_game._player._visible = false;
@@ -2565,7 +2565,7 @@ void Scene109::actions() {
}
}
}
- _scene->_activeAnimation->free();
+ _scene->freeAnimation();
_scene->_sequences.remove(_globals._sequenceIndexes[8]);
_scene->_sprites.remove(_globals._spriteIndexes[8]);
_scene->_spriteSlots.clear();
@@ -2953,7 +2953,7 @@ void Scene112::enter() {
void Scene112::step() {
if ((_scene->_activeAnimation != nullptr) && (_game._storyMode == STORYMODE_NICE)) {
if (_scene->_activeAnimation->getCurrentFrame() >= 54) {
- _scene->_activeAnimation->free();
+ _scene->freeAnimation();
_game._trigger = 70;
}
}
diff --git a/engines/mads/nebular/nebular_scenes2.cpp b/engines/mads/nebular/nebular_scenes2.cpp
index 6080c09fd4..a2d3c45460 100644
--- a/engines/mads/nebular/nebular_scenes2.cpp
+++ b/engines/mads/nebular/nebular_scenes2.cpp
@@ -3709,7 +3709,7 @@ void Scene210::setDialogNode(int node) {
_game._player._visible = false;
_vm->_palette->lock();
_scene->_kernelMessages.reset();
- _scene->_activeAnimation->free();
+ _scene->freeAnimation();
_scene->_activeAnimation = nullptr;
_scene->resetScene();
diff --git a/engines/mads/scene.cpp b/engines/mads/scene.cpp
index 99151c1267..65d1c04c0c 100644
--- a/engines/mads/scene.cpp
+++ b/engines/mads/scene.cpp
@@ -396,11 +396,8 @@ void Scene::doFrame() {
_cyclingActive = true;
_vm->_game->_fx = kTransitionNone;
- if (_freeAnimationFlag && _activeAnimation) {
- _activeAnimation->free();
- _freeAnimationFlag = false;
- _activeAnimation = nullptr;
- }
+ if (_freeAnimationFlag)
+ freeAnimation();
}
void Scene::drawElements(ScreenTransition transitionType, bool surfaceFlag) {
@@ -600,4 +597,35 @@ void Scene::resetScene() {
_sequences.clear();
}
+void Scene::freeAnimation() {
+ if (_activeAnimation) {
+ Player &player = _vm->_game->_player;
+
+ if (!_freeAnimationFlag) {
+ _spriteSlots.fullRefresh(true);
+ _sequences.scan();
+ }
+
+ // Refresh the player
+ if (player._visible) {
+ player._forceRefresh = true;
+ player.update();
+ }
+
+ // Remove any kernel messages in use by the animation
+ for (uint i = 0; i < _activeAnimation->_messages.size(); ++i) {
+ int msgIndex = _activeAnimation->_messages[i]._kernelMsgIndex;
+ if (msgIndex >= 0)
+ _kernelMessages.remove(msgIndex);
+ }
+
+ // Delete the animation
+ delete _activeAnimation;
+ _activeAnimation = nullptr;
+ }
+
+ _freeAnimationFlag = false;
+}
+
+
} // End of namespace MADS
diff --git a/engines/mads/scene.h b/engines/mads/scene.h
index b695f3b1fa..7944576a5a 100644
--- a/engines/mads/scene.h
+++ b/engines/mads/scene.h
@@ -222,6 +222,11 @@ public:
* leaving any player sprites list in place at the start of the list.
*/
void removeSprites();
+
+ /**
+ * Frees any currently active animation for the scene
+ */
+ void freeAnimation();
};
} // End of namespace MADS