diff options
author | Christopher Page | 2008-06-20 20:20:46 +0000 |
---|---|---|
committer | Christopher Page | 2008-06-20 20:20:46 +0000 |
commit | 8ce5dcc8e84cbd1e58437cebabd129760a873900 (patch) | |
tree | 58e33932959aef32071ae750cd0857435f9b5e9a /engines | |
parent | 0c6c7de3554a65a22324a0aa89b111aa7f2fa79f (diff) | |
parent | 6dce28e166865dd8c892e0e298ed6abcdc1042bd (diff) | |
download | scummvm-rg350-8ce5dcc8e84cbd1e58437cebabd129760a873900.tar.gz scummvm-rg350-8ce5dcc8e84cbd1e58437cebabd129760a873900.tar.bz2 scummvm-rg350-8ce5dcc8e84cbd1e58437cebabd129760a873900.zip |
Merged revisions 31992,32088,32094,32129,32203,32208,32219,32236,32329,32332-32333,32357,32504,32519,32525,32566,32578,32641-32642,32673,32675,32677,32679-32680,32718-32719,32721,32739 via svnmerge from
https://scummvm.svn.sourceforge.net/svnroot/scummvm/scummvm/branches/gsoc2008-rtl
........
r31992 | cpage88 | 2008-05-10 18:44:46 -0500 (Sat, 10 May 2008) | 1 line
Modified game loop to return to launcher, codeblocks layouts update 1.5->1.6
........
r32088 | cpage88 | 2008-05-13 11:09:57 -0500 (Tue, 13 May 2008) | 1 line
used memmove() instead of memcpy() to fix memory overlap error
........
r32094 | cpage88 | 2008-05-13 17:59:19 -0500 (Tue, 13 May 2008) | 1 line
Fixed memory leak by deallocating memory used by window->iconPtr
........
r32129 | cpage88 | 2008-05-14 18:26:32 -0500 (Wed, 14 May 2008) | 1 line
Fixed memory leak when returning to launcher in AGOS engine by properly creating and deleting midi driver pointer
........
r32203 | cpage88 | 2008-05-20 16:40:53 -0500 (Tue, 20 May 2008) | 1 line
AGOS Engine: Began implementation for a new quit event which will cleanly return to the launcher. This replaces the old shutdown() method within delay()
........
r32208 | cpage88 | 2008-05-21 13:52:27 -0500 (Wed, 21 May 2008) | 1 line
AGOS: Fixed two memory leaks when returning to the launcher (_mouseData and _zoneBuffers)
........
r32219 | cpage88 | 2008-05-22 18:40:36 -0500 (Thu, 22 May 2008) | 1 line
AGOS: Fixed a memory leak from earlier in a better way
........
r32236 | cpage88 | 2008-05-23 19:08:13 -0500 (Fri, 23 May 2008) | 1 line
AGI: Fixed two memory leaks when returning to launcher from AGI Engine
........
r32329 | cpage88 | 2008-05-27 15:15:36 -0500 (Tue, 27 May 2008) | 1 line
AGI: Modified AGI Engine to shutdown without using system->quit
........
r32332 | cpage88 | 2008-05-27 18:26:48 -0500 (Tue, 27 May 2008) | 1 line
CINE: Fixed two memory leaks when shutting down the CINE engine
........
r32333 | cpage88 | 2008-05-27 19:52:45 -0500 (Tue, 27 May 2008) | 1 line
CINE: Initialize exitEngine to 0 in mainLoop() to allow replay after returning to the launcher
........
r32357 | cpage88 | 2008-05-28 18:28:11 -0500 (Wed, 28 May 2008) | 1 line
LURE: Fixed some memory leaks when returning to the launcher from the LURE engine
........
r32504 | cpage88 | 2008-06-02 16:08:49 -0500 (Mon, 02 Jun 2008) | 1 line
PARA: Got rid of calls to system->quit() so that the Parallaction engine can return to the launcher. Also fixed a couple of memory leaks.
........
r32519 | cpage88 | 2008-06-03 13:24:54 -0500 (Tue, 03 Jun 2008) | 1 line
PARA: Fixed some memory leaks
........
r32525 | cpage88 | 2008-06-04 00:21:47 -0500 (Wed, 04 Jun 2008) | 1 line
QUEEN: Modified engine to use a quit flag instead of system->quit() in order to return to the launcher
........
r32566 | cpage88 | 2008-06-05 19:34:47 -0500 (Thu, 05 Jun 2008) | 1 line
TOUCHE: Fixed a memory leak
........
r32578 | cpage88 | 2008-06-06 11:40:39 -0500 (Fri, 06 Jun 2008) | 1 line
SKY: Fixed a memory leak in SKY engine
........
r32641 | cpage88 | 2008-06-09 17:26:05 -0500 (Mon, 09 Jun 2008) | 1 line
TOUCHE: Reverted some comments that were used for testing purposes
........
r32642 | cpage88 | 2008-06-09 18:15:17 -0500 (Mon, 09 Jun 2008) | 1 line
Implemented popAllCursors() in CursorManager to ensure that all unnecessary cursors are removed from the cursor stack when returning to the launcher
........
r32673 | cpage88 | 2008-06-12 11:58:02 -0500 (Thu, 12 Jun 2008) | 1 line
SAGA: Fixed memory leaks in the SAGA engine
........
r32675 | cpage88 | 2008-06-12 13:11:09 -0500 (Thu, 12 Jun 2008) | 1 line
LURE: Fixed memory leaks in the LURE engine
........
r32677 | cpage88 | 2008-06-12 13:52:43 -0500 (Thu, 12 Jun 2008) | 1 line
CINE: Fixed memory leaks in the CINE engine
........
r32679 | cpage88 | 2008-06-12 14:34:32 -0500 (Thu, 12 Jun 2008) | 1 line
AGOS: Fixed a memory leak in the AGOS engine
........
r32680 | cpage88 | 2008-06-12 14:43:54 -0500 (Thu, 12 Jun 2008) | 1 line
SCUMM: Fixed a memory leak in the SCUMM engine
........
r32718 | cpage88 | 2008-06-16 12:34:58 -0500 (Mon, 16 Jun 2008) | 1 line
AGOS: Found a system->quit(), changed to _quit=true
........
r32719 | cpage88 | 2008-06-16 13:47:32 -0500 (Mon, 16 Jun 2008) | 1 line
Fixed a problem where the function that I previously implemented, popAllCursors(), was causing the mouse cursor to disapear
........
r32721 | cpage88 | 2008-06-16 14:55:59 -0500 (Mon, 16 Jun 2008) | 1 line
Cleaned up some unnecessary comments
........
r32739 | cpage88 | 2008-06-20 14:38:38 -0500 (Fri, 20 Jun 2008) | 1 line
Reverting changes to codeblocks layouts made in revision 31992
........
svn-id: r32742
Diffstat (limited to 'engines')
53 files changed, 185 insertions, 66 deletions
diff --git a/engines/agi/agi.cpp b/engines/agi/agi.cpp index 81aec3e351..9d88dd73ef 100644 --- a/engines/agi/agi.cpp +++ b/engines/agi/agi.cpp @@ -62,9 +62,7 @@ void AgiEngine::processEvents() { while (_eventMan->pollEvent(event)) { switch (event.type) { case Common::EVENT_QUIT: - _gfx->deinitVideo(); - _gfx->deinitMachine(); - _system->quit(); + _game.quitProgNow = true; break; case Common::EVENT_PREDICTIVE_DIALOG: if (_predictiveDialogRunning) @@ -766,12 +764,15 @@ AgiEngine::~AgiEngine() { } agiDeinit(); + delete _loader; _sound->deinitSound(); delete _sound; _gfx->deinitVideo(); delete _sprites; + delete _picture; free(_game.sbufOrig); _gfx->deinitMachine(); + delete _gfx; delete _rnd; delete _console; diff --git a/engines/agos/agos.cpp b/engines/agos/agos.cpp index 9b22240f83..365f9fcde7 100644 --- a/engines/agos/agos.cpp +++ b/engines/agos/agos.cpp @@ -37,6 +37,7 @@ #include "sound/mididrv.h" #include "sound/mods/protracker.h" +#include "sound/audiocd.h" using Common::File; @@ -96,6 +97,8 @@ AGOSEngine::AGOSEngine(OSystem *syst) _vc_get_out_of_code = 0; _gameOffsetsPtr = 0; + _quit = false; + _debugger = 0; _gameFile = 0; @@ -556,14 +559,17 @@ int AGOSEngine::init() { // Setup midi driver int midiDriver = MidiDriver::detectMusicDriver(MDT_ADLIB | MDT_MIDI); _nativeMT32 = ((midiDriver == MD_MT32) || ConfMan.getBool("native_mt32")); - MidiDriver *driver = MidiDriver::createMidi(midiDriver); + + _driver = MidiDriver::createMidi(midiDriver); + if (_nativeMT32) { - driver->property(MidiDriver::PROP_CHANNEL_MASK, 0x03FE); + _driver->property(MidiDriver::PROP_CHANNEL_MASK, 0x03FE); } _midi.mapMT32toGM (getGameType() != GType_SIMON2 && !_nativeMT32); - _midi.setDriver(driver); + _midi.setDriver(_driver); + int ret = _midi.open(); if (ret) warning("MIDI Player init failed: \"%s\"", _midi.getErrorName (ret)); @@ -875,6 +881,9 @@ AGOSEngine::~AGOSEngine() { delete _gameFile; _midi.close(); + delete _driver; + + AudioCD.destroy(); for (uint i = 0; i < _itemHeap.size(); i++) { delete[] _itemHeap[i]; @@ -883,6 +892,8 @@ AGOSEngine::~AGOSEngine() { free(_tablesHeapPtr - _tablesHeapCurPos); + free(_mouseData); + free(_gameOffsetsPtr); free(_iconFilePtr); free(_itemArrayPtr); @@ -894,6 +905,7 @@ AGOSEngine::~AGOSEngine() { free(_backGroundBuf); free(_backBuf); free(_scaleBuf); + free(_zoneBuffers); free(_window4BackScn); free(_window6BackScn); @@ -937,7 +949,7 @@ void AGOSEngine::pauseEngineIntern(bool pauseIt) { void AGOSEngine::pause() { pauseEngine(true); - while (_pause) { + while (_pause && !_quit) { delay(1); if (_keyPressed.keycode == Common::KEYCODE_p) pauseEngine(false); @@ -974,7 +986,7 @@ int AGOSEngine::go() { (getFeatures() & GF_DEMO)) { int i; - while (1) { + while (!_quit) { for (i = 0; i < 4; i++) { setWindowImage(3, 9902 + i); debug(0, "Displaying image %d", 9902 + i); @@ -1003,7 +1015,7 @@ int AGOSEngine::go() { runSubroutine101(); permitInput(); - while (1) { + while (!_quit) { waitForInput(); handleVerbClicked(_verbHitArea); delay(100); @@ -1012,6 +1024,9 @@ int AGOSEngine::go() { return 0; } + +/* I do not think that this will be used + * void AGOSEngine::shutdown() { // Sync with AGOSEngine::~AGOSEngine() // In Simon 2, this gets deleted along with _sound further down @@ -1019,6 +1034,7 @@ void AGOSEngine::shutdown() { delete _gameFile; _midi.close(); + delete _driver; for (uint i = 0; i < _itemHeap.size(); i++) { delete[] _itemHeap[i]; @@ -1058,6 +1074,7 @@ void AGOSEngine::shutdown() { _system->quit(); } +*/ uint32 AGOSEngine::getTime() const { // FIXME: calling time() is not portable, use OSystem::getMillis instead diff --git a/engines/agos/agos.h b/engines/agos/agos.h index 448d26a9d0..74a0b026e9 100644 --- a/engines/agos/agos.h +++ b/engines/agos/agos.h @@ -269,6 +269,7 @@ protected: uint16 _marks; + bool _quit; bool _scriptVar2; bool _runScriptReturn1; bool _runScriptCondition[40]; @@ -523,6 +524,7 @@ protected: byte _lettersToPrintBuf[80]; MidiPlayer _midi; + MidiDriver *_driver; bool _midiEnabled; bool _nativeMT32; diff --git a/engines/agos/animation.cpp b/engines/agos/animation.cpp index fd78c65002..c92f834a3b 100644 --- a/engines/agos/animation.cpp +++ b/engines/agos/animation.cpp @@ -280,7 +280,7 @@ void MoviePlayer::handleNextFrame() { _rightButtonDown = false; break; case Common::EVENT_QUIT: - _vm->_system->quit(); + _vm->_quit = true; break; default: break; diff --git a/engines/agos/draw.cpp b/engines/agos/draw.cpp index 737f5317af..d38a5ad33b 100644 --- a/engines/agos/draw.cpp +++ b/engines/agos/draw.cpp @@ -473,7 +473,7 @@ void AGOSEngine::restoreBackGround() { animTable = animTableTmp = _screenAnim1; while (animTable->srcPtr) { if (!(animTable->windowNum & 0x8000)) { - memcpy(animTableTmp, animTable, sizeof(AnimTable)); + memmove(animTableTmp, animTable, sizeof(AnimTable)); animTableTmp++; } animTable++; diff --git a/engines/agos/event.cpp b/engines/agos/event.cpp index 250ff2fcfd..010b331cf8 100644 --- a/engines/agos/event.cpp +++ b/engines/agos/event.cpp @@ -142,7 +142,7 @@ bool AGOSEngine::kickoffTimeEvents() { cur_time = getTime() - _gameStoppedClock; - while ((te = _firstTimeStruct) != NULL && te->time <= cur_time) { + while ((te = _firstTimeStruct) != NULL && te->time <= cur_time && !_quit) { result = true; _pendingDeleteTimeEvent = te; invokeTimeEvent(te); @@ -521,7 +521,7 @@ void AGOSEngine::delay(uint amount) { _rightButtonDown++; break; case Common::EVENT_QUIT: - shutdown(); + _quit = true; return; default: break; @@ -544,7 +544,7 @@ void AGOSEngine::delay(uint amount) { _system->delayMillis(this_delay); cur = _system->getMillis(); - } while (cur < start + amount); + } while (cur < start + amount && !_quit); } void AGOSEngine::timer_callback() { diff --git a/engines/agos/gfx.cpp b/engines/agos/gfx.cpp index 193b7347d6..c014413bdc 100644 --- a/engines/agos/gfx.cpp +++ b/engines/agos/gfx.cpp @@ -1263,7 +1263,7 @@ void AGOSEngine::setWindowImageEx(uint16 mode, uint16 vga_res) { if (getGameType() == GType_WW && (mode == 6 || mode == 8 || mode == 9)) { setWindowImage(mode, vga_res); } else { - while (_copyScnFlag) + while (_copyScnFlag && !_quit) delay(1); setWindowImage(mode, vga_res); diff --git a/engines/agos/input.cpp b/engines/agos/input.cpp index add7eb96f0..d36549f187 100644 --- a/engines/agos/input.cpp +++ b/engines/agos/input.cpp @@ -189,12 +189,12 @@ void AGOSEngine::waitForInput() { resetVerbs(); } - for (;;) { + while (!_quit) { _lastHitArea = NULL; _lastHitArea3 = NULL; _dragAccept = 1; - for (;;) { + while (!_quit) { if ((getGameType() == GType_SIMON1 || getGameType() == GType_SIMON2) && _keyPressed.keycode == Common::KEYCODE_F10) displayBoxStars(); diff --git a/engines/agos/intern.h b/engines/agos/intern.h index 54cf4dba16..4479e2851e 100644 --- a/engines/agos/intern.h +++ b/engines/agos/intern.h @@ -161,6 +161,7 @@ struct WindowBlock { uint8 fill_color, text_color; IconBlock *iconPtr; WindowBlock() { memset(this, 0, sizeof(*this)); } + ~WindowBlock() { free (iconPtr); } }; // note on text offset: // the actual x-coordinate is: textColumn * 8 + textColumnOffset diff --git a/engines/agos/script.cpp b/engines/agos/script.cpp index 44fbb4e9e0..6758aec511 100644 --- a/engines/agos/script.cpp +++ b/engines/agos/script.cpp @@ -410,7 +410,7 @@ void AGOSEngine::o_msg() { void AGOSEngine::o_end() { // 68: exit interpreter - shutdown(); + _quit = true; } void AGOSEngine::o_done() { @@ -965,6 +965,9 @@ void AGOSEngine::writeVariable(uint16 variable, uint16 contents) { int AGOSEngine::runScript() { bool flag; + if (_quit) + return 1; + do { if (_continousMainScript) dumpOpcode(_codePtr); @@ -1007,7 +1010,7 @@ int AGOSEngine::runScript() { error("Invalid opcode '%d' encountered", _opcode); executeOpcode(_opcode); - } while (getScriptCondition() != flag && !getScriptReturn()); + } while (getScriptCondition() != flag && !getScriptReturn() && !_quit); return getScriptReturn(); } @@ -1063,7 +1066,7 @@ void AGOSEngine::waitForSync(uint a) { _exitCutscene = false; _rightButtonDown = false; - while (_vgaWaitFor != 0) { + while (_vgaWaitFor != 0 && !_quit) { if (_rightButtonDown) { if (_vgaWaitFor == 200 && (getGameType() == GType_FF || !getBitFlag(14))) { skipSpeech(); diff --git a/engines/agos/script_e1.cpp b/engines/agos/script_e1.cpp index 94df21979c..c7e1d6736e 100644 --- a/engines/agos/script_e1.cpp +++ b/engines/agos/script_e1.cpp @@ -565,7 +565,7 @@ void AGOSEngine_Elvira1::oe1_look() { lobjFunc(l, "You can see "); /* Show objects */ } if (r && (r->flags & 4) && levelOf(i) < 10000) { - shutdown(); + _quit = true; } } @@ -944,7 +944,7 @@ restart: windowPutChar(window, *message2); if (confirmYesOrNo(120, 62) == 0x7FFF) { - shutdown(); + _quit = true; } else { goto restart; } diff --git a/engines/agos/script_s1.cpp b/engines/agos/script_s1.cpp index a1308b951d..51918b9515 100644 --- a/engines/agos/script_s1.cpp +++ b/engines/agos/script_s1.cpp @@ -345,14 +345,14 @@ void AGOSEngine_Simon1::os1_pauseGame() { if (isSmartphone()) { if (_keyPressed.keycode) { if (_keyPressed.keycode == Common::KEYCODE_RETURN) - shutdown(); + _quit = true; else break; } } #endif if (_keyPressed.keycode == keyYes) - shutdown(); + _quit = true; else if (_keyPressed.keycode == keyNo) break; } diff --git a/engines/agos/subroutine.cpp b/engines/agos/subroutine.cpp index 44ada82585..cb71ed7efa 100644 --- a/engines/agos/subroutine.cpp +++ b/engines/agos/subroutine.cpp @@ -554,6 +554,10 @@ int AGOSEngine::startSubroutine(Subroutine *sub) { _currentTable = sub; restart: + + if (_quit) + return result; + while ((byte *)sl != (byte *)sub) { _currentLine = sl; if (checkIfToRunSubroutineLine(sl, sub)) { diff --git a/engines/cine/cine.cpp b/engines/cine/cine.cpp index efc33fadaf..f6778b6457 100644 --- a/engines/cine/cine.cpp +++ b/engines/cine/cine.cpp @@ -42,7 +42,6 @@ #include "cine/sound.h" #include "cine/various.h" - namespace Cine { Sound *g_sound; @@ -70,6 +69,10 @@ CineEngine::~CineEngine() { freeErrmessDat(); } Common::clearAllSpecialDebugLevels(); + + free(palPtr); + free(partBuffer); + free(textDataPtr); } int CineEngine::init() { diff --git a/engines/cine/main_loop.cpp b/engines/cine/main_loop.cpp index cfb828cf3c..0c5096c0d6 100644 --- a/engines/cine/main_loop.cpp +++ b/engines/cine/main_loop.cpp @@ -186,6 +186,7 @@ void CineEngine::mainLoop(int bootScriptIdx) { uint16 mouseButton; quitFlag = 0; + exitEngine = 0; if (_preLoad == false) { resetBgIncrustList(); diff --git a/engines/cine/pal.h b/engines/cine/pal.h index 70fcc0d98a..768cf0d27d 100644 --- a/engines/cine/pal.h +++ b/engines/cine/pal.h @@ -34,6 +34,8 @@ struct PalEntry { byte pal2[16]; }; +extern PalEntry *palPtr; + void loadPal(const char *fileName); void loadRelatedPalette(const char *fileName); diff --git a/engines/cine/sound.cpp b/engines/cine/sound.cpp index e808de6922..f26032fe98 100644 --- a/engines/cine/sound.cpp +++ b/engines/cine/sound.cpp @@ -249,6 +249,7 @@ AdlibSoundDriver::AdlibSoundDriver(Audio::Mixer *mixer) AdlibSoundDriver::~AdlibSoundDriver() { _mixer->stopHandle(_soundHandle); + OPLDestroy(_opl); } void AdlibSoundDriver::setupChannel(int channel, const byte *data, int instrument, int volume) { diff --git a/engines/lure/lure.cpp b/engines/lure/lure.cpp index 06d3b1984e..ea760ddb4f 100644 --- a/engines/lure/lure.cpp +++ b/engines/lure/lure.cpp @@ -103,6 +103,7 @@ LureEngine::~LureEngine() { if (_initialised) { // Delete and deinitialise subsystems Surface::deinitialise(); + Sound.destroy(); delete _fights; delete _room; delete _menu; @@ -164,10 +165,6 @@ void LureEngine::pauseEngineIntern(bool pause) { } } -void LureEngine::quitGame() { - _system->quit(); -} - const char *LureEngine::generateSaveName(int slotNumber) { static char buffer[15]; diff --git a/engines/lure/lure.h b/engines/lure/lure.h index d66f446247..1c5b40e54b 100644 --- a/engines/lure/lure.h +++ b/engines/lure/lure.h @@ -70,7 +70,6 @@ public: virtual int init(); virtual int go(); virtual void pauseEngineIntern(bool pause); - void quitGame(); Disk &disk() { return *_disk; } diff --git a/engines/lure/menu.cpp b/engines/lure/menu.cpp index cecc415499..0b4ef06081 100644 --- a/engines/lure/menu.cpp +++ b/engines/lure/menu.cpp @@ -57,6 +57,11 @@ MenuRecord::MenuRecord(const MenuRecordBounds *bounds, int numParams, ...) { _width = (bounds->contentsWidth + 3) << 3; } +MenuRecord::~MenuRecord() { + free(_entries); + _entries = NULL; +} + const char *MenuRecord::getEntry(uint8 index) { if (index >= _numEntries) error("Invalid menuitem index specified: %d", index); return _entries[index]; diff --git a/engines/lure/menu.h b/engines/lure/menu.h index b5b7769e34..fcc6308375 100644 --- a/engines/lure/menu.h +++ b/engines/lure/menu.h @@ -56,6 +56,7 @@ private: uint8 _numEntries; public: MenuRecord(const MenuRecordBounds *bounds, int numParams, ...); + ~MenuRecord(); uint16 xstart() { return _xstart; } uint16 width() { return _width; } diff --git a/engines/lure/palette.cpp b/engines/lure/palette.cpp index 03161032c0..badc3c96b0 100644 --- a/engines/lure/palette.cpp +++ b/engines/lure/palette.cpp @@ -106,6 +106,12 @@ Palette::Palette(uint16 resourceId, PaletteSource paletteSource) { delete srcData; } +// Destructor + +Palette::~Palette() { + delete _palette; +} + void Palette::convertRgb64Palette(const byte *srcPalette, uint16 srcNumEntries) { byte *pDest = _palette->data(); const byte *pSrc = srcPalette; diff --git a/engines/lure/palette.h b/engines/lure/palette.h index 1481e22775..9420079346 100644 --- a/engines/lure/palette.h +++ b/engines/lure/palette.h @@ -46,6 +46,7 @@ public: Palette(uint16 srcNumEntries, const byte *srcData, PaletteSource paletteSource); Palette(Palette &src); Palette(uint16 resourceId, PaletteSource paletteSource = DEFAULT); + ~Palette(); uint8 *data() { return _palette->data(); } MemoryBlock *palette() { return _palette; } diff --git a/engines/lure/res.cpp b/engines/lure/res.cpp index f2997d5d17..68de260061 100644 --- a/engines/lure/res.cpp +++ b/engines/lure/res.cpp @@ -349,6 +349,7 @@ void Resources::reloadData() { _indexedRoomExitHospots.push_back(RoomExitIndexedHotspotList::value_type(new RoomExitIndexedHotspotData(indexedRec))); indexedRec++; } + delete mb; // Initialise delay list _delayList.clear(true); diff --git a/engines/lure/sound.cpp b/engines/lure/sound.cpp index 839298d1c5..285f66e4e2 100644 --- a/engines/lure/sound.cpp +++ b/engines/lure/sound.cpp @@ -85,8 +85,10 @@ SoundManager::~SoundManager() { if (_soundData) delete _soundData; - if (_driver) + if (_driver) { _driver->close(); + delete _driver; + } _driver = NULL; g_system->deleteMutex(_soundMutex); @@ -143,7 +145,7 @@ void SoundManager::bellsBodge() { Room &room = Room::getReference(); RoomData *roomData = res.getRoom(room.roomNumber()); - if (roomData->areaFlag != res.fieldList().getField(AREA_FLAG)) { + if (roomData && roomData->areaFlag != res.fieldList().getField(AREA_FLAG)) { res.fieldList().setField(AREA_FLAG, roomData->areaFlag); switch (roomData->areaFlag) { diff --git a/engines/parallaction/dialogue.cpp b/engines/parallaction/dialogue.cpp index 70db637699..b9dea60dc0 100644 --- a/engines/parallaction/dialogue.cpp +++ b/engines/parallaction/dialogue.cpp @@ -105,10 +105,8 @@ uint16 DialogueManager::askPassword() { if (g_system->getEventManager()->pollEvent(e)) { if (e.type == Common::EVENT_QUIT) { - // TODO: don't quit() here, just have caller routines to check - // on kEngineQuit and exit gracefully to allow the engine to shut down _engineFlags |= kEngineQuit; - g_system->quit(); + break; } if ((e.type == Common::EVENT_KEYDOWN) && isdigit(e.kbd.ascii)) { @@ -231,11 +229,19 @@ void DialogueManager::run() { answer = 0; displayQuestion(); + + if (_engineFlags & kEngineQuit) + return; + if (_q->_answers[0] == NULL) break; if (scumm_stricmp(_q->_answers[0]->_text, "NULL")) { if (!displayAnswers()) break; answer = getAnswer(); + + if (_engineFlags & kEngineQuit) + return; + cmdlist = &_q->_answers[answer]->_commands; } @@ -266,7 +272,7 @@ int16 DialogueManager::selectAnswer() { uint32 event; Common::Point p; - while (true) { + while (_engineFlags & kEngineQuit == 0) { _vm->_input->readInput(); _vm->_input->getCursorPos(p); diff --git a/engines/parallaction/exec_ns.cpp b/engines/parallaction/exec_ns.cpp index a4b372f42a..bd2d54c0a0 100644 --- a/engines/parallaction/exec_ns.cpp +++ b/engines/parallaction/exec_ns.cpp @@ -519,6 +519,8 @@ uint16 Parallaction::runZone(ZonePtr z) { case kZoneSpeak: runDialogue(z->u.speak); + if (_engineFlags & kEngineQuit) + return 0; break; } diff --git a/engines/parallaction/graphics.h b/engines/parallaction/graphics.h index 894e0fd678..f03b8538b8 100644 --- a/engines/parallaction/graphics.h +++ b/engines/parallaction/graphics.h @@ -95,6 +95,7 @@ public: } ~SurfaceToFrames() { + _surf->free(); delete _surf; } diff --git a/engines/parallaction/input.cpp b/engines/parallaction/input.cpp index 28d0ad888d..e758bbd41c 100644 --- a/engines/parallaction/input.cpp +++ b/engines/parallaction/input.cpp @@ -80,11 +80,8 @@ uint16 Input::readInput() { break; case Common::EVENT_QUIT: - // TODO: don't quit() here, just have caller routines to check - // on kEngineQuit and exit gracefully to allow the engine to shut down _engineFlags |= kEngineQuit; - _vm->_system->quit(); - break; + return KeyDown; default: break; diff --git a/engines/parallaction/parallaction.cpp b/engines/parallaction/parallaction.cpp index d66b1af1f1..25ebe4263d 100644 --- a/engines/parallaction/parallaction.cpp +++ b/engines/parallaction/parallaction.cpp @@ -84,21 +84,23 @@ Parallaction::Parallaction(OSystem *syst, const PARALLACTIONGameDescription *gam Parallaction::~Parallaction() { + clearSet(_commandOpcodes); + clearSet(_instructionOpcodes); + delete _debugger; - delete _globalTable; - delete _callableNames; - delete _localFlagNames; freeLocation(); freeCharacter(); destroyInventory(); - + + delete _localFlagNames; delete _gfx; delete _soundMan; delete _disk; + delete _input; } @@ -136,9 +138,11 @@ int Parallaction::init() { } - - - +void Parallaction::clearSet(OpcodeSet &opcodes) { + for (Common::Array<const Opcode*>::iterator i = opcodes.begin(); i != opcodes.end(); ++i) + delete *i; + opcodes.clear(); +} void Parallaction::updateView() { @@ -354,12 +358,20 @@ void Parallaction::runGame() { processInput(data); } + if (_engineFlags & kEngineQuit) + return; + runPendingZones(); + if (_engineFlags & kEngineQuit) + return; + if (_engineFlags & kEngineChangeLocation) { changeLocation(_location._name); } + if (_engineFlags & kEngineQuit) + return; _gfx->beginFrame(); @@ -522,11 +534,12 @@ void Character::free() { delete _talk; delete _head; delete _objs; + delete _ani->gfxobj; - _ani->gfxobj = NULL; _talk = NULL; _head = NULL; _objs = NULL; + _ani->gfxobj = NULL; return; } diff --git a/engines/parallaction/parallaction.h b/engines/parallaction/parallaction.h index 6e5957d3cd..5ae1386378 100644 --- a/engines/parallaction/parallaction.h +++ b/engines/parallaction/parallaction.h @@ -385,6 +385,9 @@ protected: // members int16 pickupItem(ZonePtr z); + void clearSet(OpcodeSet &opcodes); + + public: virtual void callFunction(uint index, void* parm) { } @@ -401,6 +404,7 @@ public: void beep(); + public: // const char **_zoneFlagNamesRes; // const char **_zoneTypeNamesRes; diff --git a/engines/parallaction/parallaction_br.cpp b/engines/parallaction/parallaction_br.cpp index 0f5cc2a0c4..b22e1b0f2d 100644 --- a/engines/parallaction/parallaction_br.cpp +++ b/engines/parallaction/parallaction_br.cpp @@ -109,6 +109,9 @@ int Parallaction_br::go() { guiStart(); + if (_engineFlags & kEngineQuit) + return 0; + // initCharacter(); _input->_inputMode = Input::kInputModeGame; diff --git a/engines/parallaction/parallaction_ns.cpp b/engines/parallaction/parallaction_ns.cpp index 2cca3a6a4a..f346a278f7 100644 --- a/engines/parallaction/parallaction_ns.cpp +++ b/engines/parallaction/parallaction_ns.cpp @@ -156,7 +156,9 @@ int Parallaction_ns::init() { Parallaction_ns::~Parallaction_ns() { freeFonts(); - + + delete _locationParser; + delete _programParser; delete _mouseComposedArrow; _location._animations.remove(_char._ani); @@ -233,9 +235,15 @@ int Parallaction_ns::go() { _globalTable = _disk->loadTable("global"); guiStart(); - + + if (_engineFlags & kEngineQuit) + return 0; + changeLocation(_location._name); + if (_engineFlags & kEngineQuit) + return 0; + _input->_inputMode = Input::kInputModeGame; while ((_engineFlags & kEngineQuit) == 0) { runGame(); diff --git a/engines/parallaction/parser.cpp b/engines/parallaction/parser.cpp index f9de6eb4af..6de0a7d7f5 100644 --- a/engines/parallaction/parser.cpp +++ b/engines/parallaction/parser.cpp @@ -30,8 +30,7 @@ namespace Parallaction { char _tokens[20][MAX_TOKEN_LEN]; -Script::Script(Common::ReadStream *input, bool disposeSource) : _input(input), _disposeSource(disposeSource), _line(0) { -} +Script::Script(Common::ReadStream *input, bool disposeSource) : _input(input), _disposeSource(disposeSource), _line(0) {} Script::~Script() { if (_disposeSource) diff --git a/engines/parallaction/parser.h b/engines/parallaction/parser.h index d488cf9b58..1541fb89b2 100644 --- a/engines/parallaction/parser.h +++ b/engines/parallaction/parser.h @@ -221,13 +221,14 @@ public: virtual void init(); virtual ~LocationParser_ns() { + delete _parser; delete _commandsNames; delete _locationStmt; + delete _locationZoneStmt; + delete _locationAnimStmt; delete _zoneTypeNames; delete _zoneFlagNames; - delete _parser; - clearSet(_commandParsers); clearSet(_locationAnimParsers); clearSet(_locationZoneParsers); @@ -356,7 +357,9 @@ public: virtual void init(); virtual ~ProgramParser_ns() { + delete _parser; delete _instructionNames; + clearSet(_instructionParsers); } diff --git a/engines/parallaction/parser_ns.cpp b/engines/parallaction/parser_ns.cpp index 2c4601c938..c654e3008e 100644 --- a/engines/parallaction/parser_ns.cpp +++ b/engines/parallaction/parser_ns.cpp @@ -1397,7 +1397,7 @@ void LocationParser_ns::parseZone(ZoneList &list, char *name) { list.push_front(z); _parser->pushTables(&_locationZoneParsers, _locationZoneStmt); - + return; } diff --git a/engines/queen/input.cpp b/engines/queen/input.cpp index 146e95bcef..9f03c341c9 100644 --- a/engines/queen/input.cpp +++ b/engines/queen/input.cpp @@ -27,6 +27,7 @@ #include "common/events.h" #include "common/system.h" +#include "queen/queen.h" #include "queen/input.h" namespace Queen { @@ -51,12 +52,12 @@ const Verb Input::_verbKeys[] = { VERB_USE }; -Input::Input(Common::Language language, OSystem *system) : +Input::Input(Common::Language language, OSystem *system, QueenEngine *vm) : _system(system), _eventMan(system->getEventManager()), _fastMode(false), _keyVerb(VERB_NONE), _cutawayRunning(false), _canQuit(false), _cutawayQuit(false), _dialogueRunning(false), _talkQuit(false), _quickSave(false), _quickLoad(false), _debugger(false), _inKey(Common::KEYCODE_INVALID), - _mouseButton(0), _idleTime(0) { + _mouseButton(0), _idleTime(0) , _vm(vm) { switch (language) { case Common::EN_ANY: @@ -119,8 +120,8 @@ void Input::delay(uint amount) { break; case Common::EVENT_QUIT: - _system->quit(); - break; + _vm->quitGame(); + return; default: break; diff --git a/engines/queen/input.h b/engines/queen/input.h index 86092aeed6..43a57729c6 100644 --- a/engines/queen/input.h +++ b/engines/queen/input.h @@ -49,7 +49,7 @@ public: MOUSE_RBUTTON = 2 }; - Input(Common::Language language, OSystem *system); + Input(Common::Language language, OSystem *system, QueenEngine *vm); void delay(uint amount); @@ -99,6 +99,8 @@ private: Common::EventManager *_eventMan; + QueenEngine *_vm; + //! some cutaways require update() run faster bool _fastMode; diff --git a/engines/queen/journal.cpp b/engines/queen/journal.cpp index bfbcfa4e59..0327fb74b8 100644 --- a/engines/queen/journal.cpp +++ b/engines/queen/journal.cpp @@ -85,8 +85,8 @@ void Journal::use() { handleMouseWheel(1); break; case Common::EVENT_QUIT: - _system->quit(); - break; + _vm->quitGame(); + return; default: break; } diff --git a/engines/queen/queen.cpp b/engines/queen/queen.cpp index d1a1247c46..c95e44b477 100644 --- a/engines/queen/queen.cpp +++ b/engines/queen/queen.cpp @@ -418,7 +418,7 @@ int QueenEngine::init() { _display = new Display(this, _system); _graphics = new Graphics(this); _grid = new Grid(this); - _input = new Input(_resource->getLanguage(), _system); + _input = new Input(_resource->getLanguage(), _system, this); if (_resource->isDemo()) { _logic = new LogicDemo(this); diff --git a/engines/saga/animation.cpp b/engines/saga/animation.cpp index 3a1e510529..9fffb0f8bf 100644 --- a/engines/saga/animation.cpp +++ b/engines/saga/animation.cpp @@ -55,6 +55,7 @@ Anim::Anim(SagaEngine *vm) : _vm(vm) { Anim::~Anim(void) { reset(); + freeCutawayList(); } void Anim::loadCutawayList(const byte *resourcePointer, size_t resourceLength) { diff --git a/engines/saga/font.cpp b/engines/saga/font.cpp index e936117894..7789949393 100644 --- a/engines/saga/font.cpp +++ b/engines/saga/font.cpp @@ -63,6 +63,8 @@ Font::~Font(void) { free(_fonts[i]); } + + free(_fonts); } diff --git a/engines/saga/interface.cpp b/engines/saga/interface.cpp index 7380570a99..1d048baaad 100644 --- a/engines/saga/interface.cpp +++ b/engines/saga/interface.cpp @@ -334,7 +334,21 @@ Interface::Interface(SagaEngine *vm) : _vm(vm) { Interface::~Interface(void) { free(_inventory); + free(_mainPanel.image); + free(_conversePanel.image); + free(_optionPanel.image); + free(_quitPanel.image); + free(_loadPanel.image); + free(_savePanel.image); + _mainPanel.sprites.freeMem(); + _conversePanel.sprites.freeMem(); + _optionPanel.sprites.freeMem(); + _quitPanel.sprites.freeMem(); + _loadPanel.sprites.freeMem(); + _savePanel.sprites.freeMem(); + _protectPanel.sprites.freeMem(); + _defPortraits.freeMem(); _scenePortraits.freeMem(); } diff --git a/engines/saga/introproc_ihnm.cpp b/engines/saga/introproc_ihnm.cpp index 5f1d0157d5..6614f4098f 100644 --- a/engines/saga/introproc_ihnm.cpp +++ b/engines/saga/introproc_ihnm.cpp @@ -132,6 +132,8 @@ void Scene::IHNMLoadCutaways() { // Load the cutaways for the title screens _vm->_anim->loadCutawayList(resourcePointer, resourceLength); + + free(resourcePointer); } bool Scene::checkKey() { diff --git a/engines/saga/rscfile.cpp b/engines/saga/rscfile.cpp index b7d4f4f1bd..e150caeca5 100644 --- a/engines/saga/rscfile.cpp +++ b/engines/saga/rscfile.cpp @@ -769,6 +769,7 @@ void Resource::loadGlobalResources(int chapter, int actorsEntrance) { _vm->_sprite->_mainSprites.freeMem(); _vm->_sprite->loadList(_metaResource.mainSpritesID, _vm->_sprite->_mainSprites); + _vm->_actor->loadObjList(_metaResource.objectCount, _metaResource.objectsResourceID); _vm->_resource->loadResource(resourceContext, _metaResource.cutawayListResourceID, resourcePointer, resourceLength); @@ -806,6 +807,7 @@ void Resource::loadGlobalResources(int chapter, int actorsEntrance) { // The IHNM demo has a fixed music track and doesn't load a song table _vm->_music->setVolume(_vm->_musicVolume == 10 ? -1 : _vm->_musicVolume * 25, 1); _vm->_music->play(3, MUSIC_LOOP); + free(resourcePointer); } int voiceLUTResourceID = 0; diff --git a/engines/saga/saga.cpp b/engines/saga/saga.cpp index 40eb32b276..fafbd02cec 100644 --- a/engines/saga/saga.cpp +++ b/engines/saga/saga.cpp @@ -79,6 +79,7 @@ SagaEngine::SagaEngine(OSystem *syst, const SAGAGameDescription *gameDesc) _scene = NULL; _isoMap = NULL; _gfx = NULL; + _driver = NULL; _console = NULL; _render = NULL; _music = NULL; @@ -133,6 +134,7 @@ SagaEngine::~SagaEngine() { delete _render; delete _music; delete _sound; + delete _driver; delete _gfx; delete _console; @@ -188,11 +190,11 @@ int SagaEngine::init() { bool native_mt32 = ((midiDriver == MD_MT32) || ConfMan.getBool("native_mt32")); bool adlib = (midiDriver == MD_ADLIB); - MidiDriver *driver = MidiDriver::createMidi(midiDriver); + _driver = MidiDriver::createMidi(midiDriver); if (native_mt32) - driver->property(MidiDriver::PROP_CHANNEL_MASK, 0x03FE); + _driver->property(MidiDriver::PROP_CHANNEL_MASK, 0x03FE); - _music = new Music(this, _mixer, driver, _musicVolume); + _music = new Music(this, _mixer, _driver, _musicVolume); _music->setNativeMT32(native_mt32); _music->setAdlib(adlib); diff --git a/engines/saga/saga.h b/engines/saga/saga.h index 4a5fae7ddb..6b6eb6b3fb 100644 --- a/engines/saga/saga.h +++ b/engines/saga/saga.h @@ -29,6 +29,7 @@ #include "engines/engine.h" #include "common/stream.h" +#include "sound/mididrv.h" #include "saga/gfx.h" #include "saga/list.h" @@ -531,6 +532,7 @@ public: SndRes *_sndRes; Sound *_sound; Music *_music; + MidiDriver *_driver; Anim *_anim; Render *_render; IsoMap *_isoMap; diff --git a/engines/saga/script.cpp b/engines/saga/script.cpp index 7664af314f..088be34c72 100644 --- a/engines/saga/script.cpp +++ b/engines/saga/script.cpp @@ -150,6 +150,7 @@ Script::~Script() { debug(8, "Shutting down scripting subsystem."); _mainStrings.freeMem(); + _globalVoiceLUT.freeMem(); freeModules(); free(_modules); diff --git a/engines/saga/sprite.cpp b/engines/saga/sprite.cpp index e9d002819c..be4f2a423d 100644 --- a/engines/saga/sprite.cpp +++ b/engines/saga/sprite.cpp @@ -74,6 +74,9 @@ Sprite::Sprite(SagaEngine *vm) : _vm(vm) { Sprite::~Sprite(void) { debug(8, "Shutting down sprite subsystem..."); _mainSprites.freeMem(); + _inventorySprites.freeMem(); + _arrowSprites.freeMem(); + _saveReminderSprites.freeMem(); free(_decodeBuf); } diff --git a/engines/scumm/sound.cpp b/engines/scumm/sound.cpp index fdd0598378..7500b16c87 100644 --- a/engines/scumm/sound.cpp +++ b/engines/scumm/sound.cpp @@ -89,6 +89,7 @@ Sound::Sound(ScummEngine *parent, Audio::Mixer *mixer) Sound::~Sound() { stopCDTimer(); + AudioCD.destroy(); delete _sfxFile; } diff --git a/engines/sky/music/adlibmusic.cpp b/engines/sky/music/adlibmusic.cpp index 7c2b262d82..4434f4cd68 100644 --- a/engines/sky/music/adlibmusic.cpp +++ b/engines/sky/music/adlibmusic.cpp @@ -47,6 +47,7 @@ AdlibMusic::AdlibMusic(Audio::Mixer *pMixer, Disk *pDisk) AdlibMusic::~AdlibMusic(void) { + OPLDestroy(_opl); _mixer->stopHandle(_soundHandle); } diff --git a/engines/touche/midi.cpp b/engines/touche/midi.cpp index 14cb85912a..ce62849d2f 100644 --- a/engines/touche/midi.cpp +++ b/engines/touche/midi.cpp @@ -107,6 +107,7 @@ void MidiPlayer::close() { _mutex.lock(); _driver->setTimerCallback(NULL, NULL); _driver->close(); + delete _driver; _driver = 0; _parser->setMidiDriver(NULL); delete _parser; diff --git a/engines/touche/touche.cpp b/engines/touche/touche.cpp index 6520fb5e4a..06ee28dae8 100644 --- a/engines/touche/touche.cpp +++ b/engines/touche/touche.cpp @@ -96,6 +96,7 @@ int ToucheEngine::init() { MidiDriver *driver = MidiDriver::createMidi(midiDriver); _midiPlayer = new MidiPlayer(driver, native_mt32); + _mixer->setVolumeForSoundType(Audio::Mixer::kSFXSoundType, ConfMan.getInt("sfx_volume")); _mixer->setVolumeForSoundType(Audio::Mixer::kSpeechSoundType, ConfMan.getInt("speech_volume")); _mixer->setVolumeForSoundType(Audio::Mixer::kMusicSoundType, Audio::Mixer::kMaxMixerVolume); |