[Scummvm-git-logs] scummvm master -> f04705084c6745b67766f33eac25cc73b4d3f524

antoniou79 antoniou at cti.gr
Thu Apr 4 20:10:57 CEST 2019


This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
f04705084c BLADERUNNER: Support wait for dialogue queues to finish


Commit: f04705084c6745b67766f33eac25cc73b4d3f524
    https://github.com/scummvm/scummvm/commit/f04705084c6745b67766f33eac25cc73b4d3f524
Author: Thanasis Antoniou (a.antoniou79 at gmail.com)
Date: 2019-04-04T21:03:10+03:00

Commit Message:
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.

Changed paths:
    engines/bladerunner/actor.cpp
    engines/bladerunner/actor_dialogue_queue.cpp
    engines/bladerunner/actor_dialogue_queue.h
    engines/bladerunner/actor_walk.cpp
    engines/bladerunner/bladerunner.cpp
    engines/bladerunner/bladerunner.h
    engines/bladerunner/script/scene/hf05.cpp
    engines/bladerunner/script/script.cpp
    engines/bladerunner/script/script.h


diff --git a/engines/bladerunner/actor.cpp b/engines/bladerunner/actor.cpp
index 461fbab..da4e3fe 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 479e399..627b0b1 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 e456632..bba900d 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 6758282..f9abf6d 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 911a46a..2752baa 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 a06daf2..ef5140d 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 4cdc3f0..54ffe91 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 15b6067..9242b29 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 f52fc52..340752a 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);





More information about the Scummvm-git-logs mailing list