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

spalek at users.sourceforge.net spalek at users.sourceforge.net
Sun Nov 22 22:12:23 CET 2009


Revision: 46098
          http://scummvm.svn.sourceforge.net/scummvm/?rev=46098&view=rev
Author:   spalek
Date:     2009-11-22 21:12:23 +0000 (Sun, 22 Nov 2009)

Log Message:
-----------
Remove obsolete and unneeded logic bypassing reloading a location.

I have tested that this could only possibly happen when the game has been
loaded with last location being the map.  Then pressing Escape calls
enterNewRoom() and this superfluous optimization takes place.  It is harmless
to simply reload the map.  After having removed it, enterNewRoom() needs not
return any return value, because the test at the tail can be done by the
caller.  I have then restructured the code a little to make it cleaner.

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

Modified: scummvm/trunk/engines/draci/game.cpp
===================================================================
--- scummvm/trunk/engines/draci/game.cpp	2009-11-22 20:44:37 UTC (rev 46097)
+++ scummvm/trunk/engines/draci/game.cpp	2009-11-22 21:12:23 UTC (rev 46098)
@@ -154,10 +154,21 @@
 
 void Game::start() {
 	while (!shouldQuit()) {
-		if (enterNewRoom()) {
-			// Call the outer loop doing all the hard job.
-			loop(kOuterLoop, false);
+		// Reset the flag allowing to run the scripts.
+		_vm->_script->endCurrentProgram(false);
+
+		enterNewRoom();
+
+		if (_vm->_script->shouldEndProgram()) {
+			// Escape pressed during the intro or map animations run in the
+			// init scripts.  This flag was turned on to skip the rest of
+			// those programs.  Don't call loop(), because the
+			// location may have changed.
+			continue;
 		}
+
+		// Call the outer loop doing all the hard job.
+		loop(kOuterLoop, false);
 	}
 
 }
@@ -432,6 +443,7 @@
 	// by the user clicking on something or run at the end of a
 	// gate script in the intro).
 	if ((_loopStatus == kStatusOrdinary || _loopStatus == kStatusGate) && (_newRoom != getRoomNum() || _newGate != _variables[0] - 1)) {
+		// TODO: don't use _variables but a new named attribute
 		setExitLoop(true);
 	}
 
@@ -1221,20 +1233,7 @@
 	}
 }
 
-bool Game::enterNewRoom() {
-	if ((_newRoom == getRoomNum() && _newGate == _variables[0] - 1) && !isReloaded()) {
-		// Re-entering the same room via a different gate is correct
-		// and the room needs to be reloaded (used in the ballroom when
-		// propping the chair by the brick).
-		// TODO: 1. don't use _variables but a new named attribute.  2.
-		// investigate whether the optimization with shortcut is
-		// needed; maybe reloading the room always is the right thing
-		// to do.
-		_vm->_script->endCurrentProgram(false);
-		return true;
-	}
-	// If the game has been reloaded, force reloading all animations.
-	setIsReloaded(false);
+void Game::enterNewRoom() {
 	debugC(1, kDraciLogicDebugLevel, "Entering room %d using gate %d", _newRoom, _newGate);
 	_vm->_mouse->cursorOff();
 
@@ -1285,10 +1284,6 @@
 	// cleaned up.  Some rooms (e.g., the map) don't support walking.
 	_walkingState.stopWalking();
 
-	// Reset the flag allowing to run the scripts.  It may have been turned
-	// on by pressing Escape in the intro or in the map room.
-	_vm->_script->endCurrentProgram(false);
-
 	_currentRoom.load(_newRoom, _vm->_roomsArchive);
 	loadWalkingMap(getMapID());
 	loadRoomObjects();
@@ -1303,7 +1298,10 @@
 	debugC(6, kDraciLogicDebugLevel, "Running program for gate %d", _newGate);
 	_vm->_script->runWrapper(_currentRoom._program, _currentRoom._gates[_newGate], true, true);
 
+	// Reset the loop status.
+	setLoopStatus(kStatusOrdinary);
 	setExitLoop(false);
+	setIsReloaded(false);
 
 	// Set cursor state
 	// Need to do this after we set the palette since the cursors use it
@@ -1315,18 +1313,6 @@
 		debugC(6, kDraciLogicDebugLevel, "Mouse: OFF");
 		_vm->_mouse->cursorOff();
 	}
-
-	// Reset the loop status.
-	setLoopStatus(kStatusOrdinary);
-
-	if (_vm->_script->shouldEndProgram()) {
-		// Escape pressed during the intro or map animations run in the
-		// init scripts.  This flag was turned on to skip the rest of
-		// those programs.  Return false to make start() rerun us from
-		// the beginning, because the room number has changed.
-		return false;
-	}
-	return true;
 }
 
 void Game::positionAnimAsHero(Animation *anim) {

Modified: scummvm/trunk/engines/draci/game.h
===================================================================
--- scummvm/trunk/engines/draci/game.h	2009-11-22 20:44:37 UTC (rev 46097)
+++ scummvm/trunk/engines/draci/game.h	2009-11-22 21:12:23 UTC (rev 46098)
@@ -327,7 +327,7 @@
 	void advanceAnimationsAndTestLoopExit();
 	void handleStatusChangeByMouse();
 
-	bool enterNewRoom();	// Returns false if another room change has been triggered and therefore loop() shouldn't be called yet.
+	void enterNewRoom();
 	void initWalkingOverlays();
 	void loadRoomObjects();
 	void redrawWalkingPath(Animation *anim, byte colour, const WalkingPath &path);


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