From 59bc9f846d639c2794ec41065092e49e8458c5f9 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Thu, 6 Aug 2015 21:40:35 -0400 Subject: SHERLOCK: RT: Properly implement cmdWalkHolmesAndNPCToCoords --- engines/sherlock/tattoo/tattoo_people.cpp | 69 +++++++++++++++++++++++++++++++ engines/sherlock/tattoo/tattoo_people.h | 5 +++ engines/sherlock/tattoo/tattoo_talk.cpp | 12 +++++- 3 files changed, 84 insertions(+), 2 deletions(-) (limited to 'engines') diff --git a/engines/sherlock/tattoo/tattoo_people.cpp b/engines/sherlock/tattoo/tattoo_people.cpp index b0dfa73faf..3738bbf418 100644 --- a/engines/sherlock/tattoo/tattoo_people.cpp +++ b/engines/sherlock/tattoo/tattoo_people.cpp @@ -1111,6 +1111,75 @@ void TattooPerson::walkHolmesToNPC() { } } +void TattooPerson::walkBothToCoords(const PositionFacing &holmesDest, const PositionFacing &npcDest) { + Events &events = *_vm->_events; + TattooPeople &people = *(TattooPeople *)_vm->_people; + Scene &scene = *_vm->_scene; + Talk &talk = *_vm->_talk; + TattooPerson &holmes = people[HOLMES]; + bool holmesStopped = false, npcStopped = false; + + // Save the current cursor and change to the wait cursor + CursorId oldCursor = events.getCursor(); + events.setCursor(WAIT); + + holmes._centerWalk = false; + _centerWalk = false; + + // Start Holmes walking to his dest + holmes._walkDest = Common::Point(holmesDest.x / FIXED_INT_MULTIPLIER + 10, holmesDest.y / FIXED_INT_MULTIPLIER); + people._allowWalkAbort = true; + holmes.goAllTheWay(); + + // Start the NPC walking to their dest + _walkDest = Common::Point(npcDest.x / FIXED_INT_MULTIPLIER + 10, npcDest.y / FIXED_INT_MULTIPLIER); + goAllTheWay(); + + // Clear the path variables + _npcIndex = _npcPause = 0; + Common::fill(&_npcPath[0], &_npcPath[100], 0); + _npcFacing = npcDest._facing; + + // Now loop until both stop walking + do { + events.pollEvents(); + scene.doBgAnim(); + + if (!holmes._walkCount && !holmesStopped) { + // Holmes finished walking + holmesStopped = true; + + // Ensure Holmes is on the exact destination spot + holmes._position = holmesDest; + holmes._sequenceNumber = holmesDest._facing; + holmes.gotoStand(); + } + + if (!_walkCount && !npcStopped) { + // NPC finished walking + npcStopped = true; + + // Ensure NPC is on the exact destination spot + _position = npcDest; + _sequenceNumber = npcDest._facing; + gotoStand(); + } + + } while (!_vm->shouldQuit() && (holmes._walkCount || _walkCount)); + + holmes._centerWalk = true; + _centerWalk = true; + + // Do one last frame draw so that the lsat person to stop will be drawn in their final position + scene.doBgAnim(); + + _updateNPCPath = true; + + if (!talk._talkToAbort) + // Restore original mouse cursor + events.setCursor(oldCursor); +} + void TattooPerson::centerScreenOnPerson() { Screen &screen = *_vm->_screen; TattooUserInterface &ui = *(TattooUserInterface *)_vm->_ui; diff --git a/engines/sherlock/tattoo/tattoo_people.h b/engines/sherlock/tattoo/tattoo_people.h index 06c6776314..4e57cfe9b2 100644 --- a/engines/sherlock/tattoo/tattoo_people.h +++ b/engines/sherlock/tattoo/tattoo_people.h @@ -182,6 +182,11 @@ public: */ void walkHolmesToNPC(); + /** + * Walk both the specified character and Holmes to specified destination positions + */ + void walkBothToCoords(const PositionFacing &holmesDest, const PositionFacing &npcDest); + /** * This adjusts the sprites position, as well as it's animation sequence: */ diff --git a/engines/sherlock/tattoo/tattoo_talk.cpp b/engines/sherlock/tattoo/tattoo_talk.cpp index 260aee8857..0d385008b3 100644 --- a/engines/sherlock/tattoo/tattoo_talk.cpp +++ b/engines/sherlock/tattoo/tattoo_talk.cpp @@ -862,13 +862,21 @@ OpcodeReturn TattooTalk::cmdWalkHomesAndNPCToCoords(const byte *&str) { person.pushNPCPath(); person._npcMoved = true; + // Get destination position and facing for Holmes int xp = (str[0] - 1) * 256 + str[1] - 1; if (xp > 16384) xp = -1 * (xp - 16384); int yp = (str[2] - 1) * 256 + str[3] - 1; + PositionFacing holmesDest(xp * FIXED_INT_MULTIPLIER, yp * FIXED_INT_MULTIPLIER, DIRECTION_CONVERSION[str[4] - 1]); - person.walkToCoords(Point32(xp * FIXED_INT_MULTIPLIER, yp * FIXED_INT_MULTIPLIER), - DIRECTION_CONVERSION[str[4] - 1]); + // Get destination position and facing for specified NPC + xp = (str[5] - 1) * 256 + str[6] - 1; + if (xp > 16384) + xp = -1 * (xp - 16384); + yp = (str[7] - 1) * 256 + str[8] - 1; + PositionFacing npcDest(xp * FIXED_INT_MULTIPLIER, yp * FIXED_INT_MULTIPLIER, DIRECTION_CONVERSION[str[9] - 1]); + + person.walkBothToCoords(holmesDest, npcDest); if (_talkToAbort) return RET_EXIT; -- cgit v1.2.3