aboutsummaryrefslogtreecommitdiff
path: root/engines/titanic/true_talk
diff options
context:
space:
mode:
authorPaul Gilbert2016-05-21 16:23:52 -0400
committerPaul Gilbert2016-07-15 19:13:47 -0400
commit886b71048470986102ce2edf7baffc637134ac49 (patch)
treec4217ef179c6dfebbe4d110d1450ff21efc832cb /engines/titanic/true_talk
parentdacfbe6a0e08325d4ddb46937c30a2905d2b79de (diff)
downloadscummvm-rg350-886b71048470986102ce2edf7baffc637134ac49.tar.gz
scummvm-rg350-886b71048470986102ce2edf7baffc637134ac49.tar.bz2
scummvm-rg350-886b71048470986102ce2edf7baffc637134ac49.zip
TITANIC: Implemented TTparser checkReferent
Diffstat (limited to 'engines/titanic/true_talk')
-rw-r--r--engines/titanic/true_talk/script_handler.h2
-rw-r--r--engines/titanic/true_talk/tt_concept.cpp23
-rw-r--r--engines/titanic/true_talk/tt_concept.h10
-rw-r--r--engines/titanic/true_talk/tt_parser.cpp35
-rw-r--r--engines/titanic/true_talk/tt_parser.h6
-rw-r--r--engines/titanic/true_talk/tt_pronoun.h2
-rw-r--r--engines/titanic/true_talk/tt_sentence.h4
7 files changed, 74 insertions, 8 deletions
diff --git a/engines/titanic/true_talk/script_handler.h b/engines/titanic/true_talk/script_handler.h
index 891a40f527..cf5eac1642 100644
--- a/engines/titanic/true_talk/script_handler.h
+++ b/engines/titanic/true_talk/script_handler.h
@@ -50,7 +50,6 @@ public:
class CScriptHandler {
private:
CTitleEngine *_owner;
- TTscriptBase *_script;
CExeResources &_resources;
int _field10;
CScriptHandlerSub1 _sub1;
@@ -63,6 +62,7 @@ private:
int _field30;
public:
TTvocab *_vocab;
+ TTscriptBase *_script;
public:
CScriptHandler(CTitleEngine *owner, int val1, int val2);
~CScriptHandler();
diff --git a/engines/titanic/true_talk/tt_concept.cpp b/engines/titanic/true_talk/tt_concept.cpp
index af0a148ce4..bc2da4c936 100644
--- a/engines/titanic/true_talk/tt_concept.cpp
+++ b/engines/titanic/true_talk/tt_concept.cpp
@@ -43,6 +43,21 @@ TTconcept::TTconcept(TTscriptBase *script, ScriptType scriptType) :
reset();
}
+TTconcept::TTconcept(TTword *word, ScriptType scriptType) :
+ _string1(" "), _string2(" "), _wordP(nullptr), _scriptP(nullptr) {
+
+ if (!word || !setStatus() || word->getStatus()) {
+ _status = SS_5;
+ } else {
+ _status = initializeWordRef(word);
+ if (!_status)
+ setScriptType(scriptType);
+ }
+
+ if (_status)
+ reset();
+}
+
bool TTconcept::setStatus() {
if (_string1.isValid() && _string2.isValid()) {
_status = SS_VALID;
@@ -54,7 +69,7 @@ bool TTconcept::setStatus() {
}
void TTconcept::setScriptType(ScriptType scriptType) {
- _field0 = 0;
+ _nextP = nullptr;
_field14 = 0;
_scriptType = scriptType;
_field1C = -1;
@@ -66,6 +81,12 @@ void TTconcept::setScriptType(ScriptType scriptType) {
_status = 0;
}
+int TTconcept::initializeWordRef(TTword *word) {
+ delete _wordP;
+ _wordP = word;
+ return 0;
+}
+
void TTconcept::reset() {
delete _wordP;
_wordP = nullptr;
diff --git a/engines/titanic/true_talk/tt_concept.h b/engines/titanic/true_talk/tt_concept.h
index 08b748e8c7..787013e6c3 100644
--- a/engines/titanic/true_talk/tt_concept.h
+++ b/engines/titanic/true_talk/tt_concept.h
@@ -34,7 +34,6 @@ class TTword;
class TTconcept {
private:
- int _field0;
TTscriptBase *_scriptP;
TTword *_wordP;
TTstring _string1;
@@ -60,13 +59,20 @@ private:
void setScriptType(ScriptType scriptType);
/**
+ * Sets up the concept for a word reference
+ */
+ int initializeWordRef(TTword *word);
+
+ /**
* Resets the concept
*/
void reset();
public:
+ TTconcept *_nextP;
+public:
TTconcept();
TTconcept(TTscriptBase *script, ScriptType scriptType);
-
+ TTconcept(TTword *word, ScriptType scriptType);
};
} // End of namespace Titanic
diff --git a/engines/titanic/true_talk/tt_parser.cpp b/engines/titanic/true_talk/tt_parser.cpp
index b81d3cc3bc..9bc129b807 100644
--- a/engines/titanic/true_talk/tt_parser.cpp
+++ b/engines/titanic/true_talk/tt_parser.cpp
@@ -23,6 +23,7 @@
#include "titanic/true_talk/tt_parser.h"
#include "titanic/true_talk/script_handler.h"
#include "titanic/true_talk/tt_action.h"
+#include "titanic/true_talk/tt_concept.h"
#include "titanic/true_talk/tt_sentence.h"
#include "titanic/true_talk/tt_word.h"
#include "titanic/titanic.h"
@@ -31,7 +32,7 @@ namespace Titanic {
TTparser::TTparser(CScriptHandler *owner) : _owner(owner), _sentenceSub(nullptr),
_sentence(nullptr), _fieldC(0), _field10(0), _field14(0), _field18(0),
- _nodesP(nullptr) {
+ _nodesP(nullptr), _conceptP(nullptr) {
loadArrays();
}
@@ -646,6 +647,17 @@ void TTparser::addNode(uint tag) {
_nodesP = newNode;
}
+int TTparser::addConcept(TTconcept *concept) {
+ if (!concept)
+ return SS_5;
+
+ if (_conceptP)
+ concept->_nextP = _conceptP;
+ _conceptP = concept;
+
+ return SS_VALID;
+}
+
int TTparser::fn2(TTword *word) {
switch (word->_id) {
case 600:
@@ -670,7 +682,26 @@ int TTparser::fn2(TTword *word) {
}
int TTparser::checkReferent(TTpronoun *pronoun) {
- // TODO
+ TTconcept *concept;
+
+ switch (pronoun->getVal()) {
+ case 0:
+ return 0;
+
+ case 1:
+ concept = new TTconcept(_owner->_script, ST_ROOM_SCRIPT);
+ break;
+
+ case 2:
+ concept = new TTconcept(_sentence->_npcScript, ST_NPC_SCRIPT);
+ break;
+
+ default:
+ concept = new TTconcept(pronoun, (ScriptType)pronoun->getVal());
+ break;
+ }
+
+ addConcept(concept);
return 0;
}
diff --git a/engines/titanic/true_talk/tt_parser.h b/engines/titanic/true_talk/tt_parser.h
index 07af2dd59c..7ad87cc138 100644
--- a/engines/titanic/true_talk/tt_parser.h
+++ b/engines/titanic/true_talk/tt_parser.h
@@ -33,6 +33,7 @@ namespace Titanic {
enum NumberFlag { NF_1 = 1, NF_2 = 2, NF_4 = 4, NF_8 = 8, NF_10 = 0x10 };
class CScriptHandler;
+class TTconcept;
struct NumberEntry {
CString _text;
@@ -61,6 +62,7 @@ private:
StringArray _phrases;
NumberArray _numbers;
TTparserNode *_nodesP;
+ TTconcept *_conceptP;
private:
/**
* Loads the various replacement string data arrays
@@ -134,6 +136,10 @@ private:
*/
void addNode(uint tag);
+ /**
+ * Add a concept node
+ */
+ int addConcept(TTconcept *concept);
public:
CScriptHandler *_owner;
TTsentenceSub *_sentenceSub;
diff --git a/engines/titanic/true_talk/tt_pronoun.h b/engines/titanic/true_talk/tt_pronoun.h
index 5aa3e1e8fe..bd80852a8f 100644
--- a/engines/titanic/true_talk/tt_pronoun.h
+++ b/engines/titanic/true_talk/tt_pronoun.h
@@ -41,6 +41,8 @@ public:
*/
int load(SimpleFile *file);
+ int getVal() const { return _field30; }
+
/**
* Creates a copy of the word
*/
diff --git a/engines/titanic/true_talk/tt_sentence.h b/engines/titanic/true_talk/tt_sentence.h
index 902ad102ce..a75742181b 100644
--- a/engines/titanic/true_talk/tt_sentence.h
+++ b/engines/titanic/true_talk/tt_sentence.h
@@ -76,8 +76,6 @@ private:
int _field34;
int _field38;
TTsentenceNode *_nodesP;
- TTroomScript *_roomScript;
- TTnpcScript *_npcScript;
int _field5C;
int _status;
private:
@@ -90,6 +88,8 @@ public:
TTstring _initialLine;
TTstring _normalizedLine;
int _field58;
+ TTroomScript *_roomScript;
+ TTnpcScript *_npcScript;
public:
TTsentence(int inputCtr, const TTstring &line, CScriptHandler *owner,
TTroomScript *roomScript, TTnpcScript *npcScript);