diff options
author | Florian Kagerer | 2009-05-31 01:24:08 +0000 |
---|---|---|
committer | Florian Kagerer | 2009-05-31 01:24:08 +0000 |
commit | c938667d4b60005a926007376305f3da8621f7c7 (patch) | |
tree | a6c2bd7655a64319269e8be65d90c5c0aa2f13d7 | |
parent | abe8cf06255f7398127912354dfbf84daceff569 (diff) | |
download | scummvm-rg350-c938667d4b60005a926007376305f3da8621f7c7.tar.gz scummvm-rg350-c938667d4b60005a926007376305f3da8621f7c7.tar.bz2 scummvm-rg350-c938667d4b60005a926007376305f3da8621f7c7.zip |
LOL: - fix shape memory allocation/release issue
svn-id: r41055
-rw-r--r-- | engines/kyra/lol.cpp | 21 | ||||
-rw-r--r-- | engines/kyra/sprites_lol.cpp | 15 |
2 files changed, 20 insertions, 16 deletions
diff --git a/engines/kyra/lol.cpp b/engines/kyra/lol.cpp index 45ab0202eb..c0fe0f3f69 100644 --- a/engines/kyra/lol.cpp +++ b/engines/kyra/lol.cpp @@ -314,21 +314,12 @@ LoLEngine::~LoLEngine() { delete[] _healiShapes; } - if (_monsterShapes) { - for (int i = 0; i < 48; i++) - delete[] _monsterShapes[i]; - delete[] _monsterShapes; - } - if (_monsterPalettes) { - for (int i = 0; i < 48; i++) - delete[] _monsterPalettes[i]; - delete[] _monsterPalettes; - } - if (_monsterShapesEx) { - for (int i = 0; i < 576; i++) - delete[] _monsterShapesEx[i]; - delete[] _monsterShapesEx; - } + for (int i = 0; i < 3; i++) + releaseMonsterShapes(i); + + delete[] _monsterShapes; + delete[] _monsterPalettes; + delete[] _monsterShapesEx; if (_automapShapes) delete[] _automapShapes; diff --git a/engines/kyra/sprites_lol.cpp b/engines/kyra/sprites_lol.cpp index adc3fd09e7..a936c4340d 100644 --- a/engines/kyra/sprites_lol.cpp +++ b/engines/kyra/sprites_lol.cpp @@ -123,9 +123,14 @@ void LoLEngine::loadMonsterShapes(const char *file, int monsterIndex, int animTy void LoLEngine::releaseMonsterShapes(int monsterIndex) { for (int i = 0; i < 16; i++) { int pos = (monsterIndex << 4) + i; + int pos2 = (monsterIndex << 4) + 16; if (_monsterShapes[pos]) { + uint8 *t = _monsterShapes[pos]; delete[] _monsterShapes[pos]; - _monsterShapes[pos] = 0; + for (int ii = pos; ii < pos2; ii++) { + if (_monsterShapes[ii] == t) + _monsterShapes[ii] = 0; + } } if (_monsterPalettes[pos]) { @@ -133,6 +138,14 @@ void LoLEngine::releaseMonsterShapes(int monsterIndex) { _monsterPalettes[pos] = 0; } } + + for (int i = 0; i < 192; i++) { + int pos = (monsterIndex * 192) + i; + if (_monsterShapesEx[pos]) { + delete[] _monsterShapesEx[pos]; + _monsterShapesEx[pos] = 0; + } + } } int LoLEngine::deleteMonstersFromBlock(int block) { |