diff options
author | Paul Gilbert | 2016-05-24 19:55:59 -0400 |
---|---|---|
committer | Paul Gilbert | 2016-07-15 19:15:22 -0400 |
commit | 483929e70a74f86b250e8934a3880919e9bf3a02 (patch) | |
tree | c48324ebfc760cc8b93273d99ccdd4d438328840 /engines/titanic/true_talk | |
parent | 06b9131a6cd5f009147368746b9354378d9d5d18 (diff) | |
download | scummvm-rg350-483929e70a74f86b250e8934a3880919e9bf3a02.tar.gz scummvm-rg350-483929e70a74f86b250e8934a3880919e9bf3a02.tar.bz2 scummvm-rg350-483929e70a74f86b250e8934a3880919e9bf3a02.zip |
TITANIC: Added various TTparser & TTconcept support methods
Diffstat (limited to 'engines/titanic/true_talk')
-rw-r--r-- | engines/titanic/true_talk/tt_concept.cpp | 5 | ||||
-rw-r--r-- | engines/titanic/true_talk/tt_concept.h | 8 | ||||
-rw-r--r-- | engines/titanic/true_talk/tt_concept_node.cpp | 1 | ||||
-rw-r--r-- | engines/titanic/true_talk/tt_parser.cpp | 57 | ||||
-rw-r--r-- | engines/titanic/true_talk/tt_parser.h | 8 |
5 files changed, 77 insertions, 2 deletions
diff --git a/engines/titanic/true_talk/tt_concept.cpp b/engines/titanic/true_talk/tt_concept.cpp index 05e6401018..2c54f2fab6 100644 --- a/engines/titanic/true_talk/tt_concept.cpp +++ b/engines/titanic/true_talk/tt_concept.cpp @@ -242,6 +242,11 @@ bool TTconcept::checkWordId2() const { return (_wordP && _wordP->_id == 204) || (_scriptP && _scriptP->getId() == 3); } +bool TTconcept::checkWordId3() const { + return isWordClass(WC_ABSTRACT) || isWordClass(WC_ADJECTIVE) || + (isWordClass(WC_ADVERB) && getWordId() != 910); +} + bool TTconcept::checkWordClass() const { return !_scriptP && _wordP && (_wordP->_wordClass == WC_THING || _wordP->_wordClass == WC_PRONOUN); } diff --git a/engines/titanic/true_talk/tt_concept.h b/engines/titanic/true_talk/tt_concept.h index 8168d4ebe1..98a6ee6ea3 100644 --- a/engines/titanic/true_talk/tt_concept.h +++ b/engines/titanic/true_talk/tt_concept.h @@ -118,12 +118,20 @@ public: */ bool isValid() const { return _status == SS_VALID; } + /** + * Returns true if the word is of the specified class + */ + bool isWordClass(WordClass wordClass) const { + return _wordP && _wordP->isClass(wordClass); + } + void setFlag(bool val) { _flag = val; } void set1C(int val) { _field1C = val; } bool checkWordId1() const; bool checkWordId2() const; + bool checkWordId3() const; bool checkWordClass() const; /** diff --git a/engines/titanic/true_talk/tt_concept_node.cpp b/engines/titanic/true_talk/tt_concept_node.cpp index aca5718bca..956d87bb68 100644 --- a/engines/titanic/true_talk/tt_concept_node.cpp +++ b/engines/titanic/true_talk/tt_concept_node.cpp @@ -51,7 +51,6 @@ TTconceptNode::TTconceptNode(const TTconceptNode &src) : _concept0P(_concepts[0] } } - void TTconceptNode::deleteSiblings() { // Iterate through the linked chain of nodes, deleting each in turn for (TTconceptNode *curP = _nextP, *nextP = nullptr; nextP; curP = nextP) { diff --git a/engines/titanic/true_talk/tt_parser.cpp b/engines/titanic/true_talk/tt_parser.cpp index d02aec931a..7b9f4c4c1c 100644 --- a/engines/titanic/true_talk/tt_parser.cpp +++ b/engines/titanic/true_talk/tt_parser.cpp @@ -790,7 +790,13 @@ int TTparser::considerRequests(TTword *word) { break; case SEEK_ACTOR: + if (_sentenceConcept->_concept0P) { + } + else { + + } + break; case SEEK_OBJECT: case SEEK_OBJECT_OVERRIDE: @@ -854,6 +860,30 @@ int TTparser::addConcept(TTconcept *concept) { return SS_VALID; } +void TTparser::removeConcept(TTconcept *concept) { + // If no concept passed, exit immediately + if (!concept) + return; + + if (_conceptP == concept) { + // Concept specified is the ver ystart of the linked list, so reset head pointer + _conceptP = _conceptP->_nextP; + } else { + // Scan through the linked list, looking for the specific concept + for (TTconcept *currP = _conceptP; currP; currP = currP->_nextP) { + if (currP->_nextP == concept) { + // Found match, so unlink the next link from the chain + currP->_nextP = currP->_nextP->_nextP; + break; + } + } + } + + // FInally, delete the concept + concept->_nextP = nullptr; + delete concept; +} + int TTparser::fn1() { // TODO return 0; @@ -917,4 +947,31 @@ void TTparser::conceptChanged(TTconcept *newConcept, TTconcept *oldConcept) { _currentConceptP = newConcept; } +bool TTparser::checkConcept2(TTconcept *concept, int conceptMode) { + switch (conceptMode) { + case 3: + return concept->checkWordId2(); + + case 5: + return concept->checkWordClass(); + + case 8: + return concept->checkWordId1(); + + case 9: + if (!concept->checkWordId3() && _sentenceConcept->_concept2P) { + if (!_sentenceConcept->_concept2P->checkWordId2() || !concept->checkWordId2()) { + return _sentenceConcept->_concept2P->checkWordClass() && + concept->checkWordClass(); + } + } + break; + + default: + break; + } + + return false; +} + } // End of namespace Titanic diff --git a/engines/titanic/true_talk/tt_parser.h b/engines/titanic/true_talk/tt_parser.h index 3e8c91c917..512acbec89 100644 --- a/engines/titanic/true_talk/tt_parser.h +++ b/engines/titanic/true_talk/tt_parser.h @@ -147,7 +147,6 @@ private: int processRequests(TTword *word); void addToConceptList(TTword *word); - int fn2(TTword *word); int checkReferent(TTpronoun *pronoun); /** @@ -160,8 +159,15 @@ private: */ int addConcept(TTconcept *concept); + /** + * Detaches a concept from the main concept list if prseent, then deletes it + */ + void removeConcept(TTconcept *concept); + int fn1(); + int fn2(TTword *word); bool fn3(TTconcept **v, int v2); + bool checkConcept2(TTconcept *concept, int conceptMode); public: CScriptHandler *_owner; TTsentenceConcept *_sentenceConcept; |