From 23317847aba98555911fda330ab8aa359e8a855e Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Mon, 1 Aug 2016 23:27:41 -0400 Subject: TITANIC: Added TTsentence localWord --- engines/titanic/support/exe_resources.h | 1 + engines/titanic/true_talk/tt_sentence.cpp | 38 +++++++++++++++++++++++++++++-- 2 files changed, 37 insertions(+), 2 deletions(-) (limited to 'engines') diff --git a/engines/titanic/support/exe_resources.h b/engines/titanic/support/exe_resources.h index 49e05aa56f..993c34db97 100644 --- a/engines/titanic/support/exe_resources.h +++ b/engines/titanic/support/exe_resources.h @@ -44,6 +44,7 @@ public: void reset(CScriptHandler *owner, int val1, int val2); bool is18Equals(int val) const { return _field18 == val; } + int get18() const { return _field18; } }; } // End of namespace Titanic diff --git a/engines/titanic/true_talk/tt_sentence.cpp b/engines/titanic/true_talk/tt_sentence.cpp index 6a8e74d976..253ec5253e 100644 --- a/engines/titanic/true_talk/tt_sentence.cpp +++ b/engines/titanic/true_talk/tt_sentence.cpp @@ -262,8 +262,42 @@ bool TTsentence::isConcept34(int slotIndex, const TTconceptNode *node) const { } bool TTsentence::localWord(const char *str) const { - // TODO - return false; + CScriptHandler &scriptHandler = *g_vm->_exeResources._owner; + bool foundMatch = false; + + if (scriptHandler._concept1P) { + TTstring s = scriptHandler._concept1P->getText(); + if (s == str) + foundMatch = true; + } else if (scriptHandler._concept2P) { + TTstring s = scriptHandler._concept2P->getText(); + if (s == str) + foundMatch = true; + } + + int val = g_vm->_exeResources.get18(); + bool result = false; + + for (TTsentenceNode *nodeP = _nodesP; nodeP && !result; + nodeP = static_cast(nodeP->_nextP)) { + TTsynonym syn; + if (!nodeP->_wordP) + continue; + + const TTstring wordStr = nodeP->_wordP->_text; + if (val == 3 && wordStr == str) { + result = true; + } else if (nodeP->_wordP->findSynByName(str, &syn, val)) { + result = true; + } else if (foundMatch) { + result = wordStr == "it" || wordStr == "that" || wordStr == "he" + || wordStr == "she" || wordStr == "him" || wordStr == "her" + || wordStr == "them" || wordStr == "they" || wordStr == "those" + || wordStr == "1" || wordStr == "thing"; + } + } + + return result; } bool TTsentence::contains(const char *str) const { -- cgit v1.2.3