aboutsummaryrefslogtreecommitdiff
path: root/engines/mads
diff options
context:
space:
mode:
authorFilippos Karapetis2014-05-04 03:54:54 +0300
committerFilippos Karapetis2014-05-04 03:54:54 +0300
commit0023e99621ba91ba87e4241e2a1ef6f97da4e7c0 (patch)
treecc7f68d1cc8742679fd9242c3b1188ed85c1a570 /engines/mads
parent27982c850a66cf1db10078b9ac576170b8c34bf5 (diff)
downloadscummvm-rg350-0023e99621ba91ba87e4241e2a1ef6f97da4e7c0.tar.gz
scummvm-rg350-0023e99621ba91ba87e4241e2a1ef6f97da4e7c0.tar.bz2
scummvm-rg350-0023e99621ba91ba87e4241e2a1ef6f97da4e7c0.zip
MADS: Fix bugs in SpriteSets::remove()
This fixes several crashes when sprites get erased, like for example in death animations
Diffstat (limited to 'engines/mads')
-rw-r--r--engines/mads/sprites.cpp14
1 files changed, 9 insertions, 5 deletions
diff --git a/engines/mads/sprites.cpp b/engines/mads/sprites.cpp
index f187295b00..36cbdbea12 100644
--- a/engines/mads/sprites.cpp
+++ b/engines/mads/sprites.cpp
@@ -399,17 +399,21 @@ void SpriteSets::clear() {
void SpriteSets::remove(int idx) {
if (idx >= 0) {
- delete (*this)[idx];
-
if (idx < ((int)size() - 1)) {
+ delete (*this)[idx];
(*this)[idx] = nullptr;
} else {
- do {
+ while (size() > 0 && (*this)[size() - 1] == nullptr) {
+ delete (*this)[size() - 1];
remove_at(size() - 1);
- } while (size() > 0 && (*this)[size() - 1] == nullptr);
+ }
}
- --_assetCount;
+ if (_assetCount > 0)
+ --_assetCount;
+ else
+ // FIXME: This is needed, otherwise scene sprites are not cleared in this case
+ clear();
}
}