aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--engines/titanic/true_talk/tt_concept.h2
-rw-r--r--engines/titanic/true_talk/tt_concept_node.cpp18
-rw-r--r--engines/titanic/true_talk/tt_concept_node.h5
-rw-r--r--engines/titanic/true_talk/tt_parser.cpp4
-rw-r--r--engines/titanic/true_talk/tt_parser.h2
-rw-r--r--engines/titanic/true_talk/tt_sentence.cpp111
-rw-r--r--engines/titanic/true_talk/tt_sentence.h9
-rw-r--r--engines/titanic/true_talk/tt_string.cpp4
-rw-r--r--engines/titanic/true_talk/tt_string.h4
9 files changed, 151 insertions, 8 deletions
diff --git a/engines/titanic/true_talk/tt_concept.h b/engines/titanic/true_talk/tt_concept.h
index 98a6ee6ea3..7fc56e7345 100644
--- a/engines/titanic/true_talk/tt_concept.h
+++ b/engines/titanic/true_talk/tt_concept.h
@@ -39,7 +39,6 @@ private:
TTword *_wordP;
TTstring _string1;
int _field14;
- ScriptType _scriptType;
int _field1C;
int _field20;
TTstring _string2;
@@ -75,6 +74,7 @@ private:
void initialize(TTconcept &src);
public:
TTconcept *_nextP;
+ ScriptType _scriptType;
public:
TTconcept();
TTconcept(TTscriptBase *script, ScriptType scriptType);
diff --git a/engines/titanic/true_talk/tt_concept_node.cpp b/engines/titanic/true_talk/tt_concept_node.cpp
index 956d87bb68..a98200bce3 100644
--- a/engines/titanic/true_talk/tt_concept_node.cpp
+++ b/engines/titanic/true_talk/tt_concept_node.cpp
@@ -115,6 +115,24 @@ TTconcept **TTconceptNode::setConcept(int conceptIndex, TTconcept *src) {
return conceptPP;
}
+int TTconceptNode::replaceConcept(int mode, int conceptIndex, TTconcept *concept) {
+ TTconcept **conceptPP = setConcept(conceptIndex, concept);
+
+ if (mode == 0 || (mode == 1 && !*conceptPP)) {
+ if (!concept || !concept->isValid())
+ return SS_5;
+
+ if (mode == 0 && *conceptPP) {
+ delete *conceptPP;
+ }
+
+ *conceptPP = new TTconcept(*concept);
+ return (*conceptPP)->isValid() ? SS_VALID : SS_11;
+ } else {
+ return SS_1;
+ }
+}
+
int TTconceptNode::changeConcept(int mode, TTconcept **conceptPP, int conceptIndex) {
TTconcept **newConceptPP = setConcept(conceptIndex, *conceptPP);
diff --git a/engines/titanic/true_talk/tt_concept_node.h b/engines/titanic/true_talk/tt_concept_node.h
index af2fd42e7b..5e49e37abe 100644
--- a/engines/titanic/true_talk/tt_concept_node.h
+++ b/engines/titanic/true_talk/tt_concept_node.h
@@ -58,7 +58,12 @@ public:
bool isValid() const { return _status == SS_VALID; }
TTconcept **setConcept(int conceptIndex, TTconcept *src);
+ int replaceConcept(int mode, int conceptIndex, TTconcept *concept);
int changeConcept(int mode, TTconcept **conceptPP, int conceptIndex);
+
+ int concept1WordId() const {
+ return _concept1P ? _concept1P->getWordId() : 0;
+ }
};
} // End of namespace Titanic
diff --git a/engines/titanic/true_talk/tt_parser.cpp b/engines/titanic/true_talk/tt_parser.cpp
index dd3389337a..c8bee25351 100644
--- a/engines/titanic/true_talk/tt_parser.cpp
+++ b/engines/titanic/true_talk/tt_parser.cpp
@@ -504,7 +504,7 @@ int TTparser::findFrames(TTsentence *sentence) {
}
if (!status) {
- status = fn1();
+ status = checkForAction();
}
delete line;
@@ -888,7 +888,7 @@ void TTparser::removeConcept(TTconcept *concept) {
delete concept;
}
-int TTparser::fn1() {
+int TTparser::checkForAction() {
// TODO
return 0;
}
diff --git a/engines/titanic/true_talk/tt_parser.h b/engines/titanic/true_talk/tt_parser.h
index c8432c2fe9..5d431114ec 100644
--- a/engines/titanic/true_talk/tt_parser.h
+++ b/engines/titanic/true_talk/tt_parser.h
@@ -164,7 +164,7 @@ private:
*/
void removeConcept(TTconcept *concept);
- int fn1();
+ int checkForAction();
int fn2(TTword *word);
bool checkConcept2(TTconcept *concept, int conceptMode);
int filterConcepts(int conceptMode, int conceptIndex);
diff --git a/engines/titanic/true_talk/tt_sentence.cpp b/engines/titanic/true_talk/tt_sentence.cpp
index a78a4efa0e..d269f41b0c 100644
--- a/engines/titanic/true_talk/tt_sentence.cpp
+++ b/engines/titanic/true_talk/tt_sentence.cpp
@@ -107,4 +107,115 @@ int TTsentence::storeVocabHit(TTword *word) {
return 0;
}
+bool TTsentence::fn2(int conceptIndex, const TTstring &str, TTconceptNode *conceptNode) {
+ if (!conceptNode)
+ conceptNode = &_sentenceConcept;
+ TTconcept *concept = getFrameSlot(conceptIndex, conceptNode);
+
+ if (!concept)
+ return str == "isEmpty";
+
+ bool abortFlag = false;
+ switch (concept->_scriptType) {
+ case 1:
+ if (str == "thePlayer")
+ abortFlag = 1;
+ break;
+
+ case 2:
+ if (str == "targetNpc")
+ abortFlag = 1;
+ break;
+
+ case 3:
+ if (str == "otherNpc")
+ abortFlag = 1;
+ break;
+
+ default:
+ break;
+ }
+
+ TTstring conceptText = concept->getText();
+ if (abortFlag || str == conceptText || concept->compareTo(str)) {
+ delete concept;
+ return true;
+ }
+
+ if (conceptIndex == 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 (str == g_vm->_exeResources._owner->_concept2P->getText() &&
+ (conceptText == "it" || conceptText == "he" || conceptText == "she" ||
+ conceptText == "him" || conceptText == "her" || conceptText == "them" ||
+ conceptText == "they"))
+ goto exit;
+ }
+
+ if (g_vm->_exeResources._owner->_concept1P && (conceptIndex == 0 ||
+ conceptIndex == 2 || conceptIndex == 3 || conceptIndex == 4 || conceptIndex == 5)) {
+ if (str == g_vm->_exeResources._owner->_concept2P->getText() &&
+ (conceptText == "it" || conceptText == "that" || conceptText == "he" ||
+ conceptText == "she" || conceptText == "him" || conceptText == "her" ||
+ conceptText == "them" || conceptText == "they" || conceptText == "those" ||
+ conceptText == "1" || conceptText == "thing"))
+ goto exit;
+ }
+
+ if (g_vm->_exeResources._owner->_concept1P && (conceptIndex == 0 || conceptIndex == 2)) {
+ if (conceptText == "?" && str == g_vm->_exeResources._owner->_concept2P->getText()) {
+ delete concept;
+ concept = getFrameSlot(5, conceptNode);
+ conceptText = concept->getText();
+
+ if (conceptText == "it" || conceptText == "that" || conceptText == "he" ||
+ conceptText == "she" || conceptText == "him" || conceptText == "her" ||
+ conceptText == "them" || conceptText == "they" || conceptText == "those" ||
+ conceptText == "1" || conceptText == "thing")
+ abortFlag = true;
+ }
+ }
+
+exit:
+ delete concept;
+ return abortFlag;
+}
+
+bool TTsentence::fn4(int mode, int wordId, TTconcept *concept) {
+ if (!concept)
+ return false;
+
+ switch (mode) {
+ case 1:
+ return _sentenceConcept._concept1P && _sentenceConcept._concept1P->getWordId() == wordId;
+
+ case 5:
+ return _sentenceConcept._concept5P && _sentenceConcept._concept5P->getWordId() == wordId;
+
+ default:
+ return false;
+ }
+}
+
+TTconcept *TTsentence::getFrameSlot(int conceptIndex, TTconceptNode *conceptNode) {
+ TTconcept *newConcept = new TTconcept();
+
+ if (!conceptNode)
+ conceptNode = &_sentenceConcept;
+ TTconcept *concept = conceptNode->_concepts[conceptIndex];
+ newConcept->copyFrom(concept);
+
+ if (!newConcept->isValid()) {
+ delete newConcept;
+ newConcept = nullptr;
+ }
+
+ return newConcept;
+}
+
} // End of namespace Titanic
diff --git a/engines/titanic/true_talk/tt_sentence.h b/engines/titanic/true_talk/tt_sentence.h
index 6cee9705c4..00f31b4f31 100644
--- a/engines/titanic/true_talk/tt_sentence.h
+++ b/engines/titanic/true_talk/tt_sentence.h
@@ -76,15 +76,24 @@ public:
void set34(int v) { _field34 = v; }
void set38(int v) { _field38 = v; }
bool check2C() const { return _field2C > 1 && _field2C <= 10; }
+ int concept18(TTconceptNode *conceptNode) {
+ return conceptNode ? conceptNode->get18() : 0;
+ }
+ int get58() const { return _field58; }
int getStatus() const { return _status; }
+ TTconcept *getFrameSlot(int conceptIndex, TTconceptNode *conceptNode);
+
/**
* Adds a found vocab word to the list of words representing
* the player's input
* @param word Word to node
*/
int storeVocabHit(TTword *word);
+
+ bool fn2(int conceptIndex, const TTstring &str, TTconceptNode *conceptNode);
+ bool fn4(int mode, int wordId, TTconcept *concept);
};
} // End of namespace Titanic
diff --git a/engines/titanic/true_talk/tt_string.cpp b/engines/titanic/true_talk/tt_string.cpp
index 1491937bd5..589141303b 100644
--- a/engines/titanic/true_talk/tt_string.cpp
+++ b/engines/titanic/true_talk/tt_string.cpp
@@ -95,11 +95,11 @@ TTstring &TTstring::operator+=(char c) {
return *this;
}
-bool TTstring::operator==(const TTstring &str) {
+bool TTstring::operator==(const TTstring &str) const {
return _data && str._data && _data->_string == str._data->_string;
}
-bool TTstring::operator==(const char *str) {
+bool TTstring::operator==(const char *str) const {
return _data && _data->_string == str;
}
diff --git a/engines/titanic/true_talk/tt_string.h b/engines/titanic/true_talk/tt_string.h
index 060a48f5b6..b6ec859794 100644
--- a/engines/titanic/true_talk/tt_string.h
+++ b/engines/titanic/true_talk/tt_string.h
@@ -57,8 +57,8 @@ public:
TTstring &operator+=(const char *str);
TTstring &operator+=(const TTstring &str);
TTstring &operator+=(char c);
- bool operator==(const TTstring &str);
- bool operator==(const char *str);
+ bool operator==(const TTstring &str) const;
+ bool operator==(const char *str) const;
const char &operator[](int index) {
return *(c_str() + index);