aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorPaul Gilbert2016-05-28 09:18:08 -0400
committerPaul Gilbert2016-07-15 19:16:02 -0400
commit8a3118912191736620580fd4ead9b19b15d3c3dd (patch)
tree9c51daa00cd2affd9461bfc86a5bfbbd03cc9520 /engines
parent5ffe93ad9b78d1354df62dff2bbbb743629c56f3 (diff)
downloadscummvm-rg350-8a3118912191736620580fd4ead9b19b15d3c3dd.tar.gz
scummvm-rg350-8a3118912191736620580fd4ead9b19b15d3c3dd.tar.bz2
scummvm-rg350-8a3118912191736620580fd4ead9b19b15d3c3dd.zip
TITANIC: Adding more to TTparser considerRequests, and support methods
Diffstat (limited to 'engines')
-rw-r--r--engines/titanic/true_talk/tt_concept.h4
-rw-r--r--engines/titanic/true_talk/tt_parser.cpp66
-rw-r--r--engines/titanic/true_talk/tt_sentence.cpp37
-rw-r--r--engines/titanic/true_talk/tt_sentence.h17
4 files changed, 108 insertions, 16 deletions
diff --git a/engines/titanic/true_talk/tt_concept.h b/engines/titanic/true_talk/tt_concept.h
index 58646601a6..9d067ad947 100644
--- a/engines/titanic/true_talk/tt_concept.h
+++ b/engines/titanic/true_talk/tt_concept.h
@@ -35,8 +35,6 @@ class TTword;
class TTconcept {
private:
- TTscriptBase *_scriptP;
- TTword *_wordP;
TTstring _string1;
int _field1C;
TTword *_word2P;
@@ -70,6 +68,8 @@ private:
void initialize(TTconcept &src);
public:
TTconcept *_nextP;
+ TTscriptBase *_scriptP;
+ TTword *_wordP;
ScriptType _scriptType;
int _field14;
int _field20;
diff --git a/engines/titanic/true_talk/tt_parser.cpp b/engines/titanic/true_talk/tt_parser.cpp
index 2cc9346019..748c19a718 100644
--- a/engines/titanic/true_talk/tt_parser.cpp
+++ b/engines/titanic/true_talk/tt_parser.cpp
@@ -731,6 +731,7 @@ int TTparser::considerRequests(TTword *word) {
TTconcept *concept = nullptr;
int status = 0;
bool flag = false;
+ bool modifierFlag = false;
while (word) {
//int ecx = 906;
@@ -827,6 +828,71 @@ int TTparser::considerRequests(TTword *word) {
case SEEK_OWNERSHIP:
case SEEK_STATE:
case SEEK_MODIFIERS:
+ if (!modifierFlag) {
+ bool tempFlag = false;
+
+ switch (word->_wordClass) {
+ case WC_ACTION:
+ status = processModifiers(1, word);
+ break;
+ case WC_THING:
+ status = processModifiers(2, word);
+ break;
+ case WC_ABSTRACT:
+ if (word->_id != 300) {
+ status = processModifiers(3, word);
+ } else if (!_conceptP->findByWordClass(WC_THING)) {
+ status = processModifiers(3, word);
+ } else {
+ word->_id = atoi(word->_text.c_str());
+ }
+ break;
+ case WC_PRONOUN:
+ if (word->_id != 602)
+ addToConceptList(word);
+ break;
+ case WC_ADJECTIVE: {
+ TTconcept *concept = _conceptP->findByWordClass(WC_THING);
+ if (concept) {
+ concept->_string2 += ' ';
+ concept->_string2 += word->getText();
+ } else {
+ status = processModifiers(8, word);
+ }
+ break;
+ }
+ case WC_ADVERB:
+ if (word->_id == 906) {
+ for (TTconcept *currP = _conceptP; currP; currP = currP->_nextP) {
+ if (_sentence->isFrameSlotClass(1, WC_ACTION) ||
+ _sentence->isFrameSlotClass(1, WC_THING))
+ currP->_field34 = 1;
+ }
+ } else {
+ TTconcept *conceptP = _conceptP->findByWordClass(WC_ACTION);
+
+ if (conceptP) {
+ conceptP->_string2 += ' ';
+ conceptP->_string2 += word->getText();
+ } else {
+ tempFlag = true;
+ }
+ }
+ break;
+ default:
+ addToConceptList(word);
+ status = 0;
+ break;
+ }
+
+ if (tempFlag)
+ status = _sentenceConcept->createConcept(1, 5, word);
+
+ modifierFlag = true;
+ flag = true;
+ }
+ break;
+
case SEEK_NEW_FRAME:
case SEEK_STATE_OBJECT:
if (!_sentenceConcept->_concept5P) {
diff --git a/engines/titanic/true_talk/tt_sentence.cpp b/engines/titanic/true_talk/tt_sentence.cpp
index d619c9e2f3..c777464f8d 100644
--- a/engines/titanic/true_talk/tt_sentence.cpp
+++ b/engines/titanic/true_talk/tt_sentence.cpp
@@ -107,10 +107,10 @@ int TTsentence::storeVocabHit(TTword *word) {
return 0;
}
-bool TTsentence::fn2(int conceptIndex, const TTstring &str, TTconceptNode *conceptNode) {
+bool TTsentence::fn2(int slotIndex, const TTstring &str, TTconceptNode *conceptNode) {
if (!conceptNode)
conceptNode = &_sentenceConcept;
- TTconcept *concept = getFrameSlot(conceptIndex, conceptNode);
+ TTconcept *concept = getFrameSlot(slotIndex, conceptNode);
if (!concept)
return str == "isEmpty";
@@ -142,14 +142,14 @@ bool TTsentence::fn2(int conceptIndex, const TTstring &str, TTconceptNode *conce
return true;
}
- if (conceptIndex == 1 && g_vm->_exeResources._owner->_concept4P) {
+ if (slotIndex == 1 && g_vm->_exeResources._owner->_concept4P) {
if (str == g_vm->_exeResources._owner->_concept4P->getText() &&
conceptText == "do")
goto exit;
}
- if (g_vm->_exeResources._owner->_concept2P && (conceptIndex == 0 ||
- conceptIndex == 3 || conceptIndex == 4)) {
+ if (g_vm->_exeResources._owner->_concept2P && (slotIndex == 0 ||
+ slotIndex == 3 || slotIndex == 4)) {
if (str == g_vm->_exeResources._owner->_concept2P->getText() &&
(conceptText == "it" || conceptText == "he" || conceptText == "she" ||
conceptText == "him" || conceptText == "her" || conceptText == "them" ||
@@ -157,8 +157,8 @@ bool TTsentence::fn2(int conceptIndex, const TTstring &str, TTconceptNode *conce
goto exit;
}
- if (g_vm->_exeResources._owner->_concept1P && (conceptIndex == 0 ||
- conceptIndex == 2 || conceptIndex == 3 || conceptIndex == 4 || conceptIndex == 5)) {
+ if (g_vm->_exeResources._owner->_concept1P && (slotIndex == 0 ||
+ slotIndex == 2 || slotIndex == 3 || slotIndex == 4 || slotIndex == 5)) {
if (str == g_vm->_exeResources._owner->_concept2P->getText() &&
(conceptText == "it" || conceptText == "that" || conceptText == "he" ||
conceptText == "she" || conceptText == "him" || conceptText == "her" ||
@@ -167,7 +167,7 @@ bool TTsentence::fn2(int conceptIndex, const TTstring &str, TTconceptNode *conce
goto exit;
}
- if (g_vm->_exeResources._owner->_concept1P && (conceptIndex == 0 || conceptIndex == 2)) {
+ if (g_vm->_exeResources._owner->_concept1P && (slotIndex == 0 || slotIndex == 2)) {
if (conceptText == "?" && str == g_vm->_exeResources._owner->_concept2P->getText()) {
delete concept;
concept = getFrameSlot(5, conceptNode);
@@ -202,12 +202,16 @@ bool TTsentence::fn4(int mode, int wordId, TTconceptNode *node) {
}
}
-TTconcept *TTsentence::getFrameSlot(int conceptIndex, TTconceptNode *conceptNode) {
- TTconcept *newConcept = new TTconcept();
-
+TTconcept *TTsentence::getFrameEntry(int slotIndex, const TTconceptNode *conceptNode) const {
if (!conceptNode)
conceptNode = &_sentenceConcept;
- TTconcept *concept = conceptNode->_concepts[conceptIndex];
+
+ return conceptNode->_concepts[slotIndex];
+}
+
+TTconcept *TTsentence::getFrameSlot(int slotIndex, const TTconceptNode *conceptNode) const {
+ TTconcept *newConcept = new TTconcept();
+ TTconcept *concept = getFrameEntry(slotIndex, conceptNode);
newConcept->copyFrom(concept);
if (!newConcept->isValid()) {
@@ -218,6 +222,15 @@ TTconcept *TTsentence::getFrameSlot(int conceptIndex, TTconceptNode *conceptNode
return newConcept;
}
+bool TTsentence::isFrameSlotClass(int slotIndex, WordClass wordClass, const TTconceptNode *conceptNode) const {
+ TTconcept *concept = getFrameEntry(slotIndex, conceptNode);
+ if (concept && concept->_wordP) {
+ return concept->_wordP->isClass(wordClass);
+ } else {
+ return false;
+ }
+}
+
int TTsentence::is18(int val, const TTconceptNode *node) const {
if (!node)
node = &_sentenceConcept;
diff --git a/engines/titanic/true_talk/tt_sentence.h b/engines/titanic/true_talk/tt_sentence.h
index d168d48a61..f51ca4bdda 100644
--- a/engines/titanic/true_talk/tt_sentence.h
+++ b/engines/titanic/true_talk/tt_sentence.h
@@ -85,7 +85,20 @@ public:
int getStatus() const { return _status; }
- TTconcept *getFrameSlot(int conceptIndex, TTconceptNode *conceptNode);
+ /**
+ * Gets a concept slot
+ */
+ TTconcept *getFrameEntry(int slotIndex, const TTconceptNode *conceptNode = nullptr) const;
+
+ /**
+ * Gets a conecpt slot and returns a duplicate of it
+ */
+ TTconcept *getFrameSlot(int slotIndex, const TTconceptNode *conceptNode = nullptr) const;
+
+ /**
+ * Returns true if the specified slot has an attached word with a given class
+ */
+ bool isFrameSlotClass(int slotIndex, WordClass wordClass, const TTconceptNode *conceptNode = nullptr) const;
/**
* Adds a found vocab word to the list of words representing
@@ -94,7 +107,7 @@ public:
*/
int storeVocabHit(TTword *word);
- bool fn2(int conceptIndex, const TTstring &str, TTconceptNode *conceptNode);
+ bool fn2(int slotIndex, const TTstring &str, TTconceptNode *conceptNode);
bool fn4(int mode, int wordId, TTconceptNode *node);
};