From 0015657caad6d4824a3b146fb34c4255aeeff72b Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Thu, 12 Feb 2009 15:13:52 +0000 Subject: Fix for bug #2541237 - "AGI: Restart quits ScummVM" svn-id: r36279 --- engines/agi/agi.cpp | 2 ++ engines/agi/agi.h | 2 +- engines/agi/cycle.cpp | 16 +++++++--------- engines/agi/keyboard.cpp | 4 ++-- engines/agi/op_cmd.cpp | 8 ++++---- engines/agi/op_test.cpp | 2 +- engines/agi/saveload.cpp | 2 +- engines/agi/text.cpp | 2 +- 8 files changed, 19 insertions(+), 19 deletions(-) diff --git a/engines/agi/agi.cpp b/engines/agi/agi.cpp index bf409a2210..24ed710f53 100644 --- a/engines/agi/agi.cpp +++ b/engines/agi/agi.cpp @@ -382,6 +382,8 @@ int AgiEngine::agiInit() { initWords(); + restartGame = false; + if (!_menu) _menu = new Menu(this, _gfx, _picture); diff --git a/engines/agi/agi.h b/engines/agi/agi.h index 4685032ba3..6477f22429 100644 --- a/engines/agi/agi.h +++ b/engines/agi/agi.h @@ -165,7 +165,6 @@ enum AGIErrors { errNotEnoughMemory, errBadResource, errUnknownAGIVersion, - errRestartGame, errNoLoopsInView, errViewDataError, errNoGameList, @@ -799,6 +798,7 @@ public: uint8 *_intobj; int _oldMode; + bool restartGame; Menu* _menu; diff --git a/engines/agi/cycle.cpp b/engines/agi/cycle.cpp index 49d7930972..cf987e66dc 100644 --- a/engines/agi/cycle.cpp +++ b/engines/agi/cycle.cpp @@ -115,7 +115,7 @@ void AgiEngine::interpretCycle() { oldSound = getflag(fSoundOn); _game.exitAllLogics = false; - while (runLogic(0) == 0 && !shouldQuit()) { + while (runLogic(0) == 0 && !(shouldQuit() || restartGame)) { _game.vars[vWordNotFound] = 0; _game.vars[vBorderTouchObj] = 0; _game.vars[vBorderCode] = 0; @@ -361,16 +361,11 @@ int AgiEngine::playGame() { _game.vars[vKey] = 0; } - // FIXME: This has been broken with the merge of the RTL GSoC project. shouldQuit() returns a boolean, and we're trying to - // check it against 0xff, which is never going to be true - //if (shouldQuit() == 0xff) - // ec = errRestartGame; - if (shouldPerformAutoSave(_lastSaveTime)) { saveGame(getSavegameFilename(0), "Autosave"); } - } while (shouldQuit() == 0); + } while (!(shouldQuit() || restartGame)); _sound->stopSound(); @@ -390,8 +385,11 @@ int AgiEngine::runGame() { if (agiInit() != errOK) break; - if (ec == errRestartGame) + + if (restartGame) { setflag(fRestartGame, true); + restartGame = false; + } // Set computer type (v20 i.e. vComputer) switch (getPlatform()) { @@ -444,7 +442,7 @@ int AgiEngine::runGame() { ec = playGame(); _game.state = STATE_LOADED; agiDeinit(); - } while (ec == errRestartGame); + } while (restartGame); delete _menu; _menu = NULL; diff --git a/engines/agi/keyboard.cpp b/engines/agi/keyboard.cpp index 5525cfef99..d98e58d4d9 100644 --- a/engines/agi/keyboard.cpp +++ b/engines/agi/keyboard.cpp @@ -374,7 +374,7 @@ int AgiEngine::waitKey() { } debugC(3, kDebugLevelInput, "waiting..."); - while (!shouldQuit()) { + while (!(shouldQuit() || restartGame)) { _gfx->pollTimer(); /* msdos driver -> does nothing */ key = doPollKeyboard(); if (key == KEY_ENTER || key == KEY_ESCAPE || key == BUTTON_LEFT) @@ -397,7 +397,7 @@ int AgiEngine::waitAnyKey() { } debugC(3, kDebugLevelInput, "waiting..."); - while (!shouldQuit()) { + while (!(shouldQuit() || restartGame)) { _gfx->pollTimer(); /* msdos driver -> does nothing */ key = doPollKeyboard(); if (key) diff --git a/engines/agi/op_cmd.cpp b/engines/agi/op_cmd.cpp index 32a8f62a58..1ac8ec5ce3 100644 --- a/engines/agi/op_cmd.cpp +++ b/engines/agi/op_cmd.cpp @@ -1231,7 +1231,7 @@ cmd(restart_game) { g_agi->selectionBox(" Restart game, or continue? \n\n\n", buttons); if (sel == 0) { - g_agi->quitGame(); + g_agi->restartGame = true; g_agi->setflag(fRestartGame, true); g_agi->_menu->enableAll(); } @@ -1331,7 +1331,7 @@ cmd(get_string) { do { g_agi->mainCycle(); - } while (game.inputMode == INPUT_GETSTRING && !g_agi->shouldQuit()); + } while (game.inputMode == INPUT_GETSTRING && !(g_agi->shouldQuit() || g_agi->restartGame)); } cmd(get_num) { @@ -1349,7 +1349,7 @@ cmd(get_num) { do { g_agi->mainCycle(); - } while (game.inputMode == INPUT_GETSTRING && !g_agi->shouldQuit()); + } while (game.inputMode == INPUT_GETSTRING && !(g_agi->shouldQuit() || g_agi->restartGame)); _v[p1] = atoi(game.strings[MAX_STRINGS]); debugC(4, kDebugLevelScripts, "[%s] -> %d", game.strings[MAX_STRINGS], _v[p1]); @@ -1745,7 +1745,7 @@ int AgiEngine::runLogic(int n) { curLogic->cIP = curLogic->sIP; timerHack = 0; - while (ip < _game.logics[n].size && !shouldQuit()) { + while (ip < _game.logics[n].size && !(shouldQuit() || restartGame)) { if (_debug.enabled) { if (_debug.steps > 0) { if (_debug.logic0 || n) { diff --git a/engines/agi/op_test.cpp b/engines/agi/op_test.cpp index f096c0b2e7..2e9e4ee337 100644 --- a/engines/agi/op_test.cpp +++ b/engines/agi/op_test.cpp @@ -231,7 +231,7 @@ int AgiEngine::testIfCode(int lognum) { uint8 p[16] = { 0 }; bool end_test = false; - while (retval && !shouldQuit() && !end_test) { + while (retval && !(shouldQuit() || restartGame) && !end_test) { if (_debug.enabled && (_debug.logic0 || lognum)) debugConsole(lognum, lTEST_MODE, NULL); diff --git a/engines/agi/saveload.cpp b/engines/agi/saveload.cpp index 20b50263a8..2e30623797 100644 --- a/engines/agi/saveload.cpp +++ b/engines/agi/saveload.cpp @@ -566,7 +566,7 @@ int AgiEngine::selectSlot() { int oldFirstSlot = _firstSlot + 1; int oldActive = active + 1; - while (!shouldQuit()) { + while (!(shouldQuit() || restartGame)) { int sbPos = 0; // Use the extreme scrollbar positions only if the extreme diff --git a/engines/agi/text.cpp b/engines/agi/text.cpp index ebce45ab2e..bf16f926b2 100644 --- a/engines/agi/text.cpp +++ b/engines/agi/text.cpp @@ -376,7 +376,7 @@ int AgiEngine::selectionBox(const char *m, const char **b) { AllowSyntheticEvents on(this); debugC(4, kDebugLevelText, "selectionBox(): waiting..."); - while (!shouldQuit()) { + while (!(shouldQuit() || restartGame)) { for (i = 0; b[i]; i++) _gfx->drawCurrentStyleButton(bx[i], by[i], b[i], i == active, false, i == 0); -- cgit v1.2.3