aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorPaul Gilbert2014-04-06 21:24:35 -0400
committerPaul Gilbert2014-04-06 21:24:35 -0400
commit2457905ed42820d27264a4beccc9ae45da746c18 (patch)
tree6bc39595a2578fbbe23a45a7da307f0199765fbd /engines
parentbd11534499ef169700b0ddb450cc93cff434be6b (diff)
downloadscummvm-rg350-2457905ed42820d27264a4beccc9ae45da746c18.tar.gz
scummvm-rg350-2457905ed42820d27264a4beccc9ae45da746c18.tar.bz2
scummvm-rg350-2457905ed42820d27264a4beccc9ae45da746c18.zip
MADS: Fixes for switching between scenes
Diffstat (limited to 'engines')
-rw-r--r--engines/mads/game.cpp5
-rw-r--r--engines/mads/player.cpp3
-rw-r--r--engines/mads/scene.cpp7
-rw-r--r--engines/mads/scene.h6
-rw-r--r--engines/mads/sprites.cpp19
5 files changed, 34 insertions, 6 deletions
diff --git a/engines/mads/game.cpp b/engines/mads/game.cpp
index d964c14451..90ea105bd1 100644
--- a/engines/mads/game.cpp
+++ b/engines/mads/game.cpp
@@ -143,6 +143,8 @@ void Game::gameLoop() {
}
_player.releasePlayerSprites();
+ assert(_scene._sprites.size() == 0);
+
_vm->_palette->unlock();
_vm->_events->waitCursor();
_vm->_events->freeCursors();
@@ -271,7 +273,8 @@ void Game::sectionLoop() {
_scene._reloadSceneFlag = false;
- warning("TODO: sub_1DD8C, sub_1DD7E");
+ _scene._userInterface.noInventoryAnim();
+ _scene.removeSprites();
if (!_player._loadedFirst) {
_player._spritesLoaded = false;
diff --git a/engines/mads/player.cpp b/engines/mads/player.cpp
index b337f8ada0..10d8b3e327 100644
--- a/engines/mads/player.cpp
+++ b/engines/mads/player.cpp
@@ -675,6 +675,9 @@ void Player::releasePlayerSprites() {
scene._sprites.remove(spriteEnd);
} while (--spriteEnd >= _spritesStart);
}
+
+ _spritesLoaded = false;
+ _spritesChanged = true;
}
} // End of namespace MADS
diff --git a/engines/mads/scene.cpp b/engines/mads/scene.cpp
index 9ef7d0b245..d297cb79ec 100644
--- a/engines/mads/scene.cpp
+++ b/engines/mads/scene.cpp
@@ -389,7 +389,7 @@ void Scene::doFrame() {
_animFlag = true;
_vm->_game->_fx = kTransitionNone;
- if (_freeAnimationFlag) {
+ if (_freeAnimationFlag && _activeAnimation) {
_activeAnimation->free();
_activeAnimation = nullptr;
}
@@ -570,6 +570,11 @@ void Scene::free() {
_sceneInfo = nullptr;
}
+void Scene::removeSprites() {
+ for (int idx = _sprites.size() - 1; idx >= _spritesCount; --idx)
+ _sprites.remove(idx);
+}
+
void Scene::changeVariant(int variant) {
_variant = variant;
_sceneInfo->loadCodes(_depthSurface, variant);
diff --git a/engines/mads/scene.h b/engines/mads/scene.h
index dbb218842b..b0ecf111e6 100644
--- a/engines/mads/scene.h
+++ b/engines/mads/scene.h
@@ -214,6 +214,12 @@ public:
void resetScene();
void backgroundAnimation();
+
+ /**
+ * Removes all the scene specific sprites fromt the sprites list,
+ * leaving any player sprites list in place at the start of the list.
+ */
+ void removeSprites();
};
} // End of namespace MADS
diff --git a/engines/mads/sprites.cpp b/engines/mads/sprites.cpp
index 442125e929..0dd640bca0 100644
--- a/engines/mads/sprites.cpp
+++ b/engines/mads/sprites.cpp
@@ -372,14 +372,18 @@ int SpriteSets::add(SpriteAsset *asset, int idx) {
if (idx >= (int)size())
resize(idx + 1);
- delete (*this)[idx];
- (*this)[idx] = asset;
+ if ((*this)[idx]) {
+ delete (*this)[idx];
+ } else {
+ ++_assetCount;
+ }
+
+ (*this)[idx] = asset;
return idx;
}
int SpriteSets::addSprites(const Common::String &resName, int flags) {
- ++_assetCount;
return add(new SpriteAsset(_vm, resName, flags));
}
@@ -394,7 +398,14 @@ void SpriteSets::clear() {
void SpriteSets::remove(int idx) {
if (idx >= 0) {
delete (*this)[idx];
- (*this)[idx] = nullptr;
+
+ if (idx < ((int)size() - 1))
+ (*this)[idx] = nullptr;
+ else {
+ do {
+ remove_at(size() - 1);
+ } while (size() > 0 && (*this)[size() - 1] == nullptr);
+ }
--_assetCount;
}