From 08ead492d8ff338a469ca92881919d8ff22e12b3 Mon Sep 17 00:00:00 2001 From: Matthew Stewart Date: Thu, 21 Jun 2018 23:33:02 -0400 Subject: STARTREK: LOVE3 finished. Added "callback" variants of the "walkCrewman" and "loadActorAnim" functions to simplify chains of calls in room-specific code. --- engines/startrek/startrek.cpp | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) (limited to 'engines/startrek/startrek.cpp') diff --git a/engines/startrek/startrek.cpp b/engines/startrek/startrek.cpp index 16c5d206d1..2960ff1637 100644 --- a/engines/startrek/startrek.cpp +++ b/engines/startrek/startrek.cpp @@ -459,7 +459,12 @@ void StarTrekEngine::updateActorAnimations() { if (nextAnimFrame == actor->numAnimFrames - 1) { actor->field62++; if (actor->triggerActionWhenAnimFinished) { - addAction(Action(ACTION_FINISHED_ANIMATION, actor->finishedAnimActionParam, 0, 0)); + if (actor->finishedAnimCallback != nullptr) { + addAction(Action(ACTION_CALLBACK, actor->finishedAnimCallback)); + actor->finishedAnimCallback = nullptr; + } + else + addAction(Action(ACTION_FINISHED_ANIMATION, actor->finishedAnimActionParam, 0, 0)); } } } @@ -530,7 +535,12 @@ void StarTrekEngine::updateActorAnimations() { if (actor->iwSrcPosition == -1) { if (actor->triggerActionWhenAnimFinished) { actor->triggerActionWhenAnimFinished = false; - addAction(Action(ACTION_FINISHED_WALKING, actor->finishedAnimActionParam & 0xff, 0, 0)); + if (actor->finishedAnimCallback != nullptr) { + addAction(Action(ACTION_CALLBACK, actor->finishedAnimCallback)); + actor->finishedAnimCallback = nullptr; + } + else + addAction(Action(ACTION_FINISHED_WALKING, actor->finishedAnimActionParam & 0xff, 0, 0)); } actor->sprite.bitmap.reset(); @@ -1855,13 +1865,13 @@ uint16 StarTrekEngine::getRandomWord() { * ".txt" files are just lists of strings. This traverses the file to get a particular * string index. */ -Common::String StarTrekEngine::getLoadedText(int itemIndex) { +Common::String StarTrekEngine::getLoadedText(int textIndex) { SharedPtr txtFile = loadFile(_txtFilename + ".txt"); byte *data = txtFile->_data; - while (itemIndex != 0) { + while (textIndex != 0) { while (*(data++) != '\0'); - itemIndex--; + textIndex--; } return (char *)data; -- cgit v1.2.3