diff options
author | Strangerke | 2014-12-10 23:25:18 +0100 |
---|---|---|
committer | Paul Gilbert | 2014-12-12 23:06:08 -0500 |
commit | 8517209bcbef56a1fa68a6e17b04d56c13fa77b2 (patch) | |
tree | 323c5911970f1c3df7b7fb937ed135c3498724a7 | |
parent | 538782e14e085fa4cc8e435439f0432b3b1f0b21 (diff) | |
download | scummvm-rg350-8517209bcbef56a1fa68a6e17b04d56c13fa77b2.tar.gz scummvm-rg350-8517209bcbef56a1fa68a6e17b04d56c13fa77b2.tar.bz2 scummvm-rg350-8517209bcbef56a1fa68a6e17b04d56c13fa77b2.zip |
ACCESS: Implement restart after death
-rw-r--r-- | engines/access/access.cpp | 4 | ||||
-rw-r--r-- | engines/access/access.h | 2 | ||||
-rw-r--r-- | engines/access/amazon/amazon_game.cpp | 67 | ||||
-rw-r--r-- | engines/access/room.cpp | 8 | ||||
-rw-r--r-- | engines/access/scripts.cpp | 2 |
5 files changed, 53 insertions, 30 deletions
diff --git a/engines/access/access.cpp b/engines/access/access.cpp index b63bb29e0a..4201564e84 100644 --- a/engines/access/access.cpp +++ b/engines/access/access.cpp @@ -89,6 +89,7 @@ AccessEngine::AccessEngine(OSystem *syst, const AccessGameDescription *gameDesc) _loadSaveSlot = -1; _vidX = _vidY = 0; _cheatFl = false; + _restartFl = false; } AccessEngine::~AccessEngine() { @@ -570,4 +571,7 @@ void AccessEngine::writeSavegameHeader(Common::OutSaveFile *out, AccessSavegameH out->writeUint32LE(_events->getFrameCounter()); } +bool AccessEngine::shouldQuitOrRestart() { + return shouldQuit() || _restartFl; +} } // End of namespace Access diff --git a/engines/access/access.h b/engines/access/access.h index 284ac2690c..5470d2a208 100644 --- a/engines/access/access.h +++ b/engines/access/access.h @@ -209,6 +209,7 @@ public: bool _clearSummaryFlag; bool _cheatFl; + bool _restartFl; // Fields mapped into the flags array int &_useItem; int &_startup; @@ -228,6 +229,7 @@ public: uint16 getVersion() const; uint32 getGameID() const; uint32 getGameFeatures() const; + bool shouldQuitOrRestart(); int getRandomNumber(int maxNumber); diff --git a/engines/access/amazon/amazon_game.cpp b/engines/access/amazon/amazon_game.cpp index cfcafbba6f..29466f1dee 100644 --- a/engines/access/amazon/amazon_game.cpp +++ b/engines/access/amazon/amazon_game.cpp @@ -121,40 +121,36 @@ void AmazonEngine::playGame() { return; } - _screen->clearScreen(); - _screen->setPanel(0); - _screen->forceFadeOut(); - _events->showCursor(); - - initVariables(); - - // If there's a pending savegame to load, load it - if (_loadSaveSlot != -1) - loadGameState(_loadSaveSlot); + do { + _restartFl = false; + _screen->clearScreen(); + _screen->setPanel(0); + _screen->forceFadeOut(); + _events->showCursor(); + + initVariables(); + + // If there's a pending savegame to load, load it + if (_loadSaveSlot != -1) { + loadGameState(_loadSaveSlot); + _loadSaveSlot = -1; + } - // Execute the room - _room->doRoom(); + // Execute the room + _room->doRoom(); + } while (_restartFl); } void AmazonEngine::setupGame() { - // Setup timers - const int TIMER_DEFAULTS[] = { 3, 10, 8, 1, 1, 1, 1, 2 }; - for (int i = 0; i < 32; ++i) { - TimerEntry te; - te._initTm = te._timer = (i < 8) ? TIMER_DEFAULTS[i] : 1; - te._flag = 1; - - _timers.push_back(te); - } - // Load death list - _deaths.resize(58); if (isDemo()) { + _deaths.resize(34); for (int i = 0; i < 34; ++i) { _deaths[i]._screenId = DEATH_SCREENS_DEMO[i]; _deaths[i]._msg = DEATH_TEXT_DEMO[i]; } } else { + _deaths.resize(58); for (int i = 0; i < 58; ++i) { _deaths[i]._screenId = DEATH_SCREENS[i]; _deaths[i]._msg = DEATH_TEXT[i]; @@ -178,8 +174,29 @@ void AmazonEngine::initVariables() { _player->_roomNumber = 33; else _player->_roomNumber = 4; + + _converseMode = 0; + _inventory->_startInvItem = 0; + _inventory->_startInvBox = 0; + Common::fill(&_objectsTable[0], &_objectsTable[100], (SpriteResource *)nullptr); + _player->_playerOff = false; + + // Setup timers + const int TIMER_DEFAULTS[] = { 3, 10, 8, 1, 1, 1, 1, 2 }; + for (int i = 0; i < 32; ++i) { + TimerEntry te; + te._initTm = te._timer = (i < 8) ? TIMER_DEFAULTS[i] : 1; + te._flag = 1; + + _timers.push_back(te); + } + _player->_playerX = _player->_rawPlayer.x = TRAVEL_POS[_player->_roomNumber][0]; _player->_playerY = _player->_rawPlayer.y = TRAVEL_POS[_player->_roomNumber][1]; + _room->_selectCommand = -1; + _events->_normalMouse = CURSOR_CROSSHAIRS; + _mouseMode = 0; + _numAnimTimers = 0; } void AmazonEngine::establish(int screenId, int esatabIndex) { @@ -739,8 +756,8 @@ void AmazonEngine::dead(int deathId) { _player->removeSprite1(); } - warning("TODO: restart game"); - quitGame(); + // The original was jumping to the restart label in main + _restartFl = true; _events->pollEvents(); } } diff --git a/engines/access/room.cpp b/engines/access/room.cpp index a781dab24a..57332f742d 100644 --- a/engines/access/room.cpp +++ b/engines/access/room.cpp @@ -90,7 +90,7 @@ void Room::doRoom() { _vm->_player->checkScroll(); doCommands(); - if (_vm->shouldQuit()) + if (_vm->shouldQuitOrRestart()) return; // DOROOMFLASHBACK jump point @@ -128,7 +128,7 @@ void Room::doRoom() { _function = FN_NONE; roomLoop(); - if (_vm->shouldQuit()) + if (_vm->shouldQuitOrRestart()) return; if (_function == FN_CLEAR1) { @@ -578,7 +578,7 @@ void Room::walkCursor() { _selectCommand = -1; _conFlag = true; - while (_conFlag && !_vm->shouldQuit()) { + while (_conFlag && !_vm->shouldQuitOrRestart()) { _conFlag = false; _vm->_scripts->executeScript(); } @@ -622,7 +622,7 @@ void Room::checkBoxes3() { _vm->_boxSelect = start; _conFlag = true; - while (_conFlag && !_vm->shouldQuit()) { + while (_conFlag && !_vm->shouldQuitOrRestart()) { _conFlag = false; _vm->_scripts->executeScript(); } diff --git a/engines/access/scripts.cpp b/engines/access/scripts.cpp index 728421c6d9..6c9f278736 100644 --- a/engines/access/scripts.cpp +++ b/engines/access/scripts.cpp @@ -100,7 +100,7 @@ int Scripts::executeScript() { assert(_scriptCommand >= 0x80); executeCommand(_scriptCommand - 0x80); - } while (!_endFlag && !_vm->shouldQuit()); + } while (!_endFlag && !_vm->shouldQuitOrRestart()); return _returnCode; } |