[Scummvm-cvs-logs] SF.net SVN: scummvm:[45389] scummvm/trunk/engines/draci

spalek at users.sourceforge.net spalek at users.sourceforge.net
Mon Oct 26 05:59:53 CET 2009


Revision: 45389
          http://scummvm.svn.sourceforge.net/scummvm/?rev=45389&view=rev
Author:   spalek
Date:     2009-10-26 04:59:52 +0000 (Mon, 26 Oct 2009)

Log Message:
-----------
Fix Escape in the intro, and switching map and the inventory

Modified Paths:
--------------
    scummvm/trunk/engines/draci/draci.cpp
    scummvm/trunk/engines/draci/game.cpp
    scummvm/trunk/engines/draci/script.cpp
    scummvm/trunk/engines/draci/script.h

Modified: scummvm/trunk/engines/draci/draci.cpp
===================================================================
--- scummvm/trunk/engines/draci/draci.cpp	2009-10-26 02:46:51 UTC (rev 45388)
+++ scummvm/trunk/engines/draci/draci.cpp	2009-10-26 04:59:52 UTC (rev 45389)
@@ -231,6 +231,12 @@
 				_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 @@
 					_game->setExitLoop(true);
 
 					// End any currently running GPL programs
-					_script->endCurrentProgram();
+					_script->endCurrentProgram(true);
 				}
 				break;
 			}
@@ -259,6 +265,9 @@
 				_showWalkingMap = !_showWalkingMap;
 				break;
 			case Common::KEYCODE_i:
+				if (_game->getRoomNum() == _game->getMapRoom()) {
+					break;
+				}
 				if (_game->getLoopStatus() == kStatusInventory &&
 				   _game->getLoopSubstatus() == kSubstatusOrdinary) {
 					_game->inventoryDone();

Modified: scummvm/trunk/engines/draci/game.cpp
===================================================================
--- scummvm/trunk/engines/draci/game.cpp	2009-10-26 02:46:51 UTC (rev 45388)
+++ scummvm/trunk/engines/draci/game.cpp	2009-10-26 04:59:52 UTC (rev 45389)
@@ -144,13 +144,19 @@
 	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();
 	}
 }

Modified: scummvm/trunk/engines/draci/script.cpp
===================================================================
--- scummvm/trunk/engines/draci/script.cpp	2009-10-26 02:46:51 UTC (rev 45388)
+++ scummvm/trunk/engines/draci/script.cpp	2009-10-26 04:59:52 UTC (rev 45389)
@@ -850,10 +850,6 @@
 	}
 }
 
-void Script::endCurrentProgram() {
-	_endProgram = true;
-}
-
 void Script::quitGame(Common::Queue<int> &params) {
 	_vm->_game->setQuit(true);
 }
@@ -1057,7 +1053,14 @@
  *  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 @@
 		// 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 @@
 			(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

Modified: scummvm/trunk/engines/draci/script.h
===================================================================
--- scummvm/trunk/engines/draci/script.h	2009-10-26 02:46:51 UTC (rev 45388)
+++ scummvm/trunk/engines/draci/script.h	2009-10-26 04:59:52 UTC (rev 45389)
@@ -89,11 +89,12 @@
 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;


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list