diff options
author | Paul Gilbert | 2016-07-24 23:08:46 -0400 |
---|---|---|
committer | Paul Gilbert | 2016-07-24 23:08:46 -0400 |
commit | 3c547b6b354fc54a19dc88cc2470fb51093eb5bb (patch) | |
tree | f5a008e5ee8646c95cf1443fda06e97706f0594d /engines | |
parent | d59b012442289e81f021957306bee36de294aac5 (diff) | |
download | scummvm-rg350-3c547b6b354fc54a19dc88cc2470fb51093eb5bb.tar.gz scummvm-rg350-3c547b6b354fc54a19dc88cc2470fb51093eb5bb.tar.bz2 scummvm-rg350-3c547b6b354fc54a19dc88cc2470fb51093eb5bb.zip |
TITANIC: Load word lists for each NPC Script class
Diffstat (limited to 'engines')
-rw-r--r-- | engines/titanic/true_talk/barbot_script.cpp | 1 | ||||
-rw-r--r-- | engines/titanic/true_talk/bellbot_script.cpp | 1 | ||||
-rw-r--r-- | engines/titanic/true_talk/deskbot_script.cpp | 1 | ||||
-rw-r--r-- | engines/titanic/true_talk/doorbot_script.cpp | 1 | ||||
-rw-r--r-- | engines/titanic/true_talk/liftbot_script.cpp | 1 | ||||
-rw-r--r-- | engines/titanic/true_talk/script_handler.cpp | 20 | ||||
-rw-r--r-- | engines/titanic/true_talk/script_handler.h | 6 | ||||
-rw-r--r-- | engines/titanic/true_talk/tt_npc_script.cpp | 35 | ||||
-rw-r--r-- | engines/titanic/true_talk/tt_npc_script.h | 19 |
9 files changed, 71 insertions, 14 deletions
diff --git a/engines/titanic/true_talk/barbot_script.cpp b/engines/titanic/true_talk/barbot_script.cpp index cd44d631b4..6317f16e7c 100644 --- a/engines/titanic/true_talk/barbot_script.cpp +++ b/engines/titanic/true_talk/barbot_script.cpp @@ -63,6 +63,7 @@ void BarbotScript::setupSentences() { _mappings.load("Mappings/Barbot", 8); _entries.load("Sentences/Barbot"); _entries2.load("Sentences/Barbot2"); + _words.load("Words/Barbot"); } int BarbotScript::chooseResponse(TTroomScript *roomScript, TTsentence *sentence, uint tag) { diff --git a/engines/titanic/true_talk/bellbot_script.cpp b/engines/titanic/true_talk/bellbot_script.cpp index a13f9d6106..baf75cd405 100644 --- a/engines/titanic/true_talk/bellbot_script.cpp +++ b/engines/titanic/true_talk/bellbot_script.cpp @@ -43,6 +43,7 @@ BellbotScript::BellbotScript(int val1, const char *charClass, int v2, loadResponses("Responses/Bellbot", 4); setupSentences(); _tagMappings.load("TagMap/Bellbot"); + _words.load("Words/Bellbot"); } void BellbotScript::setupSentences() { diff --git a/engines/titanic/true_talk/deskbot_script.cpp b/engines/titanic/true_talk/deskbot_script.cpp index 61e1f717c9..1349a78755 100644 --- a/engines/titanic/true_talk/deskbot_script.cpp +++ b/engines/titanic/true_talk/deskbot_script.cpp @@ -44,6 +44,7 @@ DeskbotScript::DeskbotScript(int val1, const char *charClass, int v2, loadResponses("Responses/Deskbot", 4); setupSentences(); _tagMappings.load("TagMap/Deskbot"); + _words.load("Words/Deskbot"); } void DeskbotScript::setupSentences() { diff --git a/engines/titanic/true_talk/doorbot_script.cpp b/engines/titanic/true_talk/doorbot_script.cpp index 0db75474eb..4be25118ef 100644 --- a/engines/titanic/true_talk/doorbot_script.cpp +++ b/engines/titanic/true_talk/doorbot_script.cpp @@ -38,6 +38,7 @@ DoorbotScript::DoorbotScript(int val1, const char *charClass, int v2, loadResponses("Responses/Doorbot"); setupSentences(); _tagMappings.load("TagMap/Doorbot"); + _words.load("Words/Doorbot"); } void DoorbotScript::setupSentences() { diff --git a/engines/titanic/true_talk/liftbot_script.cpp b/engines/titanic/true_talk/liftbot_script.cpp index e911fe181e..dae80c2e69 100644 --- a/engines/titanic/true_talk/liftbot_script.cpp +++ b/engines/titanic/true_talk/liftbot_script.cpp @@ -39,6 +39,7 @@ LiftbotScript::LiftbotScript(int val1, const char *charClass, int v2, loadResponses("Responses/Liftbot"); setupSentences(); _tagMappings.load("TagMap/Liftbot"); + _words.load("Words/Liftbot"); } void LiftbotScript::setupSentences() { diff --git a/engines/titanic/true_talk/script_handler.cpp b/engines/titanic/true_talk/script_handler.cpp index c4665465da..23ecf35290 100644 --- a/engines/titanic/true_talk/script_handler.cpp +++ b/engines/titanic/true_talk/script_handler.cpp @@ -118,25 +118,31 @@ int CScriptHandler::setResponse(TTscriptBase *script, TTresponse *response) { return _owner->setResponse(script, response); } -void CScriptHandler::handleWord(TTstring &str) { +void CScriptHandler::handleWord(const TTstring *str) { handleWord1(str); handleWord2(str); } -void CScriptHandler::handleWord1(TTstring &str) { +void CScriptHandler::handleWord1(const TTstring *str) { if (_concept2P) delete _concept2P; + _concept2P = nullptr; - TTword word(str, WC_UNKNOWN, 0); - _concept2P = new TTconcept(&word); + if (str) { + TTword word(*str, WC_UNKNOWN, 0); + _concept2P = new TTconcept(&word); + } } -void CScriptHandler::handleWord2(TTstring &str) { +void CScriptHandler::handleWord2(const TTstring *str) { if (_concept1P) delete _concept1P; + _concept1P = nullptr; - TTword word(str, WC_UNKNOWN, 0); - _concept1P = new TTconcept(&word); + if (str) { + TTword word(*str, WC_UNKNOWN, 0); + _concept1P = new TTconcept(&word); + } } } // End of namespace Titanic diff --git a/engines/titanic/true_talk/script_handler.h b/engines/titanic/true_talk/script_handler.h index 11976d902d..193c60f719 100644 --- a/engines/titanic/true_talk/script_handler.h +++ b/engines/titanic/true_talk/script_handler.h @@ -43,8 +43,8 @@ private: int _inputCtr; int _field30; private: - void handleWord1(TTstring &str); - void handleWord2(TTstring &str); + void handleWord1(const TTstring *str); + void handleWord2(const TTstring *str); public: TTparser _parser; TTvocab *_vocab; @@ -81,7 +81,7 @@ public: */ int setResponse(TTscriptBase *script, TTresponse *response); - void handleWord(TTstring &str); + void handleWord(const TTstring *str); }; } // End of namespace Titanic diff --git a/engines/titanic/true_talk/tt_npc_script.cpp b/engines/titanic/true_talk/tt_npc_script.cpp index d7e3bc167e..c552d00eed 100644 --- a/engines/titanic/true_talk/tt_npc_script.cpp +++ b/engines/titanic/true_talk/tt_npc_script.cpp @@ -206,6 +206,22 @@ void TTtagMappings::load(const char *name) { /*------------------------------------------------------------------------*/ +void TTwordEntries::load(const char *name) { + Common::SeekableReadStream *r = g_vm->_filesManager->getResource(name); + + while (r->pos() < r->size()) { + TTwordEntry we; + we._id = r->readUint32LE(); + we._text = readStringFromStream(r); + + push_back(we); + } + + delete r; +} + +/*------------------------------------------------------------------------*/ + TTnpcScriptBase::TTnpcScriptBase(int charId, const char *charClass, int v2, const char *charName, int v3, int val2, int v4, int v5, int v6, int v7) : TTscriptBase(0, charClass, v2, charName, v3, v4, v5, v6, v7), @@ -298,7 +314,7 @@ void TTnpcScript::addResponse(int id) { if (id > 200000) id = getDialogueId(id); - proc15(id); + handleWord(id); TTscriptBase::addResponse(id); } @@ -350,8 +366,21 @@ void TTnpcScript::selectResponse(int id) { addResponse(id); } -int TTnpcScript::proc15(int id) const { - return 0; +bool TTnpcScript::handleWord(uint id) const { + if (_words.empty()) + return false; + + for (uint idx = 0; idx < _words.size(); ++idx) { + const TTwordEntry &we = _words[idx]; + if (we._id == id) { + TTstring str(we._text); + g_vm->_scriptHandler->handleWord(&str); + return true; + } + } + + g_vm->_scriptHandler->handleWord(nullptr); + return true; } bool TTnpcScript::handleQuote(TTroomScript *roomScript, TTsentence *sentence, diff --git a/engines/titanic/true_talk/tt_npc_script.h b/engines/titanic/true_talk/tt_npc_script.h index ab4379bf60..29b174b8e0 100644 --- a/engines/titanic/true_talk/tt_npc_script.h +++ b/engines/titanic/true_talk/tt_npc_script.h @@ -120,6 +120,18 @@ public: void load(const char *name); }; +struct TTwordEntry { + uint _id; + CString _text; + + TTwordEntry() : _id(0) {} +}; + +class TTwordEntries : public Common::Array<TTwordEntry> { +public: + void load(const char *name); +}; + class TTnpcScriptBase : public TTscriptBase { protected: int _field54; @@ -167,6 +179,7 @@ protected: TTscriptMappings _mappings; TTsentenceEntries _entries; TTtagMappings _tagMappings; + TTwordEntries _words; int _entryCount; int _field68; int _field6C; @@ -313,7 +326,11 @@ public: */ virtual void selectResponse(int id); - virtual int proc15(int id) const; + /** + * Handles scanning the word list for a given Id, and if + * found adds it to the sentence concept list + */ + virtual bool handleWord(uint id) const; virtual bool handleQuote(TTroomScript *roomScript, TTsentence *sentence, int val, uint tagId, uint remainder) const; |