diff options
author | uruk | 2014-07-15 13:53:26 +0200 |
---|---|---|
committer | uruk | 2014-07-15 13:53:26 +0200 |
commit | 035fb6ad1cdb8ca126ac8dd5a930b954f650061c (patch) | |
tree | 4cd06b2e32ab15f7b0eb2b954aaae6aa9066561f | |
parent | 753b5f89bab3eb2cdd6d0f4567a76d5d4fd83624 (diff) | |
download | scummvm-rg350-035fb6ad1cdb8ca126ac8dd5a930b954f650061c.tar.gz scummvm-rg350-035fb6ad1cdb8ca126ac8dd5a930b954f650061c.tar.bz2 scummvm-rg350-035fb6ad1cdb8ca126ac8dd5a930b954f650061c.zip |
CGE2: Hopefully fix a memory leak problem regarding Hero::_dim;
-rw-r--r-- | engines/cge2/hero.cpp | 28 | ||||
-rw-r--r-- | engines/cge2/hero.h | 2 |
2 files changed, 10 insertions, 20 deletions
diff --git a/engines/cge2/hero.cpp b/engines/cge2/hero.cpp index 6281e4dd5e..677811885e 100644 --- a/engines/cge2/hero.cpp +++ b/engines/cge2/hero.cpp @@ -33,11 +33,7 @@ namespace CGE2 { Hero::Hero(CGE2Engine *vm) : Sprite(vm), _contact(nullptr), _dir(kNoDir), - _curDim(0), _tracePtr(-1), _ignoreMap(false) { - - for (int i = 0; i < kDimMax; i++) { - _dim[i] = nullptr; - } + _curDim(0), _tracePtr(-1), _ignoreMap(false), _isDimLoaded(false) { } 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! @@ -62,10 +58,14 @@ Sprite *Hero::expand() { // It's very similar to Sprite's expand, but doesn't bo Seq *seq; int section = kIdPhase; - 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 (!_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); + } + + _isDimLoaded = true; } if (_seqCnt) { @@ -200,16 +200,6 @@ Sprite *Hero::expand() { // It's very similar to Sprite's expand, but doesn't bo return this; } -Sprite *Hero::contract() { - /* TODO: Recheck this later! - for (int i = 0; i < kDimMax; i++) { - if (_dim[i] != nullptr) - delete[] _dim[i]; - } - */ - return this; -} - void Hero::setCurrent() { FXP m = _vm->_eye->_z / (_pos3D._z - _vm->_eye->_z); FXP tmp = m * _siz.y; diff --git a/engines/cge2/hero.h b/engines/cge2/hero.h index c277b4a780..f45a65211b 100644 --- a/engines/cge2/hero.h +++ b/engines/cge2/hero.h @@ -62,6 +62,7 @@ struct HeroTab { }; class Hero : public Sprite { + bool _isDimLoaded; int _hig[kDimMax]; Sprite *_contact; public: @@ -77,7 +78,6 @@ public: Hero(CGE2Engine *vm); void tick(); Sprite *expand(); - Sprite *contract(); Sprite *setContact(); int stepSize() { return _ext->_seq[7]._dx; } int distance(V3D pos); |