From d4e5e447925d251afca20afec0e090b210740c82 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Tue, 18 Aug 2015 20:53:31 -0400 Subject: SHERLOCK: Standardize sequence stack code for both games --- engines/sherlock/scalpel/scalpel_talk.cpp | 25 ++++++++++++++++++++++++- engines/sherlock/scalpel/scalpel_talk.h | 14 +++++++++++++- 2 files changed, 37 insertions(+), 2 deletions(-) (limited to 'engines/sherlock/scalpel') diff --git a/engines/sherlock/scalpel/scalpel_talk.cpp b/engines/sherlock/scalpel/scalpel_talk.cpp index 61e736483c..4debe7fc26 100644 --- a/engines/sherlock/scalpel/scalpel_talk.cpp +++ b/engines/sherlock/scalpel/scalpel_talk.cpp @@ -879,7 +879,26 @@ OpcodeReturn ScalpelTalk::cmdCallTalkFile(const byte *&str) { return RET_SUCCESS; } -void ScalpelTalk::pullSequence() { +void ScalpelTalk::pushSequenceEntry(Object *obj) { + Scene &scene = *_vm->_scene; + SequenceEntry seqEntry; + seqEntry._objNum = scene._bgShapes.indexOf(*obj); + + if (seqEntry._objNum != -1) { + Object &obj = scene._bgShapes[seqEntry._objNum]; + for (uint idx = 0; idx < MAX_TALK_SEQUENCES; ++idx) + seqEntry._sequences.push_back(obj._sequences[idx]); + + seqEntry._frameNumber = obj._frameNumber; + seqEntry._seqTo = obj._seqTo; + } + + _sequenceStack.push(seqEntry); + if (_scriptStack.size() >= 5) + error("script stack overflow"); +} + +void ScalpelTalk::pullSequence(int slot) { Scene &scene = *_vm->_scene; if (_sequenceStack.empty()) @@ -901,6 +920,10 @@ void ScalpelTalk::pullSequence() { } } +void ScalpelTalk::clearSequences() { + _sequenceStack.clear(); +} + } // End of namespace Scalpel } // End of namespace Sherlock diff --git a/engines/sherlock/scalpel/scalpel_talk.h b/engines/sherlock/scalpel/scalpel_talk.h index 1d70db14b9..9e07b26dc8 100644 --- a/engines/sherlock/scalpel/scalpel_talk.h +++ b/engines/sherlock/scalpel/scalpel_talk.h @@ -37,6 +37,8 @@ namespace Scalpel { class ScalpelTalk : public Talk { private: + Common::Stack _sequenceStack; + OpcodeReturn cmdSwitchSpeaker(const byte *&str); OpcodeReturn cmdAssignPortraitLocation(const byte *&str); OpcodeReturn cmdGotoScene(const byte *&str); @@ -102,16 +104,26 @@ public: */ void talk3DOMovieTrigger(int subIndex); + /** + * Push the details of a passed object onto the saved sequences stack + */ + virtual void pushSequenceEntry(Object *obj); + /** * Pulls a background object sequence from the sequence stack and restore's the * object's sequence */ - virtual void pullSequence(); + virtual void pullSequence(int slot = -1); /** * Returns true if the script stack is empty */ virtual bool isSequencesEmpty() const { return _scriptStack.empty(); } + + /** + * Clears the stack of pending object sequences associated with speakers in the scene + */ + virtual void clearSequences(); }; } // End of namespace Scalpel -- cgit v1.2.3