diff options
| author | Filippos Karapetis | 2014-05-04 03:54:54 +0300 | 
|---|---|---|
| committer | Filippos Karapetis | 2014-05-04 03:54:54 +0300 | 
| commit | 0023e99621ba91ba87e4241e2a1ef6f97da4e7c0 (patch) | |
| tree | cc7f68d1cc8742679fd9242c3b1188ed85c1a570 | |
| parent | 27982c850a66cf1db10078b9ac576170b8c34bf5 (diff) | |
| download | scummvm-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
| -rw-r--r-- | engines/mads/sprites.cpp | 14 | 
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();  	}  } | 
