aboutsummaryrefslogtreecommitdiff
path: root/engines/mads
diff options
context:
space:
mode:
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();
}
}