aboutsummaryrefslogtreecommitdiff
path: root/sword2
diff options
context:
space:
mode:
authorTorbjörn Andersson2004-01-06 16:49:04 +0000
committerTorbjörn Andersson2004-01-06 16:49:04 +0000
commit60b59de181befcebc3515d54d8c18a7b05383bb7 (patch)
treec53aa53d9f1dcb6bf2e0b1e1a4ffdae6bc4d6219 /sword2
parentcda20b4125725c83670ab6cc68c68b85717954e6 (diff)
downloadscummvm-rg350-60b59de181befcebc3515d54d8c18a7b05383bb7.tar.gz
scummvm-rg350-60b59de181befcebc3515d54d8c18a7b05383bb7.tar.bz2
scummvm-rg350-60b59de181befcebc3515d54d8c18a7b05383bb7.zip
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
Diffstat (limited to 'sword2')
-rw-r--r--sword2/sword2.cpp19
1 files 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) {