From 60b59de181befcebc3515d54d8c18a7b05383bb7 Mon Sep 17 00:00:00 2001 From: Torbjörn Andersson Date: Tue, 6 Jan 2004 16:49:04 +0000 Subject: 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. svn-id: r12184 --- sword2/sword2.cpp | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/sword2/sword2.cpp b/sword2/sword2.cpp index 54734bc73a..a11d20dff9 100644 --- a/sword2/sword2.cpp +++ b/sword2/sword2.cpp @@ -253,9 +253,7 @@ int32 Sword2Engine::initialiseGame(void) { } void Sword2Engine::closeGame(void) { - // Stop music instantly! - killMusic(); - _system->quit(); + _quit = true; } void Sword2Engine::gameCycle(void) { @@ -299,10 +297,8 @@ void Sword2Engine::go() { _gui->readOptionSettings(); debug(5, "CALLING: initialiseGame"); - if (initialiseGame()) { - closeGame(); + if (initialiseGame()) return; - } if (_saveSlot != -1) { if (saveExists(_saveSlot)) @@ -322,6 +318,7 @@ void Sword2Engine::go() { // 1 in 4 frames, to speed up game _gameCycle = 0; + _quit = false; while (1) { if (_debugger->isAttached()) @@ -387,6 +384,13 @@ void Sword2Engine::go() { 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 @@ void Sword2Engine::go() { #endif } - closeGame(); // close engine systems down + // Stop music instantly! + killMusic(); } void Sword2Engine::startGame(void) { -- cgit v1.2.3