aboutsummaryrefslogtreecommitdiff
path: root/engines/draci/script.cpp
diff options
context:
space:
mode:
authorRobert Špalek2009-11-02 02:28:43 +0000
committerRobert Špalek2009-11-02 02:28:43 +0000
commitc45f0343f4c386263025f1c39536ec9c6a2e566e (patch)
treee79aa7095d494462b46188509dd0118b94f75444 /engines/draci/script.cpp
parent9f711bd0ced5368a0dd5a28be7db5d7128849c01 (diff)
downloadscummvm-rg350-c45f0343f4c386263025f1c39536ec9c6a2e566e.tar.gz
scummvm-rg350-c45f0343f4c386263025f1c39536ec9c6a2e566e.tar.bz2
scummvm-rg350-c45f0343f4c386263025f1c39536ec9c6a2e566e.zip
Refactored running loop().
- shouldExitLoop() is a bool again and introduced new flag isReloaded() instead of adding special hacky value 2 - loop() accepts 2 parameters: loop substatus and shouldExit flag, because each caller previously had to set and restore these manually. loop() now also tests whether the substatuses are properly nested. reordered the loop-exitting code. - renamed loop substatuses to logical names - enterNewRoom() returns bool whether loop() should continue so that start() doesn't have to test and clear shouldEndProgram(). it doesn't need force_reload as a parameter anymore. - dialog selections use new inner substatus instead of outer substatus, for consistency svn-id: r45607
Diffstat (limited to 'engines/draci/script.cpp')
-rw-r--r--engines/draci/script.cpp46
1 files changed, 9 insertions, 37 deletions
diff --git a/engines/draci/script.cpp b/engines/draci/script.cpp
index f938737728..6a2eaeddd4 100644
--- a/engines/draci/script.cpp
+++ b/engines/draci/script.cpp
@@ -359,11 +359,7 @@ void Script::play(Common::Queue<int> &params) {
// Runs just one phase of the loop and exits. Used when waiting for a
// particular animation phase to come.
- _vm->_game->setLoopSubstatus(kSubstatusStrange);
- _vm->_game->setExitLoop(true);
- _vm->_game->loop();
- _vm->_game->setExitLoop(false);
- _vm->_game->setLoopSubstatus(kSubstatusOrdinary);
+ _vm->_game->loop(kInnerUntilExit, true);
}
Animation *Script::loadObjectAnimation(GameObject *obj, int animID) {
@@ -463,19 +459,14 @@ void Script::startPlay(Common::Queue<int> &params) {
anim->registerCallback(&Animation::exitGameLoop);
- _vm->_game->setLoopSubstatus(kSubstatusStrange);
-
bool visible = (obj->_location == _vm->_game->getRoomNum() && obj->_visible);
-
if (objID == kDragonObject || visible) {
_vm->_anims->play(animID);
}
// Runs an inner loop until the animation ends.
- _vm->_game->loop();
- _vm->_game->setExitLoop(false);
+ _vm->_game->loop(kInnerUntilExit, false);
_vm->_anims->stop(animID);
- _vm->_game->setLoopSubstatus(kSubstatusOrdinary);
anim->registerCallback(&Animation::doNothing);
}
@@ -677,17 +668,12 @@ void Script::walkOnPlay(Common::Queue<int> &params) {
int y = params.pop();
SightDirection dir = static_cast<SightDirection> (params.pop());
- // HACK: This should be an onDest action when hero walking is properly implemented
- // For now, we just go throught the loop-body once to redraw the screen.
- _vm->_game->setExitLoop(true);
-
_vm->_game->walkHero(x, y, dir);
- _vm->_game->setLoopSubstatus(kSubstatusStrange);
- _vm->_game->loop();
- _vm->_game->setLoopSubstatus(kSubstatusOrdinary);
-
- _vm->_game->setExitLoop(false);
+ // HACK: This (shouldExit==true) should be an onDest action when hero
+ // walking is properly implemented For now, we just go throught the
+ // loop-body once to redraw the screen.
+ _vm->_game->loop(kInnerUntilExit, true);
}
void Script::newRoom(Common::Queue<int> &params) {
@@ -737,9 +723,6 @@ void Script::talk(Common::Queue<int> &params) {
speechFrame->setFont(_vm->_smallFont);
}
- // Set the loop substatus to an appropriate value
- _vm->_game->setLoopSubstatus(kSubstatusTalk);
-
// Speak the dubbing if possible
uint dubbingDuration = 0;
if (sample) {
@@ -776,12 +759,8 @@ void Script::talk(Common::Queue<int> &params) {
speechFrame->setX(x);
speechFrame->setY(y);
- // Prevent the loop from exiting early if other things left the loop in the
- // "exit immediately" state
- _vm->_game->setExitLoop(false);
-
// Call the game loop to enable interactivity until the text expires.
- _vm->_game->loop();
+ _vm->_game->loop(kInnerWhileTalk, false);
// Delete the text
_vm->_screen->getSurface()->markDirtyRect(speechFrame->getRect(kNoDisplacement));
@@ -793,10 +772,6 @@ void Script::talk(Common::Queue<int> &params) {
_vm->_sound->stopVoice();
sample->close();
}
-
- // Revert to "normal" loop status
- _vm->_game->setLoopSubstatus(kSubstatusOrdinary);
- _vm->_game->setExitLoop(false);
}
void Script::dialogue(Common::Queue<int> &params) {
@@ -877,7 +852,7 @@ void Script::fadePalette(Common::Queue<int> &params) {
int phases = params.pop();
// Let the palette fade in the background while the game continues.
- // Since we don't set substatus to kSubstatusFade, the outer loop will
+ // Since we don't set substatus to kInnerWhileFade, the outer loop will
// just continue rather than exit.
_vm->_game->initializeFading(phases);
}
@@ -889,10 +864,7 @@ void Script::fadePalettePlay(Common::Queue<int> &params) {
_vm->_game->initializeFading(phases);
// Call the game loop to enable interactivity until the fading is done.
- _vm->_game->setLoopSubstatus(kSubstatusFade);
- _vm->_game->loop();
- _vm->_game->setExitLoop(false);
- _vm->_game->setLoopSubstatus(kSubstatusOrdinary);
+ _vm->_game->loop(kInnerWhileFade, false);
}
void Script::setPalette(Common::Queue<int> &params) {