MADS: Fix GCC warnings and memory leaks

This commit is contained in:
Paul Gilbert 2014-03-13 20:56:03 -04:00
parent b2d90ddaab
commit 84fb90e7a5
8 changed files with 36 additions and 7 deletions

View File

@ -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() {

View File

@ -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; }

View File

@ -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;

View File

@ -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;

View File

@ -124,7 +124,7 @@ public:
bool _textActive;
bool _active;
DirtyArea() { _active = false; }
DirtyArea();
void setArea(int width, int height, int maxWidth, int maxHeight);

View File

@ -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);
}
/*------------------------------------------------------------------------*/

View File

@ -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<SpriteAsset *>::clear();
}
/*------------------------------------------------------------------------*/
ImageInterEntry::ImageInterEntry() {

View File

@ -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
*/