diff options
author | Thanasis Antoniou | 2019-04-04 21:01:25 +0300 |
---|---|---|
committer | Thanasis Antoniou | 2019-04-04 21:03:10 +0300 |
commit | f04705084c6745b67766f33eac25cc73b4d3f524 (patch) | |
tree | f54608dbc31fff10871fa0ded267104a61f16893 | |
parent | e4b78f4f621a7d73c08099c3b7674f3966cf8da4 (diff) | |
download | scummvm-rg350-f04705084c6745b67766f33eac25cc73b4d3f524.tar.gz scummvm-rg350-f04705084c6745b67766f33eac25cc73b4d3f524.tar.bz2 scummvm-rg350-f04705084c6745b67766f33eac25cc73b4d3f524.zip |
BLADERUNNER: Support wait for dialogue queues to finish
Fixes a Crazylegs bug where he can interrupt himself
Could probably be used elsewhere if there are any other such cases.
-rw-r--r-- | engines/bladerunner/actor.cpp | 2 | ||||
-rw-r--r-- | engines/bladerunner/actor_dialogue_queue.cpp | 17 | ||||
-rw-r--r-- | engines/bladerunner/actor_dialogue_queue.h | 1 | ||||
-rw-r--r-- | engines/bladerunner/actor_walk.cpp | 2 | ||||
-rw-r--r-- | engines/bladerunner/bladerunner.cpp | 16 | ||||
-rw-r--r-- | engines/bladerunner/bladerunner.h | 1 | ||||
-rw-r--r-- | engines/bladerunner/script/scene/hf05.cpp | 7 | ||||
-rw-r--r-- | engines/bladerunner/script/script.cpp | 5 | ||||
-rw-r--r-- | engines/bladerunner/script/script.h | 1 |
9 files changed, 49 insertions, 3 deletions
diff --git a/engines/bladerunner/actor.cpp b/engines/bladerunner/actor.cpp index 461fbab148..da4e3fe448 100644 --- a/engines/bladerunner/actor.cpp +++ b/engines/bladerunner/actor.cpp @@ -53,7 +53,7 @@ Actor::Actor(BladeRunnerEngine *vm, int actorId) { _walkInfo = new ActorWalk(vm); _movementTrack = new MovementTrack(); - _cluesLimit = (actorId == 0 || actorId == 99) ? 4 : 2; + _cluesLimit = (actorId == kActorMcCoy || actorId == kActorVoiceOver) ? 4 : 2; _clues = new ActorClues(vm, _cluesLimit); _combatInfo = new ActorCombat(vm); diff --git a/engines/bladerunner/actor_dialogue_queue.cpp b/engines/bladerunner/actor_dialogue_queue.cpp index 479e399d9c..627b0b1cb3 100644 --- a/engines/bladerunner/actor_dialogue_queue.cpp +++ b/engines/bladerunner/actor_dialogue_queue.cpp @@ -52,7 +52,7 @@ ActorDialogueQueue::~ActorDialogueQueue() { } void ActorDialogueQueue::add(int actorId, int sentenceId, int animationMode) { - if (actorId == 0 || actorId == BladeRunnerEngine::kActorVoiceOver) { + if (actorId == kActorMcCoy || actorId == kActorVoiceOver) { animationMode = -1; } if (_entries.size() < kMaxEntries) { @@ -105,6 +105,21 @@ void ActorDialogueQueue::flush(int a1, bool callScript) { } } +/** +* return true when queue is empty and object is flushed +*/ +bool ActorDialogueQueue::isEmpty() { + return _entries.empty() \ + && !_isNotPause \ + && !_isPause \ + && _actorId == -1 \ + && _sentenceId == -1 \ + && _animationMode == -1 \ + && _animationModePrevious == -1 \ + && _delay == 0 \ + && _timeLast == 0; +} + void ActorDialogueQueue::tick() { if (!_vm->_audioSpeech->isPlaying()) { if (_isPause) { diff --git a/engines/bladerunner/actor_dialogue_queue.h b/engines/bladerunner/actor_dialogue_queue.h index e45663275a..bba900db7d 100644 --- a/engines/bladerunner/actor_dialogue_queue.h +++ b/engines/bladerunner/actor_dialogue_queue.h @@ -64,6 +64,7 @@ public: void add(int actorId, int sentenceId, int animationMode); void addPause(int delay); void flush(int a1, bool callScript); + bool isEmpty(); void tick(); void save(SaveFileWriteStream &f); diff --git a/engines/bladerunner/actor_walk.cpp b/engines/bladerunner/actor_walk.cpp index 675828284c..f9abf6dc15 100644 --- a/engines/bladerunner/actor_walk.cpp +++ b/engines/bladerunner/actor_walk.cpp @@ -174,7 +174,7 @@ bool ActorWalk::tick(int actorId, float stepDistance, bool mustReachWalkDestinat int r = nextOnPath(actorId, _current, _destination, next); obstaclesRestore(); if (r == 0) { - stop(actorId, actorId == 0, kAnimationModeCombatIdle, kAnimationModeIdle); + stop(actorId, actorId == kActorMcCoy, kAnimationModeCombatIdle, kAnimationModeIdle); return false; } if (r != -1) { diff --git a/engines/bladerunner/bladerunner.cpp b/engines/bladerunner/bladerunner.cpp index 911a46ad83..2752baa393 100644 --- a/engines/bladerunner/bladerunner.cpp +++ b/engines/bladerunner/bladerunner.cpp @@ -1693,6 +1693,22 @@ void BladeRunnerEngine::loopActorSpeaking() { playerGainsControl(); } +/** +* To be used only for when there is a chance an ongoing dialogue in a dialogue queue +* might be interrupted AND that is unwanted behavior (sometimes, it's intended that the dialogue +* can be interrupted without necessarily being finished). +*/ +void BladeRunnerEngine::loopQueuedDialogueStillPlaying() { + if (_actorDialogueQueue->isEmpty()) { + return; + } + + do { + gameTick(); + } while (_gameIsRunning && !_actorDialogueQueue->isEmpty()); + +} + void BladeRunnerEngine::outtakePlay(int id, bool noLocalization, int container) { Common::String name = _gameInfo->getOuttake(id); diff --git a/engines/bladerunner/bladerunner.h b/engines/bladerunner/bladerunner.h index a06daf2dd7..ef5140d522 100644 --- a/engines/bladerunner/bladerunner.h +++ b/engines/bladerunner/bladerunner.h @@ -275,6 +275,7 @@ public: void gameWaitForActive(); void loopActorSpeaking(); + void loopQueuedDialogueStillPlaying(); void outtakePlay(int id, bool no_localization, int container = -1); diff --git a/engines/bladerunner/script/scene/hf05.cpp b/engines/bladerunner/script/scene/hf05.cpp index 4cdc3f02b7..54ffe91b79 100644 --- a/engines/bladerunner/script/scene/hf05.cpp +++ b/engines/bladerunner/script/scene/hf05.cpp @@ -690,6 +690,13 @@ void SceneScriptHF05::talkWithCrazyLegs1() { Ambient_Sounds_Play_Sound(149, 99, 99, 0, 0); Actor_Face_Actor(kActorCrazylegs, kActorMcCoy, true); Actor_Face_Actor(kActorMcCoy, kActorCrazylegs, true); +#if BLADERUNNER_ORIGINAL_BUGS +#else + // There is a chance here that Crazylegs will "interrupt himself" + // and thus sometimes skip the last sentence of the above queued dialogue in chapter 3. + // So we explicitly wait for the queue to be emptied before proceeding to his next line + ADQ_Wait_For_All_Queued_Dialogue(); +#endif // BLADERUNNER_ORIGINAL_BUGS Actor_Says(kActorCrazylegs, 170, kAnimationModeTalk); Actor_Says(kActorCrazylegs, 180, 12); Actor_Says(kActorCrazylegs, 190, 14); diff --git a/engines/bladerunner/script/script.cpp b/engines/bladerunner/script/script.cpp index 15b6067030..9242b294c4 100644 --- a/engines/bladerunner/script/script.cpp +++ b/engines/bladerunner/script/script.cpp @@ -1551,6 +1551,11 @@ void ScriptBase::ADQ_Add_Pause(int delay) { _vm->_actorDialogueQueue->addPause(delay); } +void ScriptBase::ADQ_Wait_For_All_Queued_Dialogue() { + debugC(kDebugScript, "ADQ_Wait_For_All_Queued_Dialogue()"); + _vm->loopQueuedDialogueStillPlaying(); +} + bool ScriptBase::Game_Over() { debugC(kDebugScript, "Game_Over()"); _vm->_gameIsRunning = false; diff --git a/engines/bladerunner/script/script.h b/engines/bladerunner/script/script.h index f52fc52431..340752ac4c 100644 --- a/engines/bladerunner/script/script.h +++ b/engines/bladerunner/script/script.h @@ -259,6 +259,7 @@ protected: void ADQ_Flush(); void ADQ_Add(int actorId, int sentenceId, int animationMode); void ADQ_Add_Pause(int delay); + void ADQ_Wait_For_All_Queued_Dialogue(); bool Game_Over(); void Autosave_Game(int textId); void I_Sez(const char *str); |