diff options
author | uruk | 2014-07-15 22:15:06 +0200 |
---|---|---|
committer | uruk | 2014-07-15 22:15:06 +0200 |
commit | 0b0f998aacb1d8804e8cdf2679df69966a643c41 (patch) | |
tree | 6060cc1e487d7b9f55acef42e52ff0fdf80201e4 /engines/cge2 | |
parent | fbd8f2c390af8f73a138110450e4f2b98adffd49 (diff) | |
download | scummvm-rg350-0b0f998aacb1d8804e8cdf2679df69966a643c41.tar.gz scummvm-rg350-0b0f998aacb1d8804e8cdf2679df69966a643c41.tar.bz2 scummvm-rg350-0b0f998aacb1d8804e8cdf2679df69966a643c41.zip |
CGE2: Try a different approach regarding _dim.
Now it doesn't crash the hospital scene, but I am not entirely sure it's totally leak-free...
Diffstat (limited to 'engines/cge2')
-rw-r--r-- | engines/cge2/hero.cpp | 23 | ||||
-rw-r--r-- | engines/cge2/hero.h | 1 |
2 files changed, 15 insertions, 9 deletions
diff --git a/engines/cge2/hero.cpp b/engines/cge2/hero.cpp index 677811885e..0a72178fe7 100644 --- a/engines/cge2/hero.cpp +++ b/engines/cge2/hero.cpp @@ -33,7 +33,11 @@ namespace CGE2 { Hero::Hero(CGE2Engine *vm) : Sprite(vm), _contact(nullptr), _dir(kNoDir), - _curDim(0), _tracePtr(-1), _ignoreMap(false), _isDimLoaded(false) { + _curDim(0), _tracePtr(-1), _ignoreMap(false) { + + for (int i = 0; i < kDimMax; i++) { + _dim[i] = nullptr; + } } Sprite *Hero::expand() { // It's very similar to Sprite's expand, but doesn't bother with "labels" for example. TODO: Try to unify the two later! @@ -57,15 +61,18 @@ Sprite *Hero::expand() { // It's very similar to Sprite's expand, but doesn't bo int cnt[kActions]; Seq *seq; int section = kIdPhase; - - if (!_isDimLoaded) { - for (int i = 0; i < kDimMax; i++) { - _dim[i] = new Bitmap[_shpCnt]; - for (int j = 0; j < _shpCnt; j++) - _dim[i][j].setVM(_vm); + + for (int i = 0; i < kDimMax; i++) { + if (_dim[i] != nullptr) { + delete[] _dim[i]; + _dim[i] = nullptr; } + } - _isDimLoaded = true; + for (int i = 0; i < kDimMax; i++) { + _dim[i] = new Bitmap[_shpCnt]; + for (int j = 0; j < _shpCnt; j++) + _dim[i][j].setVM(_vm); } if (_seqCnt) { diff --git a/engines/cge2/hero.h b/engines/cge2/hero.h index f45a65211b..e8cce711f4 100644 --- a/engines/cge2/hero.h +++ b/engines/cge2/hero.h @@ -62,7 +62,6 @@ struct HeroTab { }; class Hero : public Sprite { - bool _isDimLoaded; int _hig[kDimMax]; Sprite *_contact; public: |