diff options
-rw-r--r-- | engines/mohawk/graphics.cpp | 1 | ||||
-rw-r--r-- | engines/mohawk/myst.cpp | 64 | ||||
-rw-r--r-- | engines/mohawk/myst.h | 9 |
3 files changed, 69 insertions, 5 deletions
diff --git a/engines/mohawk/graphics.cpp b/engines/mohawk/graphics.cpp index f472a9d721..a2fb8e3f0c 100644 --- a/engines/mohawk/graphics.cpp +++ b/engines/mohawk/graphics.cpp @@ -92,6 +92,7 @@ MystGraphics::~MystGraphics() { delete _bmpDecoder; delete _jpegDecoder; delete _pictDecoder; + delete[] _pictureFile.entries; } static const char* picFileNames[] = { diff --git a/engines/mohawk/myst.cpp b/engines/mohawk/myst.cpp index b351f611e3..be0ac1c2e4 100644 --- a/engines/mohawk/myst.cpp +++ b/engines/mohawk/myst.cpp @@ -64,6 +64,14 @@ MohawkEngine_Myst::MohawkEngine_Myst(OSystem *syst, const MohawkGameDescription _needsUpdate = false; _curResource = -1; + _gfx = NULL; + _console = NULL; + _scriptParser = NULL; + _varStore = NULL; + _saveLoad = NULL; + _loadDialog = NULL; + _optionsDialog = NULL; + _cursorHintCount = 0; _cursorHints = NULL; @@ -83,6 +91,8 @@ MohawkEngine_Myst::MohawkEngine_Myst(OSystem *syst, const MohawkGameDescription } MohawkEngine_Myst::~MohawkEngine_Myst() { + DebugMan.clearAllDebugChannels(); + delete _gfx; delete _console; delete _scriptParser; @@ -90,10 +100,17 @@ MohawkEngine_Myst::~MohawkEngine_Myst() { delete _saveLoad; delete _loadDialog; delete _optionsDialog; + + delete[] _cursorHints; + delete[] _view.conditionalImages; delete[] _view.scriptResources; - delete[] _cursorHints; - _resources.clear(); + + while(!_resources.empty()) { + MystResource *temp = _resources.back(); + _resources.pop_back(); + delete temp; + } } // Uses cached data objects in preference to disk access @@ -949,7 +966,11 @@ static MystResource *loadResource(MohawkEngine_Myst *vm, Common::SeekableReadStr } void MohawkEngine_Myst::loadResources() { - _resources.clear(); + while(!_resources.empty()) { + MystResource *temp = _resources.back(); + _resources.pop_back(); + delete temp; + } if (!_view.rlst) { debugC(kDebugResource, "No RLST present"); @@ -1011,6 +1032,9 @@ MystResource::MystResource(MohawkEngine_Myst *vm, Common::SeekableReadStream *rl (_flags & kMystSubimageEnableFlag) != 0); } +MystResource::~MystResource() { +} + void MystResource::handleMouseUp() { if (_dest != 0) _vm->changeToCard(_dest); @@ -1021,6 +1045,7 @@ void MystResource::handleMouseUp() { MystResourceType5::MystResourceType5(MohawkEngine_Myst *vm, Common::SeekableReadStream *rlstStream, MystResource *parent) : MystResource(vm, rlstStream, parent) { debugC(kDebugResource, "\tResource Type 5 Script:"); + _scripts = NULL; _scriptCount = rlstStream->readUint16LE(); debugC(kDebugResource, "\tOpcode Count: %d", _scriptCount); @@ -1046,6 +1071,12 @@ MystResourceType5::MystResourceType5(MohawkEngine_Myst *vm, Common::SeekableRead } } +MystResourceType5::~MystResourceType5() { + for (uint16 i = 0; i < _scriptCount; i++) + delete[] _scripts[i].values; + delete[] _scripts; +} + void MystResourceType5::handleMouseUp() { _vm->_scriptParser->runScript(_scriptCount, _scripts, this); } @@ -1133,6 +1164,14 @@ MystResourceType7::MystResourceType7(MohawkEngine_Myst *vm, Common::SeekableRead _subResources.push_back(loadResource(vm, rlstStream, this)); } +MystResourceType7::~MystResourceType7() { + while(!_subResources.empty()) { + MystResource *temp = _subResources.back(); + _subResources.pop_back(); + delete temp; + } +} + // TODO: All these functions to switch subresource are very similar. // Find way to share code (function pointer pass?) void MystResourceType7::drawDataToScreen() { @@ -1286,6 +1325,10 @@ MystResourceType8::MystResourceType8(MohawkEngine_Myst *vm, Common::SeekableRead } } +MystResourceType8::~MystResourceType8() { + delete[] _subImages; +} + void MystResourceType8::drawDataToScreen() { // Need to call overidden Type 7 function to ensure // switch section is processed correctly. @@ -1416,6 +1459,11 @@ MystResourceType10::MystResourceType10(MohawkEngine_Myst *vm, Common::SeekableRe warning("TODO: Card contains Type 10 Resource - Function not yet implemented"); } +MystResourceType10::~MystResourceType10() { + for (byte i = 0; i < 4; i++) + delete[] _lists[i].list; +} + void MystResourceType10::handleMouseUp() { // TODO } @@ -1472,6 +1520,11 @@ MystResourceType11::MystResourceType11(MohawkEngine_Myst *vm, Common::SeekableRe warning("TODO: Card contains Type 11 Resource - Function not yet implemented"); } +MystResourceType11::~MystResourceType11() { + for (byte i = 0; i < 3; i++) + delete[] _lists[i].list; +} + void MystResourceType11::handleMouseUp() { // TODO @@ -1557,6 +1610,11 @@ MystResourceType12::MystResourceType12(MohawkEngine_Myst *vm, Common::SeekableRe _doAnimation = false; } +MystResourceType12::~MystResourceType12() { + for (byte i = 0; i < 3; i++) + delete[] _lists[i].list; +} + void MystResourceType12::handleAnimation() { // TODO: Probably not final version. Variable/Type 11 Controlled? if (_doAnimation) { diff --git a/engines/mohawk/myst.h b/engines/mohawk/myst.h index 7486e559bb..a66456e1c8 100644 --- a/engines/mohawk/myst.h +++ b/engines/mohawk/myst.h @@ -157,7 +157,7 @@ struct MystScriptEntry { class MystResource { public: MystResource(MohawkEngine_Myst *vm, Common::SeekableReadStream *rlstStream, MystResource *parent); - virtual ~MystResource() {} + virtual ~MystResource(); MystResource *_parent; @@ -188,6 +188,7 @@ protected: class MystResourceType5 : public MystResource { public: MystResourceType5(MohawkEngine_Myst *vm, Common::SeekableReadStream *rlstStream, MystResource *parent); + virtual ~MystResourceType5(); void handleMouseUp(); protected: @@ -218,7 +219,7 @@ private: struct MystResourceType7 : public MystResource { public: MystResourceType7(MohawkEngine_Myst *vm, Common::SeekableReadStream *rlstStream, MystResource *parent); - virtual ~MystResourceType7() {} + virtual ~MystResourceType7(); virtual void drawDataToScreen(); virtual void handleAnimation(); @@ -237,6 +238,7 @@ protected: class MystResourceType8 : public MystResourceType7 { public: MystResourceType8(MohawkEngine_Myst *vm, Common::SeekableReadStream *rlstStream, MystResource *parent); + virtual ~MystResourceType8(); void drawDataToScreen(); uint16 getType8Var(); @@ -254,6 +256,7 @@ protected: class MystResourceType10 : public MystResourceType8 { public: MystResourceType10(MohawkEngine_Myst *vm, Common::SeekableReadStream *rlstStream, MystResource *parent); + virtual ~MystResourceType10(); void handleMouseUp(); protected: @@ -273,6 +276,7 @@ protected: class MystResourceType11 : public MystResourceType8 { public: MystResourceType11(MohawkEngine_Myst *vm, Common::SeekableReadStream *rlstStream, MystResource *parent); + virtual ~MystResourceType11(); void handleMouseUp(); protected: @@ -292,6 +296,7 @@ protected: class MystResourceType12 : public MystResourceType8 { public: MystResourceType12(MohawkEngine_Myst *vm, Common::SeekableReadStream *rlstStream, MystResource *parent); + virtual ~MystResourceType12(); void handleAnimation(); void handleMouseUp(); |