From c45f0343f4c386263025f1c39536ec9c6a2e566e Mon Sep 17 00:00:00 2001 From: Robert Špalek Date: Mon, 2 Nov 2009 02:28:43 +0000 Subject: 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 --- engines/draci/script.cpp | 46 +++++++++------------------------------------- 1 file changed, 9 insertions(+), 37 deletions(-) (limited to 'engines/draci/script.cpp') 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 ¶ms) { // 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 ¶ms) { 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 ¶ms) { int y = params.pop(); SightDirection dir = static_cast (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 ¶ms) { @@ -737,9 +723,6 @@ void Script::talk(Common::Queue ¶ms) { 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 ¶ms) { 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 ¶ms) { _vm->_sound->stopVoice(); sample->close(); } - - // Revert to "normal" loop status - _vm->_game->setLoopSubstatus(kSubstatusOrdinary); - _vm->_game->setExitLoop(false); } void Script::dialogue(Common::Queue ¶ms) { @@ -877,7 +852,7 @@ void Script::fadePalette(Common::Queue ¶ms) { 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 ¶ms) { _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 ¶ms) { -- cgit v1.2.3