aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorRobert Špalek2009-10-26 04:59:52 +0000
committerRobert Špalek2009-10-26 04:59:52 +0000
commit74da9e5e3bd842b6b5f44a01aff6fd26dee510ec (patch)
treeb1365db3c9e979b013def7da484df11be26c7a1f /engines
parent6b61700a7bf9ac66acc01b69f19703196b497320 (diff)
downloadscummvm-rg350-74da9e5e3bd842b6b5f44a01aff6fd26dee510ec.tar.gz
scummvm-rg350-74da9e5e3bd842b6b5f44a01aff6fd26dee510ec.tar.bz2
scummvm-rg350-74da9e5e3bd842b6b5f44a01aff6fd26dee510ec.zip
Fix Escape in the intro, and switching map and the inventory
svn-id: r45389
Diffstat (limited to 'engines')
-rw-r--r--engines/draci/draci.cpp11
-rw-r--r--engines/draci/game.cpp10
-rw-r--r--engines/draci/script.cpp22
-rw-r--r--engines/draci/script.h7
4 files changed, 31 insertions, 19 deletions
diff --git a/engines/draci/draci.cpp b/engines/draci/draci.cpp
index 4b93e02ab6..e32a239f94 100644
--- a/engines/draci/draci.cpp
+++ b/engines/draci/draci.cpp
@@ -231,6 +231,12 @@ void DraciEngine::handleEvents() {
_game->scheduleEnteringRoomUsingGate(_game->prevRoomNum(), 0);
break;
case Common::KEYCODE_ESCAPE: {
+ if (_game->getLoopStatus() == kStatusInventory &&
+ _game->getLoopSubstatus() == kSubstatusOrdinary) {
+ _game->inventoryDone();
+ break;
+ }
+
const int escRoom = _game->getRoomNum() != _game->getMapRoom()
? _game->getEscRoom() : _game->getPreviousRoomNum();
@@ -243,7 +249,7 @@ void DraciEngine::handleEvents() {
_game->setExitLoop(true);
// End any currently running GPL programs
- _script->endCurrentProgram();
+ _script->endCurrentProgram(true);
}
break;
}
@@ -259,6 +265,9 @@ void DraciEngine::handleEvents() {
_showWalkingMap = !_showWalkingMap;
break;
case Common::KEYCODE_i:
+ if (_game->getRoomNum() == _game->getMapRoom()) {
+ break;
+ }
if (_game->getLoopStatus() == kStatusInventory &&
_game->getLoopSubstatus() == kSubstatusOrdinary) {
_game->inventoryDone();
diff --git a/engines/draci/game.cpp b/engines/draci/game.cpp
index da94c261d3..f771c564f0 100644
--- a/engines/draci/game.cpp
+++ b/engines/draci/game.cpp
@@ -144,13 +144,19 @@ void Game::start() {
while (!shouldQuit()) {
debugC(1, kDraciGeneralDebugLevel, "Game::start()");
- const bool force_reload = shouldExitLoop() > 1;
-
// Whenever the top-level loop is entered, it should not finish unless
// the exit is triggered by a script
_shouldExitLoop = false;
+ _vm->_script->endCurrentProgram(false);
+ const bool force_reload = shouldExitLoop() > 1;
enterNewRoom(force_reload);
+
+ if (_vm->_script->shouldEndProgram()) {
+ // Room changed during the initialization (intro or Escape pressed).
+ continue;
+ }
+
loop();
}
}
diff --git a/engines/draci/script.cpp b/engines/draci/script.cpp
index 1809695d5b..e5dc28e705 100644
--- a/engines/draci/script.cpp
+++ b/engines/draci/script.cpp
@@ -850,10 +850,6 @@ void Script::setPalette(Common::Queue<int> &params) {
}
}
-void Script::endCurrentProgram() {
- _endProgram = true;
-}
-
void Script::quitGame(Common::Queue<int> &params) {
_vm->_game->setQuit(true);
}
@@ -1057,7 +1053,14 @@ const GPL2Command *Script::findCommand(byte num, byte subnum) const {
* value comes from.
*/
-int Script::run(const GPL2Program &program, uint16 offset) {
+void Script::run(const GPL2Program &program, uint16 offset) {
+ if (shouldEndProgram()) {
+ // This might get set by some GPL commands via Script::endCurrentProgram()
+ // if they need a program to stop midway. This flag is sticky until cleared
+ // at the top level.
+ return;
+ }
+
int oldJump = _jump;
// Mark the last animation index before we do anything so a Release command
@@ -1108,10 +1111,6 @@ int Script::run(const GPL2Program &program, uint16 offset) {
// extract low byte, i.e. the command subnumber
byte subnum = cmdpair & 0xFF;
- // This might get set by some GPL commands via Script::endCurrentProgram()
- // if they need a program to stop midway
- _endProgram = false;
-
if ((cmd = findCommand(num, subnum))) {
int tmp;
@@ -1142,12 +1141,9 @@ int Script::run(const GPL2Program &program, uint16 offset) {
(this->*(cmd->_handler))(params);
}
- } while (cmd->_number != 0 && !_endProgram); // 0 = gplend and exit
+ } while (cmd->_number != 0 && !shouldEndProgram()); // 0 = gplend and exit
- _endProgram = false;
_jump = oldJump;
-
- return 0;
}
} // End of namespace Draci
diff --git a/engines/draci/script.h b/engines/draci/script.h
index 3476dd1116..1073f2c290 100644
--- a/engines/draci/script.h
+++ b/engines/draci/script.h
@@ -89,11 +89,12 @@ struct GameObject;
class Script {
public:
- Script(DraciEngine *vm) : _vm(vm), _jump(0) { setupCommandList(); };
+ Script(DraciEngine *vm) : _vm(vm), _jump(0), _endProgram(false) { setupCommandList(); };
- int run(const GPL2Program &program, uint16 offset);
+ void run(const GPL2Program &program, uint16 offset);
bool testExpression(const GPL2Program &program, uint16 offset) const;
- void endCurrentProgram();
+ void endCurrentProgram(bool value) { _endProgram = value; }
+ bool shouldEndProgram() const { return _endProgram; }
private:
int _jump;