aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Špalek2009-11-22 21:12:23 +0000
committerRobert Špalek2009-11-22 21:12:23 +0000
commitf6f8b66d455d73fb72e8c4547d763d9d9d115386 (patch)
tree99df74bb0b0bd666c1c0842e7c2a19bbc3c1be36
parentd3d16422e0177942fcf5045cc65585c10d0da9b0 (diff)
downloadscummvm-rg350-f6f8b66d455d73fb72e8c4547d763d9d9d115386.tar.gz
scummvm-rg350-f6f8b66d455d73fb72e8c4547d763d9d9d115386.tar.bz2
scummvm-rg350-f6f8b66d455d73fb72e8c4547d763d9d9d115386.zip
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. svn-id: r46098
-rw-r--r--engines/draci/game.cpp52
-rw-r--r--engines/draci/game.h2
2 files changed, 20 insertions, 34 deletions
diff --git a/engines/draci/game.cpp b/engines/draci/game.cpp
index 3ea717c2d9..99cb5d7d74 100644
--- a/engines/draci/game.cpp
+++ b/engines/draci/game.cpp
@@ -154,10 +154,21 @@ Game::Game(DraciEngine *vm) : _vm(vm), _walkingState(vm) {
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 @@ void Game::advanceAnimationsAndTestLoopExit() {
// 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 @@ void Game::deleteObjectAnimations() {
}
}
-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 @@ bool Game::enterNewRoom() {
// 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 @@ bool Game::enterNewRoom() {
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 @@ bool Game::enterNewRoom() {
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) {
diff --git a/engines/draci/game.h b/engines/draci/game.h
index 63ad10a814..de22b0e2c6 100644
--- a/engines/draci/game.h
+++ b/engines/draci/game.h
@@ -327,7 +327,7 @@ private:
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);