From 84fb90e7a52daffd862159d54cda4817aa930a6f Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Thu, 13 Mar 2014 20:56:03 -0400 Subject: MADS: Fix GCC warnings and memory leaks --- engines/mads/animation.cpp | 2 -- engines/mads/animation.h | 4 ++-- engines/mads/scene.cpp | 3 ++- engines/mads/scene_data.cpp | 5 +++++ engines/mads/scene_data.h | 2 +- engines/mads/sequence.cpp | 6 +++++- engines/mads/sprites.cpp | 11 +++++++++++ engines/mads/sprites.h | 10 ++++++++++ 8 files changed, 36 insertions(+), 7 deletions(-) (limited to 'engines') diff --git a/engines/mads/animation.cpp b/engines/mads/animation.cpp index b5ebb2c278..09a9e1fc04 100644 --- a/engines/mads/animation.cpp +++ b/engines/mads/animation.cpp @@ -145,8 +145,6 @@ Animation::Animation(MADSEngine *vm, Scene *scene) : _vm(vm), _scene(scene) { Animation::~Animation() { delete _font; - for (uint i = 0; i < _spriteSets.size(); ++i) - delete _spriteSets[i]; } void Animation::free() { diff --git a/engines/mads/animation.h b/engines/mads/animation.h index 492fb9dbe4..c5308b7753 100644 --- a/engines/mads/animation.h +++ b/engines/mads/animation.h @@ -182,8 +182,8 @@ public: */ void update(); - virtual void setCurrentFrame(int frameNumber); - virtual int getCurrentFrame() const { return _currentFrame; } + void setCurrentFrame(int frameNumber); + int getCurrentFrame() const { return _currentFrame; } bool freeFlag() const { return _freeFlag; } bool getAnimMode() const { return _header._animMode; } diff --git a/engines/mads/scene.cpp b/engines/mads/scene.cpp index ebc35f0f27..ef5fd78f74 100644 --- a/engines/mads/scene.cpp +++ b/engines/mads/scene.cpp @@ -41,7 +41,8 @@ Scene::Scene(MADSEngine *vm): _vm(vm), _action(_vm), _depthSurface(vm), _animFlag = false; _animVal1 = 0; _depthStyle = 0; - _v1A = _v1C = 0; + _v1A = 0; + _v1C = 0; _roomChanged = false; _reloadSceneFlag = false; _destFacing = 0; diff --git a/engines/mads/scene_data.cpp b/engines/mads/scene_data.cpp index 0cb273a0f4..8f981ef37d 100644 --- a/engines/mads/scene_data.cpp +++ b/engines/mads/scene_data.cpp @@ -140,6 +140,11 @@ void ScreenObjects::proc1() { MADSEngine *DirtyArea::_vm = nullptr; +DirtyArea::DirtyArea() { + _active = false; + _textActive = false; +} + void DirtyArea::setArea(int width, int height, int maxWidth, int maxHeight) { if (_bounds.left % 2) { --_bounds.left; diff --git a/engines/mads/scene_data.h b/engines/mads/scene_data.h index d5c7281fae..d0c61ae3f7 100644 --- a/engines/mads/scene_data.h +++ b/engines/mads/scene_data.h @@ -124,7 +124,7 @@ public: bool _textActive; bool _active; - DirtyArea() { _active = false; } + DirtyArea(); void setArea(int width, int height, int maxWidth, int maxHeight); diff --git a/engines/mads/sequence.cpp b/engines/mads/sequence.cpp index c03ff38c71..c7cbf19693 100644 --- a/engines/mads/sequence.cpp +++ b/engines/mads/sequence.cpp @@ -41,11 +41,15 @@ namespace MADS { _dynamicHotspotIndex = -1; _triggerCountdown = 0; _doneFlag = 0; - _entries._count = 0; _abortMode = ABORTMODE_0; _numTicks = 0; _extraTicks = 0; _timeout = 0; + + _entries._count = 0; + Common::fill(&_entries._mode[0], &_entries._mode[TIMER_ENTRY_SUBSET_MAX], SM_0); + Common::fill(&_entries._frameIndex[0], &_entries._frameIndex[TIMER_ENTRY_SUBSET_MAX], 0); + Common::fill(&_entries._abortVal[0], &_entries._abortVal[TIMER_ENTRY_SUBSET_MAX], 0); } /*------------------------------------------------------------------------*/ diff --git a/engines/mads/sprites.cpp b/engines/mads/sprites.cpp index 228071af23..a7a46ce29f 100644 --- a/engines/mads/sprites.cpp +++ b/engines/mads/sprites.cpp @@ -362,6 +362,10 @@ void SpriteSlots::cleanUp() { /*------------------------------------------------------------------------*/ +SpriteSets::~SpriteSets() { + clear(); +} + int SpriteSets::add(SpriteAsset *asset, int idx) { if (!idx) idx = size(); @@ -378,6 +382,13 @@ int SpriteSets::addSprites(const Common::String &resName, int flags) { return add(new SpriteAsset(_vm, resName, flags)); } +void SpriteSets::clear() { + for (uint i = 0; i < size(); ++i) + delete (*this)[i]; + + Common::Array::clear(); +} + /*------------------------------------------------------------------------*/ ImageInterEntry::ImageInterEntry() { diff --git a/engines/mads/sprites.h b/engines/mads/sprites.h index 603518a923..bf19be1afe 100644 --- a/engines/mads/sprites.h +++ b/engines/mads/sprites.h @@ -206,6 +206,16 @@ public: */ SpriteSets(MADSEngine *vm) : _vm(vm) {} + /** + * Destructor + */ + ~SpriteSets(); + + /** + * Clears the current list, freeing any laoded assets + */ + void clear(); + /** * Add a sprite asset to the list */ -- cgit v1.2.3