aboutsummaryrefslogtreecommitdiff
path: root/engines/titanic
diff options
context:
space:
mode:
Diffstat (limited to 'engines/titanic')
-rw-r--r--engines/titanic/true_talk/script_handler.cpp5
-rw-r--r--engines/titanic/true_talk/script_handler.h5
-rw-r--r--engines/titanic/true_talk/tt_concept.cpp32
-rw-r--r--engines/titanic/true_talk/tt_concept.h8
-rw-r--r--engines/titanic/true_talk/tt_parser.cpp7
-rw-r--r--engines/titanic/true_talk/tt_parser.h6
-rw-r--r--engines/titanic/true_talk/tt_word.cpp17
-rw-r--r--engines/titanic/true_talk/tt_word.h10
8 files changed, 82 insertions, 8 deletions
diff --git a/engines/titanic/true_talk/script_handler.cpp b/engines/titanic/true_talk/script_handler.cpp
index 0bc50bd5f9..a5f00868bc 100644
--- a/engines/titanic/true_talk/script_handler.cpp
+++ b/engines/titanic/true_talk/script_handler.cpp
@@ -22,6 +22,7 @@
#include "titanic/true_talk/script_handler.h"
#include "titanic/true_talk/tt_sentence.h"
+#include "titanic/true_talk/tt_parser.h"
#include "titanic/titanic.h"
namespace Titanic {
@@ -91,4 +92,8 @@ SimpleFile *CScriptHandler::openResource(const CString &name) {
return _owner->open(name);
}
+void CScriptHandler::setParserConcept(TTconcept *newConcept, TTconcept *oldConcept) {
+ _parser.conceptChanged(newConcept, oldConcept);
+}
+
} // End of namespace Titanic
diff --git a/engines/titanic/true_talk/script_handler.h b/engines/titanic/true_talk/script_handler.h
index cf5eac1642..0183612210 100644
--- a/engines/titanic/true_talk/script_handler.h
+++ b/engines/titanic/true_talk/script_handler.h
@@ -81,7 +81,10 @@ public:
*/
SimpleFile *openResource(const CString &name);
-
+ /**
+ * Called when concept data is copied from one to another
+ */
+ void setParserConcept(TTconcept *newConcept, TTconcept *oldConcept);
};
} // End of namespace Titanic
diff --git a/engines/titanic/true_talk/tt_concept.cpp b/engines/titanic/true_talk/tt_concept.cpp
index a9794cabe7..cab67c9621 100644
--- a/engines/titanic/true_talk/tt_concept.cpp
+++ b/engines/titanic/true_talk/tt_concept.cpp
@@ -23,6 +23,7 @@
#include "titanic/true_talk/tt_concept.h"
#include "titanic/true_talk/tt_script_base.h"
#include "titanic/true_talk/tt_word.h"
+#include "titanic/titanic.h"
namespace Titanic {
@@ -58,7 +59,7 @@ TTconcept::TTconcept(TTword *word, ScriptType scriptType) :
reset();
}
-TTconcept::TTconcept(const TTconcept &src) :
+TTconcept::TTconcept(TTconcept &src) :
_string1(src._string1), _string2(src._string2),
_wordP(nullptr), _scriptP(nullptr) {
@@ -96,7 +97,7 @@ void TTconcept::setScriptType(ScriptType scriptType) {
_scriptType = scriptType;
_field1C = -1;
_field20 = 0;
- _field2C = 0;
+ _word2 = nullptr;
_field30 = 0;
_field34 = 0;
_field38 = 0;
@@ -124,8 +125,31 @@ bool TTconcept::compareTo(const char *str) const {
_wordP->compareTo(str);
}
-void TTconcept::copyFrom(const TTconcept &src) {
- // TODO
+void TTconcept::copyFrom(TTconcept &src) {
+ _nextP = src._nextP;
+ _field14 = src._field14;
+ _scriptType = src._scriptType;
+ _field1C = src._field1C;
+ _field20 = src._field20;
+
+ if (src._word2) {
+ _word2 = src._word2->copyWords();
+ if (src._word2->getChainStatus())
+ _status = 11;
+ } else {
+ _word2 = nullptr;
+ }
+
+ _field30 = src._field30;
+ _field34 = src._field34;
+
+ if (src._field38 == 1) {
+ g_vm->_exeResources._owner->setParserConcept(this, &src);
+ src.set38(1);
+ _field38 = 1;
+ }
+
+ _status = src._status;
}
} // End of namespace Titanic
diff --git a/engines/titanic/true_talk/tt_concept.h b/engines/titanic/true_talk/tt_concept.h
index 8006e56240..ba48e70369 100644
--- a/engines/titanic/true_talk/tt_concept.h
+++ b/engines/titanic/true_talk/tt_concept.h
@@ -42,7 +42,7 @@ private:
int _field1C;
int _field20;
TTstring _string2;
- int _field2C;
+ TTword *_word2;
int _field30;
int _field34;
int _field38;
@@ -71,14 +71,14 @@ private:
/**
* Copy auxiliary data from the specified source concept
*/
- void copyFrom(const TTconcept &src);
+ void copyFrom(TTconcept &src);
public:
TTconcept *_nextP;
public:
TTconcept();
TTconcept(TTscriptBase *script, ScriptType scriptType);
TTconcept(TTword *word, ScriptType scriptType);
- TTconcept(const TTconcept &src);
+ TTconcept(TTconcept &src);
/**
* Compares the name of the associated word, if any,
@@ -90,6 +90,8 @@ public:
* Return the status of the concept
*/
int getStatus() const { return _status; }
+
+ void set38(int val) { _field38 = val; }
};
} // End of namespace Titanic
diff --git a/engines/titanic/true_talk/tt_parser.cpp b/engines/titanic/true_talk/tt_parser.cpp
index 3a49e291d0..76c979a2a7 100644
--- a/engines/titanic/true_talk/tt_parser.cpp
+++ b/engines/titanic/true_talk/tt_parser.cpp
@@ -895,4 +895,11 @@ int TTparser::checkReferent(TTpronoun *pronoun) {
return 0;
}
+void TTparser::conceptChanged(TTconcept *newConcept, TTconcept *oldConcept) {
+ if (!oldConcept && newConcept != _currentConceptP)
+ _currentConceptP = nullptr;
+ else if (oldConcept && oldConcept == _currentConceptP)
+ _currentConceptP = newConcept;
+}
+
} // End of namespace Titanic
diff --git a/engines/titanic/true_talk/tt_parser.h b/engines/titanic/true_talk/tt_parser.h
index b73dd7655d..84fa1aaa20 100644
--- a/engines/titanic/true_talk/tt_parser.h
+++ b/engines/titanic/true_talk/tt_parser.h
@@ -73,6 +73,7 @@ private:
NumberArray _numbers;
TTparserNode *_nodesP;
TTconcept *_conceptP;
+ TTconcept *_currentConceptP;
private:
/**
* Loads the various replacement string data arrays
@@ -173,6 +174,11 @@ public:
int preprocess(TTsentence *sentence);
int findFrames(TTsentence *sentence);
+
+ /**
+ * Called when a concept is copied from one to another
+ */
+ void conceptChanged(TTconcept *newConcept, TTconcept *oldConcept);
};
} // End of namespace Titanic
diff --git a/engines/titanic/true_talk/tt_word.cpp b/engines/titanic/true_talk/tt_word.cpp
index 24221e12da..c2ce2c1ef4 100644
--- a/engines/titanic/true_talk/tt_word.cpp
+++ b/engines/titanic/true_talk/tt_word.cpp
@@ -210,4 +210,21 @@ void TTword::setSynFile(FileHandle file) {
_synP->_file = file;
}
+TTstringStatus TTword::getChainStatus() const {
+ for (const TTword *word = this; word; word = word->_nextP) {
+ if (word->getStatus())
+ return word->getStatus();
+ }
+
+ return SS_VALID;
+}
+
+TTword *TTword::copyWords() {
+ TTword *result = copy();
+ for (TTword *word = result; word; word = word->_nextP)
+ word->_nextP = word->_nextP->copy();
+
+ return result;
+}
+
} // End of namespace Titanic
diff --git a/engines/titanic/true_talk/tt_word.h b/engines/titanic/true_talk/tt_word.h
index f7550b4c0a..5fa4953be7 100644
--- a/engines/titanic/true_talk/tt_word.h
+++ b/engines/titanic/true_talk/tt_word.h
@@ -125,6 +125,16 @@ public:
TTstringStatus getStatus() const { return _status; }
/**
+ * Return the status of the entire word chain
+ */
+ TTstringStatus getChainStatus() const;
+
+ /**
+ * Copy the word and any attached to it
+ */
+ TTword *copyWords();
+
+ /**
* Creates a copy of the word
*/
virtual TTword *copy();