[Scummvm-cvs-logs] SF.net SVN: scummvm: [32742] scummvm/trunk

cpage88 at users.sourceforge.net cpage88 at users.sourceforge.net
Fri Jun 20 22:20:46 CEST 2008


Revision: 32742
          http://scummvm.svn.sourceforge.net/scummvm/?rev=32742&view=rev
Author:   cpage88
Date:     2008-06-20 13:20:46 -0700 (Fri, 20 Jun 2008)

Log Message:
-----------
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
........

Revision Links:
--------------
    http://scummvm.svn.sourceforge.net/scummvm/?rev=31992&view=rev

Modified Paths:
--------------
    scummvm/trunk/base/main.cpp
    scummvm/trunk/engines/agi/agi.cpp
    scummvm/trunk/engines/agos/agos.cpp
    scummvm/trunk/engines/agos/agos.h
    scummvm/trunk/engines/agos/animation.cpp
    scummvm/trunk/engines/agos/draw.cpp
    scummvm/trunk/engines/agos/event.cpp
    scummvm/trunk/engines/agos/gfx.cpp
    scummvm/trunk/engines/agos/input.cpp
    scummvm/trunk/engines/agos/intern.h
    scummvm/trunk/engines/agos/script.cpp
    scummvm/trunk/engines/agos/script_e1.cpp
    scummvm/trunk/engines/agos/script_s1.cpp
    scummvm/trunk/engines/agos/subroutine.cpp
    scummvm/trunk/engines/cine/cine.cpp
    scummvm/trunk/engines/cine/main_loop.cpp
    scummvm/trunk/engines/cine/pal.h
    scummvm/trunk/engines/cine/sound.cpp
    scummvm/trunk/engines/lure/lure.cpp
    scummvm/trunk/engines/lure/lure.h
    scummvm/trunk/engines/lure/menu.cpp
    scummvm/trunk/engines/lure/menu.h
    scummvm/trunk/engines/lure/palette.cpp
    scummvm/trunk/engines/lure/palette.h
    scummvm/trunk/engines/lure/res.cpp
    scummvm/trunk/engines/lure/sound.cpp
    scummvm/trunk/engines/parallaction/dialogue.cpp
    scummvm/trunk/engines/parallaction/exec_ns.cpp
    scummvm/trunk/engines/parallaction/graphics.h
    scummvm/trunk/engines/parallaction/input.cpp
    scummvm/trunk/engines/parallaction/parallaction.cpp
    scummvm/trunk/engines/parallaction/parallaction.h
    scummvm/trunk/engines/parallaction/parallaction_br.cpp
    scummvm/trunk/engines/parallaction/parallaction_ns.cpp
    scummvm/trunk/engines/parallaction/parser.cpp
    scummvm/trunk/engines/parallaction/parser.h
    scummvm/trunk/engines/parallaction/parser_ns.cpp
    scummvm/trunk/engines/queen/input.cpp
    scummvm/trunk/engines/queen/input.h
    scummvm/trunk/engines/queen/journal.cpp
    scummvm/trunk/engines/queen/queen.cpp
    scummvm/trunk/engines/saga/animation.cpp
    scummvm/trunk/engines/saga/font.cpp
    scummvm/trunk/engines/saga/interface.cpp
    scummvm/trunk/engines/saga/introproc_ihnm.cpp
    scummvm/trunk/engines/saga/rscfile.cpp
    scummvm/trunk/engines/saga/saga.cpp
    scummvm/trunk/engines/saga/saga.h
    scummvm/trunk/engines/saga/script.cpp
    scummvm/trunk/engines/saga/sprite.cpp
    scummvm/trunk/engines/scumm/sound.cpp
    scummvm/trunk/engines/sky/music/adlibmusic.cpp
    scummvm/trunk/engines/touche/midi.cpp
    scummvm/trunk/engines/touche/touche.cpp
    scummvm/trunk/graphics/cursorman.cpp
    scummvm/trunk/graphics/cursorman.h
    scummvm/trunk/graphics/iff.cpp
    scummvm/trunk/gui/launcher.cpp
    scummvm/trunk/gui/newgui.cpp

Property Changed:
----------------
    scummvm/trunk/


Property changes on: scummvm/trunk
___________________________________________________________________
Name: svnmerge-integrated
   - /scummvm/branches/gsoc2008-gui:1-31703 /scummvm/branches/gsoc2008-rtl:1-31971 /scummvm/branches/gsoc2008-tfmx:1-31765
   + /scummvm/branches/gsoc2008-gui:1-31703 /scummvm/branches/gsoc2008-rtl:1-32741 /scummvm/branches/gsoc2008-tfmx:1-31765

Modified: scummvm/trunk/base/main.cpp
===================================================================
--- scummvm/trunk/base/main.cpp	2008-06-20 20:07:20 UTC (rev 32741)
+++ scummvm/trunk/base/main.cpp	2008-06-20 20:20:46 UTC (rev 32742)
@@ -228,7 +228,9 @@
 	// Reset the file/directory mappings
 	Common::File::resetDefaultDirectories();
 
-	return 0;
+
+
+    return 1;   // Changing from return 0, in order to return to launcher
 }
 
 

Modified: scummvm/trunk/engines/agi/agi.cpp
===================================================================
--- scummvm/trunk/engines/agi/agi.cpp	2008-06-20 20:07:20 UTC (rev 32741)
+++ scummvm/trunk/engines/agi/agi.cpp	2008-06-20 20:20:46 UTC (rev 32742)
@@ -62,9 +62,7 @@
 	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 @@
 	}
 
 	agiDeinit();
+	delete _loader;
 	_sound->deinitSound();
 	delete _sound;
 	_gfx->deinitVideo();
 	delete _sprites;
+	delete _picture;
 	free(_game.sbufOrig);
 	_gfx->deinitMachine();
+	delete _gfx;
 	delete _rnd;
 	delete _console;
 

Modified: scummvm/trunk/engines/agos/agos.cpp
===================================================================
--- scummvm/trunk/engines/agos/agos.cpp	2008-06-20 20:07:20 UTC (rev 32741)
+++ scummvm/trunk/engines/agos/agos.cpp	2008-06-20 20:20:46 UTC (rev 32742)
@@ -37,6 +37,7 @@
 
 #include "sound/mididrv.h"
 #include "sound/mods/protracker.h"
+#include "sound/audiocd.h"
 
 using Common::File;
 
@@ -96,6 +97,8 @@
 	_vc_get_out_of_code = 0;
 	_gameOffsetsPtr = 0;
 
+	_quit = false;
+
 	_debugger = 0;
 
 	_gameFile = 0;
@@ -556,14 +559,17 @@
 		// 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,7 +881,10 @@
 		delete _gameFile;
 
 	_midi.close();
+	delete _driver;
 
+	AudioCD.destroy();
+
 	for (uint i = 0; i < _itemHeap.size(); i++) {
 		delete[] _itemHeap[i];
 	}
@@ -883,6 +892,8 @@
 
 	free(_tablesHeapPtr - _tablesHeapCurPos);
 
+	free(_mouseData);
+	
 	free(_gameOffsetsPtr);
 	free(_iconFilePtr);
 	free(_itemArrayPtr);
@@ -894,6 +905,7 @@
 	free(_backGroundBuf);
 	free(_backBuf);
 	free(_scaleBuf);
+	free(_zoneBuffers);
 
 	free(_window4BackScn);
 	free(_window6BackScn);
@@ -937,7 +949,7 @@
 void AGOSEngine::pause() {
 	pauseEngine(true);
 
-	while (_pause) {
+	while (_pause && !_quit) {
 		delay(1);
 		if (_keyPressed.keycode == Common::KEYCODE_p)
 			pauseEngine(false);
@@ -974,7 +986,7 @@
 		(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 @@
 	runSubroutine101();
 	permitInput();
 
-	while (1) {
+	while (!_quit) {
 		waitForInput();
 		handleVerbClicked(_verbHitArea);
 		delay(100);
@@ -1012,6 +1024,9 @@
 	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 @@
 		delete _gameFile;
 
 	_midi.close();
+	delete _driver;
 
 	for (uint i = 0; i < _itemHeap.size(); i++) {
 		delete[] _itemHeap[i];
@@ -1058,6 +1074,7 @@
 
 	_system->quit();
 }
+*/
 
 uint32 AGOSEngine::getTime() const {
 	// FIXME: calling time() is not portable, use OSystem::getMillis instead

Modified: scummvm/trunk/engines/agos/agos.h
===================================================================
--- scummvm/trunk/engines/agos/agos.h	2008-06-20 20:07:20 UTC (rev 32741)
+++ scummvm/trunk/engines/agos/agos.h	2008-06-20 20:20:46 UTC (rev 32742)
@@ -269,6 +269,7 @@
 
 	uint16 _marks;
 
+	bool _quit;
 	bool _scriptVar2;
 	bool _runScriptReturn1;
 	bool _runScriptCondition[40];
@@ -523,6 +524,7 @@
 	byte _lettersToPrintBuf[80];
 
 	MidiPlayer _midi;
+	MidiDriver *_driver;
 	bool _midiEnabled;
 	bool _nativeMT32;
 

Modified: scummvm/trunk/engines/agos/animation.cpp
===================================================================
--- scummvm/trunk/engines/agos/animation.cpp	2008-06-20 20:07:20 UTC (rev 32741)
+++ scummvm/trunk/engines/agos/animation.cpp	2008-06-20 20:20:46 UTC (rev 32742)
@@ -280,7 +280,7 @@
 			_rightButtonDown = false;
 			break;
 		case Common::EVENT_QUIT:
-			_vm->_system->quit();
+			_vm->_quit = true;
 			break;
 		default:
 			break;

Modified: scummvm/trunk/engines/agos/draw.cpp
===================================================================
--- scummvm/trunk/engines/agos/draw.cpp	2008-06-20 20:07:20 UTC (rev 32741)
+++ scummvm/trunk/engines/agos/draw.cpp	2008-06-20 20:20:46 UTC (rev 32742)
@@ -473,7 +473,7 @@
 		animTable = animTableTmp = _screenAnim1;
 		while (animTable->srcPtr) {
 			if (!(animTable->windowNum & 0x8000)) {
-				memcpy(animTableTmp, animTable, sizeof(AnimTable));
+				memmove(animTableTmp, animTable, sizeof(AnimTable));
 				animTableTmp++;
 			}
 			animTable++;

Modified: scummvm/trunk/engines/agos/event.cpp
===================================================================
--- scummvm/trunk/engines/agos/event.cpp	2008-06-20 20:07:20 UTC (rev 32741)
+++ scummvm/trunk/engines/agos/event.cpp	2008-06-20 20:20:46 UTC (rev 32742)
@@ -142,7 +142,7 @@
 
 	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 @@
 				_rightButtonDown++;
 				break;
 			case Common::EVENT_QUIT:
-				shutdown();
+				_quit = true;
 				return;
 			default:
 				break;
@@ -544,7 +544,7 @@
 		_system->delayMillis(this_delay);
 
 		cur = _system->getMillis();
-	} while (cur < start + amount);
+	} while (cur < start + amount && !_quit);
 }
 
 void AGOSEngine::timer_callback() {

Modified: scummvm/trunk/engines/agos/gfx.cpp
===================================================================
--- scummvm/trunk/engines/agos/gfx.cpp	2008-06-20 20:07:20 UTC (rev 32741)
+++ scummvm/trunk/engines/agos/gfx.cpp	2008-06-20 20:20:46 UTC (rev 32742)
@@ -1263,7 +1263,7 @@
 		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);

Modified: scummvm/trunk/engines/agos/input.cpp
===================================================================
--- scummvm/trunk/engines/agos/input.cpp	2008-06-20 20:07:20 UTC (rev 32741)
+++ scummvm/trunk/engines/agos/input.cpp	2008-06-20 20:20:46 UTC (rev 32742)
@@ -189,12 +189,12 @@
 		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();

Modified: scummvm/trunk/engines/agos/intern.h
===================================================================
--- scummvm/trunk/engines/agos/intern.h	2008-06-20 20:07:20 UTC (rev 32741)
+++ scummvm/trunk/engines/agos/intern.h	2008-06-20 20:20:46 UTC (rev 32742)
@@ -161,6 +161,7 @@
 	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

Modified: scummvm/trunk/engines/agos/script.cpp
===================================================================
--- scummvm/trunk/engines/agos/script.cpp	2008-06-20 20:07:20 UTC (rev 32741)
+++ scummvm/trunk/engines/agos/script.cpp	2008-06-20 20:20:46 UTC (rev 32742)
@@ -410,7 +410,7 @@
 
 void AGOSEngine::o_end() {
 	// 68: exit interpreter
-	shutdown();
+	_quit = true;
 }
 
 void AGOSEngine::o_done() {
@@ -965,6 +965,9 @@
 int AGOSEngine::runScript() {
 	bool flag;
 
+	if (_quit)
+		return 1;
+
 	do {
 		if (_continousMainScript)
 			dumpOpcode(_codePtr);
@@ -1007,7 +1010,7 @@
 			error("Invalid opcode '%d' encountered", _opcode);
 
 		executeOpcode(_opcode);
-	} while (getScriptCondition() != flag && !getScriptReturn());
+	} while  (getScriptCondition() != flag && !getScriptReturn() && !_quit);
 
 	return getScriptReturn();
 }
@@ -1063,7 +1066,7 @@
 	_exitCutscene = false;
 	_rightButtonDown = false;
 
-	while (_vgaWaitFor != 0) {
+	while (_vgaWaitFor != 0 && !_quit) {
 		if (_rightButtonDown) {
 			if (_vgaWaitFor == 200 && (getGameType() == GType_FF || !getBitFlag(14))) {
 				skipSpeech();

Modified: scummvm/trunk/engines/agos/script_e1.cpp
===================================================================
--- scummvm/trunk/engines/agos/script_e1.cpp	2008-06-20 20:07:20 UTC (rev 32741)
+++ scummvm/trunk/engines/agos/script_e1.cpp	2008-06-20 20:20:46 UTC (rev 32742)
@@ -565,7 +565,7 @@
 		lobjFunc(l, "You can see ");	/* Show objects */
 	}
 	if (r && (r->flags & 4) && levelOf(i) < 10000) {
-		shutdown();
+		_quit = true;
 	}
 }
 
@@ -944,7 +944,7 @@
 			windowPutChar(window, *message2);
 
 		if (confirmYesOrNo(120, 62) == 0x7FFF) {
-			shutdown();
+			_quit = true;
 		} else {
 			goto restart;
 		}

Modified: scummvm/trunk/engines/agos/script_s1.cpp
===================================================================
--- scummvm/trunk/engines/agos/script_s1.cpp	2008-06-20 20:07:20 UTC (rev 32741)
+++ scummvm/trunk/engines/agos/script_s1.cpp	2008-06-20 20:20:46 UTC (rev 32742)
@@ -345,14 +345,14 @@
 		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;
 	}

Modified: scummvm/trunk/engines/agos/subroutine.cpp
===================================================================
--- scummvm/trunk/engines/agos/subroutine.cpp	2008-06-20 20:07:20 UTC (rev 32741)
+++ scummvm/trunk/engines/agos/subroutine.cpp	2008-06-20 20:20:46 UTC (rev 32742)
@@ -554,6 +554,10 @@
 
 	_currentTable = sub;
 restart:
+
+	if (_quit)
+		return result;
+
 	while ((byte *)sl != (byte *)sub) {
 		_currentLine = sl;
 		if (checkIfToRunSubroutineLine(sl, sub)) {

Modified: scummvm/trunk/engines/cine/cine.cpp
===================================================================
--- scummvm/trunk/engines/cine/cine.cpp	2008-06-20 20:07:20 UTC (rev 32741)
+++ scummvm/trunk/engines/cine/cine.cpp	2008-06-20 20:20:46 UTC (rev 32742)
@@ -42,7 +42,6 @@
 #include "cine/sound.h"
 #include "cine/various.h"
 
-
 namespace Cine {
 
 Sound *g_sound;
@@ -70,6 +69,10 @@
 		freeErrmessDat();
 	}
 	Common::clearAllSpecialDebugLevels();
+
+	free(palPtr);
+	free(partBuffer);
+	free(textDataPtr);
 }
 
 int CineEngine::init() {

Modified: scummvm/trunk/engines/cine/main_loop.cpp
===================================================================
--- scummvm/trunk/engines/cine/main_loop.cpp	2008-06-20 20:07:20 UTC (rev 32741)
+++ scummvm/trunk/engines/cine/main_loop.cpp	2008-06-20 20:20:46 UTC (rev 32742)
@@ -186,6 +186,7 @@
 	uint16 mouseButton;
 
 	quitFlag = 0;
+	exitEngine = 0;
 
 	if (_preLoad == false) {
 		resetBgIncrustList();

Modified: scummvm/trunk/engines/cine/pal.h
===================================================================
--- scummvm/trunk/engines/cine/pal.h	2008-06-20 20:07:20 UTC (rev 32741)
+++ scummvm/trunk/engines/cine/pal.h	2008-06-20 20:20:46 UTC (rev 32742)
@@ -34,6 +34,8 @@
 	byte pal2[16];
 };
 
+extern PalEntry *palPtr;
+
 void loadPal(const char *fileName);
 
 void loadRelatedPalette(const char *fileName);

Modified: scummvm/trunk/engines/cine/sound.cpp
===================================================================
--- scummvm/trunk/engines/cine/sound.cpp	2008-06-20 20:07:20 UTC (rev 32741)
+++ scummvm/trunk/engines/cine/sound.cpp	2008-06-20 20:20:46 UTC (rev 32742)
@@ -249,6 +249,7 @@
 
 AdlibSoundDriver::~AdlibSoundDriver() {
 	_mixer->stopHandle(_soundHandle);
+	OPLDestroy(_opl);
 }
 
 void AdlibSoundDriver::setupChannel(int channel, const byte *data, int instrument, int volume) {

Modified: scummvm/trunk/engines/lure/lure.cpp
===================================================================
--- scummvm/trunk/engines/lure/lure.cpp	2008-06-20 20:07:20 UTC (rev 32741)
+++ scummvm/trunk/engines/lure/lure.cpp	2008-06-20 20:20:46 UTC (rev 32742)
@@ -103,6 +103,7 @@
 	if (_initialised) {
 		// Delete and deinitialise subsystems
 		Surface::deinitialise();
+		Sound.destroy();
 		delete _fights;
 		delete _room;
 		delete _menu;
@@ -164,10 +165,6 @@
 	}
 }
 
-void LureEngine::quitGame() {
-	_system->quit();
-}
-
 const char *LureEngine::generateSaveName(int slotNumber) {
 	static char buffer[15];
 

Modified: scummvm/trunk/engines/lure/lure.h
===================================================================
--- scummvm/trunk/engines/lure/lure.h	2008-06-20 20:07:20 UTC (rev 32741)
+++ scummvm/trunk/engines/lure/lure.h	2008-06-20 20:20:46 UTC (rev 32742)
@@ -70,7 +70,6 @@
 	virtual int init();
 	virtual int go();
 	virtual void pauseEngineIntern(bool pause);
-	void quitGame();
 
 	Disk &disk() { return *_disk; }
 

Modified: scummvm/trunk/engines/lure/menu.cpp
===================================================================
--- scummvm/trunk/engines/lure/menu.cpp	2008-06-20 20:07:20 UTC (rev 32741)
+++ scummvm/trunk/engines/lure/menu.cpp	2008-06-20 20:20:46 UTC (rev 32742)
@@ -57,6 +57,11 @@
 	_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];

Modified: scummvm/trunk/engines/lure/menu.h
===================================================================
--- scummvm/trunk/engines/lure/menu.h	2008-06-20 20:07:20 UTC (rev 32741)
+++ scummvm/trunk/engines/lure/menu.h	2008-06-20 20:20:46 UTC (rev 32742)
@@ -56,6 +56,7 @@
 	uint8 _numEntries;
 public:
 	MenuRecord(const MenuRecordBounds *bounds, int numParams, ...);
+	~MenuRecord();
 
 	uint16 xstart() { return _xstart; }
 	uint16 width() { return _width; }

Modified: scummvm/trunk/engines/lure/palette.cpp
===================================================================
--- scummvm/trunk/engines/lure/palette.cpp	2008-06-20 20:07:20 UTC (rev 32741)
+++ scummvm/trunk/engines/lure/palette.cpp	2008-06-20 20:20:46 UTC (rev 32742)
@@ -106,6 +106,12 @@
 	delete srcData;
 }
 
+// Destructor
+
+Palette::~Palette() {
+	delete _palette;
+}
+
 void Palette::convertRgb64Palette(const byte *srcPalette, uint16 srcNumEntries) {
 	byte *pDest = _palette->data();
 	const byte *pSrc = srcPalette;

Modified: scummvm/trunk/engines/lure/palette.h
===================================================================
--- scummvm/trunk/engines/lure/palette.h	2008-06-20 20:07:20 UTC (rev 32741)
+++ scummvm/trunk/engines/lure/palette.h	2008-06-20 20:20:46 UTC (rev 32742)
@@ -46,6 +46,7 @@
 	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; }

Modified: scummvm/trunk/engines/lure/res.cpp
===================================================================
--- scummvm/trunk/engines/lure/res.cpp	2008-06-20 20:07:20 UTC (rev 32741)
+++ scummvm/trunk/engines/lure/res.cpp	2008-06-20 20:20:46 UTC (rev 32742)
@@ -349,6 +349,7 @@
 		_indexedRoomExitHospots.push_back(RoomExitIndexedHotspotList::value_type(new RoomExitIndexedHotspotData(indexedRec)));
 		indexedRec++;
 	}
+	delete mb;
 
 	// Initialise delay list
 	_delayList.clear(true);

Modified: scummvm/trunk/engines/lure/sound.cpp
===================================================================
--- scummvm/trunk/engines/lure/sound.cpp	2008-06-20 20:07:20 UTC (rev 32741)
+++ scummvm/trunk/engines/lure/sound.cpp	2008-06-20 20:20:46 UTC (rev 32742)
@@ -85,8 +85,10 @@
 	if (_soundData)
 		delete _soundData;
 
-	if (_driver)
+	if (_driver) {
 		_driver->close();
+		delete _driver;
+	}
 	_driver = NULL;
 
 	g_system->deleteMutex(_soundMutex);
@@ -143,7 +145,7 @@
 	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) {

Modified: scummvm/trunk/engines/parallaction/dialogue.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/dialogue.cpp	2008-06-20 20:07:20 UTC (rev 32741)
+++ scummvm/trunk/engines/parallaction/dialogue.cpp	2008-06-20 20:20:46 UTC (rev 32742)
@@ -105,10 +105,8 @@
 
 		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 @@
 		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 @@
 
 	uint32 event;
 	Common::Point p;
-	while (true) {
+	while (_engineFlags & kEngineQuit == 0) {
 
 		_vm->_input->readInput();
 		_vm->_input->getCursorPos(p);

Modified: scummvm/trunk/engines/parallaction/exec_ns.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/exec_ns.cpp	2008-06-20 20:07:20 UTC (rev 32741)
+++ scummvm/trunk/engines/parallaction/exec_ns.cpp	2008-06-20 20:20:46 UTC (rev 32742)
@@ -519,6 +519,8 @@
 
 	case kZoneSpeak:
 		runDialogue(z->u.speak);
+		if (_engineFlags & kEngineQuit)
+			return 0;
 		break;
 
 	}

Modified: scummvm/trunk/engines/parallaction/graphics.h
===================================================================
--- scummvm/trunk/engines/parallaction/graphics.h	2008-06-20 20:07:20 UTC (rev 32741)
+++ scummvm/trunk/engines/parallaction/graphics.h	2008-06-20 20:20:46 UTC (rev 32742)
@@ -95,6 +95,7 @@
 	}
 
 	~SurfaceToFrames() {
+		_surf->free();
 		delete _surf;
 	}
 

Modified: scummvm/trunk/engines/parallaction/input.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/input.cpp	2008-06-20 20:07:20 UTC (rev 32741)
+++ scummvm/trunk/engines/parallaction/input.cpp	2008-06-20 20:20:46 UTC (rev 32742)
@@ -80,11 +80,8 @@
 			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;

Modified: scummvm/trunk/engines/parallaction/parallaction.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/parallaction.cpp	2008-06-20 20:07:20 UTC (rev 32741)
+++ scummvm/trunk/engines/parallaction/parallaction.cpp	2008-06-20 20:20:46 UTC (rev 32742)
@@ -84,21 +84,23 @@
 
 
 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,11 +138,13 @@
 }
 
 
+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() {
 
 	if ((_engineFlags & kEnginePauseJobs) && (_engineFlags & kEngineInventory) == 0) {
@@ -354,12 +358,20 @@
 		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 @@
 	delete _talk;
 	delete _head;
 	delete _objs;
+	delete _ani->gfxobj;
 
-	_ani->gfxobj = NULL;
 	_talk = NULL;
 	_head = NULL;
 	_objs = NULL;
+	_ani->gfxobj = NULL;
 
 	return;
 }

Modified: scummvm/trunk/engines/parallaction/parallaction.h
===================================================================
--- scummvm/trunk/engines/parallaction/parallaction.h	2008-06-20 20:07:20 UTC (rev 32741)
+++ scummvm/trunk/engines/parallaction/parallaction.h	2008-06-20 20:20:46 UTC (rev 32742)
@@ -385,6 +385,9 @@
 
 	int16		pickupItem(ZonePtr z);
 
+	void 		clearSet(OpcodeSet &opcodes);
+
+
 public:
 	virtual	void callFunction(uint index, void* parm) { }
 
@@ -401,6 +404,7 @@
 
 	void		beep();
 
+
 public:
 //	const char **_zoneFlagNamesRes;
 //	const char **_zoneTypeNamesRes;

Modified: scummvm/trunk/engines/parallaction/parallaction_br.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/parallaction_br.cpp	2008-06-20 20:07:20 UTC (rev 32741)
+++ scummvm/trunk/engines/parallaction/parallaction_br.cpp	2008-06-20 20:20:46 UTC (rev 32742)
@@ -109,6 +109,9 @@
 
 		guiStart();
 
+		if (_engineFlags & kEngineQuit)
+			return 0;
+
 //		initCharacter();
 
 		_input->_inputMode = Input::kInputModeGame;

Modified: scummvm/trunk/engines/parallaction/parallaction_ns.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/parallaction_ns.cpp	2008-06-20 20:07:20 UTC (rev 32741)
+++ scummvm/trunk/engines/parallaction/parallaction_ns.cpp	2008-06-20 20:20:46 UTC (rev 32742)
@@ -156,7 +156,9 @@
 
 Parallaction_ns::~Parallaction_ns() {
 	freeFonts();
-
+	
+	delete _locationParser;
+	delete _programParser;
 	delete _mouseComposedArrow;
 
 	_location._animations.remove(_char._ani);
@@ -233,9 +235,15 @@
 	_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();

Modified: scummvm/trunk/engines/parallaction/parser.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/parser.cpp	2008-06-20 20:07:20 UTC (rev 32741)
+++ scummvm/trunk/engines/parallaction/parser.cpp	2008-06-20 20:20:46 UTC (rev 32742)
@@ -30,8 +30,7 @@
 
 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)

Modified: scummvm/trunk/engines/parallaction/parser.h
===================================================================
--- scummvm/trunk/engines/parallaction/parser.h	2008-06-20 20:07:20 UTC (rev 32741)
+++ scummvm/trunk/engines/parallaction/parser.h	2008-06-20 20:20:46 UTC (rev 32742)
@@ -221,13 +221,14 @@
 	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 @@
 	virtual void init();
 
 	virtual ~ProgramParser_ns() {
+		delete _parser;
 		delete _instructionNames;
+
 		clearSet(_instructionParsers);
 	}
 

Modified: scummvm/trunk/engines/parallaction/parser_ns.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/parser_ns.cpp	2008-06-20 20:07:20 UTC (rev 32741)
+++ scummvm/trunk/engines/parallaction/parser_ns.cpp	2008-06-20 20:20:46 UTC (rev 32742)
@@ -1397,7 +1397,7 @@
 	list.push_front(z);
 
 	_parser->pushTables(&_locationZoneParsers, _locationZoneStmt);
-
+	
 	return;
 }
 

Modified: scummvm/trunk/engines/queen/input.cpp
===================================================================
--- scummvm/trunk/engines/queen/input.cpp	2008-06-20 20:07:20 UTC (rev 32741)
+++ scummvm/trunk/engines/queen/input.cpp	2008-06-20 20:20:46 UTC (rev 32742)
@@ -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 @@
 	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 @@
 				break;
 
 			case Common::EVENT_QUIT:
-				_system->quit();
-				break;
+				_vm->quitGame();
+				return;
 
 			default:
 				break;

Modified: scummvm/trunk/engines/queen/input.h
===================================================================
--- scummvm/trunk/engines/queen/input.h	2008-06-20 20:07:20 UTC (rev 32741)
+++ scummvm/trunk/engines/queen/input.h	2008-06-20 20:20:46 UTC (rev 32742)
@@ -49,7 +49,7 @@
 		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 @@
 
 	Common::EventManager *_eventMan;
 
+	QueenEngine *_vm;
+
 	//! some cutaways require update() run faster
 	bool _fastMode;
 

Modified: scummvm/trunk/engines/queen/journal.cpp
===================================================================
--- scummvm/trunk/engines/queen/journal.cpp	2008-06-20 20:07:20 UTC (rev 32741)
+++ scummvm/trunk/engines/queen/journal.cpp	2008-06-20 20:20:46 UTC (rev 32742)
@@ -85,8 +85,8 @@
 				handleMouseWheel(1);
 				break;
 			case Common::EVENT_QUIT:
-				_system->quit();
-				break;
+				_vm->quitGame();
+				return;
 			default:
 				break;
 			}

Modified: scummvm/trunk/engines/queen/queen.cpp
===================================================================
--- scummvm/trunk/engines/queen/queen.cpp	2008-06-20 20:07:20 UTC (rev 32741)
+++ scummvm/trunk/engines/queen/queen.cpp	2008-06-20 20:20:46 UTC (rev 32742)
@@ -418,7 +418,7 @@
 	_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);

Modified: scummvm/trunk/engines/saga/animation.cpp
===================================================================
--- scummvm/trunk/engines/saga/animation.cpp	2008-06-20 20:07:20 UTC (rev 32741)
+++ scummvm/trunk/engines/saga/animation.cpp	2008-06-20 20:20:46 UTC (rev 32742)
@@ -55,6 +55,7 @@
 
 Anim::~Anim(void) {
 	reset();
+	freeCutawayList();
 }
 
 void Anim::loadCutawayList(const byte *resourcePointer, size_t resourceLength) {

Modified: scummvm/trunk/engines/saga/font.cpp
===================================================================
--- scummvm/trunk/engines/saga/font.cpp	2008-06-20 20:07:20 UTC (rev 32741)
+++ scummvm/trunk/engines/saga/font.cpp	2008-06-20 20:20:46 UTC (rev 32742)
@@ -63,6 +63,8 @@
 
 		free(_fonts[i]);
 	}
+
+	free(_fonts);
 }
 
 

Modified: scummvm/trunk/engines/saga/interface.cpp
===================================================================
--- scummvm/trunk/engines/saga/interface.cpp	2008-06-20 20:07:20 UTC (rev 32741)
+++ scummvm/trunk/engines/saga/interface.cpp	2008-06-20 20:20:46 UTC (rev 32742)
@@ -334,7 +334,21 @@
 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();
 }

Modified: scummvm/trunk/engines/saga/introproc_ihnm.cpp
===================================================================
--- scummvm/trunk/engines/saga/introproc_ihnm.cpp	2008-06-20 20:07:20 UTC (rev 32741)
+++ scummvm/trunk/engines/saga/introproc_ihnm.cpp	2008-06-20 20:20:46 UTC (rev 32742)
@@ -132,6 +132,8 @@
 
 	// Load the cutaways for the title screens
 	_vm->_anim->loadCutawayList(resourcePointer, resourceLength);
+
+	free(resourcePointer);
 }
 
 bool Scene::checkKey() {

Modified: scummvm/trunk/engines/saga/rscfile.cpp
===================================================================
--- scummvm/trunk/engines/saga/rscfile.cpp	2008-06-20 20:07:20 UTC (rev 32741)
+++ scummvm/trunk/engines/saga/rscfile.cpp	2008-06-20 20:20:46 UTC (rev 32742)
@@ -769,6 +769,7 @@
 	_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 @@
 		// 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;

Modified: scummvm/trunk/engines/saga/saga.cpp
===================================================================
--- scummvm/trunk/engines/saga/saga.cpp	2008-06-20 20:07:20 UTC (rev 32741)
+++ scummvm/trunk/engines/saga/saga.cpp	2008-06-20 20:20:46 UTC (rev 32742)
@@ -79,6 +79,7 @@
 	_scene = NULL;
 	_isoMap = NULL;
 	_gfx = NULL;
+	_driver = NULL;
 	_console = NULL;
 	_render = NULL;
 	_music = NULL;
@@ -133,6 +134,7 @@
 	delete _render;
 	delete _music;
 	delete _sound;
+	delete _driver;
 	delete _gfx;
 	delete _console;
 
@@ -188,11 +190,11 @@
 	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);
 

Modified: scummvm/trunk/engines/saga/saga.h
===================================================================
--- scummvm/trunk/engines/saga/saga.h	2008-06-20 20:07:20 UTC (rev 32741)
+++ scummvm/trunk/engines/saga/saga.h	2008-06-20 20:20:46 UTC (rev 32742)
@@ -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 @@
 	SndRes *_sndRes;
 	Sound *_sound;
 	Music *_music;
+	MidiDriver *_driver;
 	Anim *_anim;
 	Render *_render;
 	IsoMap *_isoMap;

Modified: scummvm/trunk/engines/saga/script.cpp
===================================================================
--- scummvm/trunk/engines/saga/script.cpp	2008-06-20 20:07:20 UTC (rev 32741)
+++ scummvm/trunk/engines/saga/script.cpp	2008-06-20 20:20:46 UTC (rev 32742)
@@ -150,6 +150,7 @@
 	debug(8, "Shutting down scripting subsystem.");
 
 	_mainStrings.freeMem();
+	_globalVoiceLUT.freeMem();
 
 	freeModules();
 	free(_modules);

Modified: scummvm/trunk/engines/saga/sprite.cpp
===================================================================
--- scummvm/trunk/engines/saga/sprite.cpp	2008-06-20 20:07:20 UTC (rev 32741)
+++ scummvm/trunk/engines/saga/sprite.cpp	2008-06-20 20:20:46 UTC (rev 32742)
@@ -74,6 +74,9 @@
 Sprite::~Sprite(void) {
 	debug(8, "Shutting down sprite subsystem...");
 	_mainSprites.freeMem();
+	_inventorySprites.freeMem();
+	_arrowSprites.freeMem();
+	_saveReminderSprites.freeMem();
 	free(_decodeBuf);
 }
 

Modified: scummvm/trunk/engines/scumm/sound.cpp
===================================================================
--- scummvm/trunk/engines/scumm/sound.cpp	2008-06-20 20:07:20 UTC (rev 32741)
+++ scummvm/trunk/engines/scumm/sound.cpp	2008-06-20 20:20:46 UTC (rev 32742)
@@ -89,6 +89,7 @@
 
 Sound::~Sound() {
 	stopCDTimer();
+	AudioCD.destroy();
 	delete _sfxFile;
 }
 

Modified: scummvm/trunk/engines/sky/music/adlibmusic.cpp
===================================================================
--- scummvm/trunk/engines/sky/music/adlibmusic.cpp	2008-06-20 20:07:20 UTC (rev 32741)
+++ scummvm/trunk/engines/sky/music/adlibmusic.cpp	2008-06-20 20:20:46 UTC (rev 32742)
@@ -47,6 +47,7 @@
 
 AdlibMusic::~AdlibMusic(void) {
 
+	OPLDestroy(_opl);
 	_mixer->stopHandle(_soundHandle);
 }
 

Modified: scummvm/trunk/engines/touche/midi.cpp
===================================================================
--- scummvm/trunk/engines/touche/midi.cpp	2008-06-20 20:07:20 UTC (rev 32741)
+++ scummvm/trunk/engines/touche/midi.cpp	2008-06-20 20:20:46 UTC (rev 32742)
@@ -107,6 +107,7 @@
 	_mutex.lock();
 	_driver->setTimerCallback(NULL, NULL);
 	_driver->close();
+	delete _driver;
 	_driver = 0;
 	_parser->setMidiDriver(NULL);
 	delete _parser;

Modified: scummvm/trunk/engines/touche/touche.cpp
===================================================================
--- scummvm/trunk/engines/touche/touche.cpp	2008-06-20 20:07:20 UTC (rev 32741)
+++ scummvm/trunk/engines/touche/touche.cpp	2008-06-20 20:20:46 UTC (rev 32742)
@@ -96,6 +96,7 @@
 	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);

Modified: scummvm/trunk/graphics/cursorman.cpp
===================================================================
--- scummvm/trunk/graphics/cursorman.cpp	2008-06-20 20:07:20 UTC (rev 32741)
+++ scummvm/trunk/graphics/cursorman.cpp	2008-06-20 20:20:46 UTC (rev 32742)
@@ -83,6 +83,24 @@
 	g_system->showMouse(isVisible());
 }
 
+
+void CursorManager::popAllCursors() {
+	while (!_cursorStack.empty()) {
+		Cursor *cur = _cursorStack.pop();
+		delete cur;
+	}
+
+	if (g_system->hasFeature(OSystem::kFeatureCursorHasPalette)) {
+		while (!_cursorPaletteStack.empty()) {
+			Palette *pal = _cursorPaletteStack.pop();
+			delete pal;
+		}
+	}
+
+	g_system->showMouse(isVisible());
+}
+
+
 void CursorManager::replaceCursor(const byte *buf, uint w, uint h, int hotspotX, int hotspotY, byte keycolor, int targetScale) {
 	if (_cursorStack.empty()) {
 		pushCursor(buf, w, h, hotspotX, hotspotY, keycolor, targetScale);

Modified: scummvm/trunk/graphics/cursorman.h
===================================================================
--- scummvm/trunk/graphics/cursorman.h	2008-06-20 20:07:20 UTC (rev 32741)
+++ scummvm/trunk/graphics/cursorman.h	2008-06-20 20:20:46 UTC (rev 32742)
@@ -80,6 +80,14 @@
 	void replaceCursor(const byte *buf, uint w, uint h, int hotspotX, int hotspotY, byte keycolor = 255, int targetScale = 1);
 
 	/**
+	 * Pop all of the cursors and cursor palettes from their respective stacks.
+	 * The purpose is to ensure that all unecessary cursors are removed from the 
+	 * stack when returning to the launcher from an engine.
+	 *
+	 */
+	void popAllCursors();
+
+	/**
 	 * Enable/Disable the current cursor palette.
 	 *
 	 * @param disable

Modified: scummvm/trunk/graphics/iff.cpp
===================================================================
--- scummvm/trunk/graphics/iff.cpp	2008-06-20 20:07:20 UTC (rev 32741)
+++ scummvm/trunk/graphics/iff.cpp	2008-06-20 20:20:46 UTC (rev 32742)
@@ -139,6 +139,7 @@
 
 			out += _bitmapHeader.width;
 		}
+		free(scan);
 		break;
 	}
 

Modified: scummvm/trunk/gui/launcher.cpp
===================================================================
--- scummvm/trunk/gui/launcher.cpp	2008-06-20 20:07:20 UTC (rev 32741)
+++ scummvm/trunk/gui/launcher.cpp	2008-06-20 20:20:46 UTC (rev 32742)
@@ -44,6 +44,7 @@
 #include "gui/ListWidget.h"
 #include "gui/TabWidget.h"
 #include "gui/PopUpWidget.h"
+#include "graphics/cursorman.h"
 
 #include "sound/mididrv.h"
 
@@ -549,6 +550,8 @@
 	// failure to launch a game. Otherwise, pressing ESC will attempt to
 	// re-launch the same game again.
 	ConfMan.setActiveDomain("");
+
+	CursorMan.popAllCursors();
 	Dialog::open();
 
 	updateButtons();

Modified: scummvm/trunk/gui/newgui.cpp
===================================================================
--- scummvm/trunk/gui/newgui.cpp	2008-06-20 20:07:20 UTC (rev 32741)
+++ scummvm/trunk/gui/newgui.cpp	2008-06-20 20:20:46 UTC (rev 32742)
@@ -364,7 +364,7 @@
 void NewGui::openDialog(Dialog *dialog) {
 	_dialogStack.push(dialog);
 	_needRedraw = true;
-
+	
 	// We reflow the dialog just before opening it. If the screen changed
 	// since the last time we looked, also refresh the loaded theme,
 	// and reflow all other open dialogs, too.


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list