aboutsummaryrefslogtreecommitdiff
path: root/engines/mads/sprites.cpp
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/mads/sprites.cpp
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/mads/sprites.cpp')
-rw-r--r--engines/mads/sprites.cpp19
1 files changed, 15 insertions, 4 deletions
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;
}