[Scummvm-cvs-logs] CVS: scummvm/sword2 sword2.cpp,1.100,1.101

Torbj?rn Andersson eriktorbjorn at users.sourceforge.net
Tue Jan 6 08:50:11 CET 2004


Update of /cvsroot/scummvm/scummvm/sword2
In directory sc8-pr-cvs1:/tmp/cvs-serv7969

Modified Files:
	sword2.cpp 
Log Message:
Never call _system->quit() directly. Let ScummVM handle that so that the
engine can be properly deleted first. Apart from being the nice thing to
do, this should make it easier to Valgrind for memory leaks.


Index: sword2.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sword2/sword2.cpp,v
retrieving revision 1.100
retrieving revision 1.101
diff -u -d -r1.100 -r1.101
--- sword2.cpp	6 Jan 2004 13:44:17 -0000	1.100
+++ sword2.cpp	6 Jan 2004 16:49:04 -0000	1.101
@@ -253,9 +253,7 @@
 }
 
 void Sword2Engine::closeGame(void) {
-	// Stop music instantly!
-	killMusic();
-	_system->quit();
+	_quit = true;
 }
 
 void Sword2Engine::gameCycle(void) {
@@ -299,10 +297,8 @@
 	_gui->readOptionSettings();
 
 	debug(5, "CALLING: initialiseGame");
-	if (initialiseGame()) {
-		closeGame();
+	if (initialiseGame())
 		return;
-	}
 
 	if (_saveSlot != -1) {
 		if (saveExists(_saveSlot))
@@ -322,6 +318,7 @@
 					// 1 in 4 frames, to speed up game
 
 	_gameCycle = 0;
+	_quit = false;
 
 	while (1) {
 		if (_debugger->isAttached())
@@ -387,6 +384,13 @@
 			gameCycle();
 		}
 
+		// We can't use this as termination condition for the looop,
+		// because we want the break to happen before updating the
+		// screen again.
+
+		if (_quit)
+			break;
+
 		// creates the debug text blocks
 		_debugger->buildDebugText();
 
@@ -402,7 +406,8 @@
 #endif
 	}
 
-	closeGame();		// close engine systems down
+	// Stop music instantly!
+	killMusic();
 }
 
 void Sword2Engine::startGame(void) {





More information about the Scummvm-git-logs mailing list