aboutsummaryrefslogtreecommitdiff
path: root/engines/titanic
diff options
context:
space:
mode:
authorPaul Gilbert2016-05-10 20:51:21 -0400
committerPaul Gilbert2016-07-10 16:39:06 -0400
commit3a464e8770606d75ec7a641eac207b58c95303c1 (patch)
treefc0c34166fd102b119537cfe4fd9cd3ee84dd8f4 /engines/titanic
parenta223309934452ca6652112060aac9bd7272d4ddb (diff)
downloadscummvm-rg350-3a464e8770606d75ec7a641eac207b58c95303c1.tar.gz
scummvm-rg350-3a464e8770606d75ec7a641eac207b58c95303c1.tar.bz2
scummvm-rg350-3a464e8770606d75ec7a641eac207b58c95303c1.zip
TITANIC: Added new TTstringNode and TTsynonymNode classes
Diffstat (limited to 'engines/titanic')
-rw-r--r--engines/titanic/module.mk1
-rw-r--r--engines/titanic/support/file_reader.h2
-rw-r--r--engines/titanic/true_talk/tt_string.cpp4
-rw-r--r--engines/titanic/true_talk/tt_string.h1
-rw-r--r--engines/titanic/true_talk/tt_string_node.cpp74
-rw-r--r--engines/titanic/true_talk/tt_string_node.h65
-rw-r--r--engines/titanic/true_talk/tt_word.cpp32
-rw-r--r--engines/titanic/true_talk/tt_word.h8
8 files changed, 185 insertions, 2 deletions
diff --git a/engines/titanic/module.mk b/engines/titanic/module.mk
index a3d60e7fdb..23354b40f6 100644
--- a/engines/titanic/module.mk
+++ b/engines/titanic/module.mk
@@ -466,6 +466,7 @@ MODULE_OBJS := \
true_talk/tt_npc_script.o \
true_talk/tt_scripts.o \
true_talk/tt_string.o \
+ true_talk/tt_string_node.o \
true_talk/tt_talker.o \
true_talk/tt_title_script.o \
true_talk/tt_word.o
diff --git a/engines/titanic/support/file_reader.h b/engines/titanic/support/file_reader.h
index 7d00ebd80d..42ab43c294 100644
--- a/engines/titanic/support/file_reader.h
+++ b/engines/titanic/support/file_reader.h
@@ -42,6 +42,8 @@ public:
CFileReader();
void reset(CScriptHandler *owner, int val1, int val2);
+
+ bool is18Equals(int val) const { return _field18 == val; }
};
} // End of namespace Titanic
diff --git a/engines/titanic/true_talk/tt_string.cpp b/engines/titanic/true_talk/tt_string.cpp
index 189873daf0..78ef8222ab 100644
--- a/engines/titanic/true_talk/tt_string.cpp
+++ b/engines/titanic/true_talk/tt_string.cpp
@@ -66,6 +66,10 @@ void TTString::operator=(const TTString &str) {
}
void TTString::operator=(const CString &str) {
+ operator=(str.c_str());
+}
+
+void TTString::operator=(const char *str) {
// Delete old string reference, if any
if (_data && --_data->_referenceCount == 0)
delete _data;
diff --git a/engines/titanic/true_talk/tt_string.h b/engines/titanic/true_talk/tt_string.h
index 250f902068..c7c88ff2a8 100644
--- a/engines/titanic/true_talk/tt_string.h
+++ b/engines/titanic/true_talk/tt_string.h
@@ -51,6 +51,7 @@ public:
void operator=(const TTString &str);
void operator=(const CString &str);
+ void operator=(const char *str);
/**
* Returns true if the string is valid
diff --git a/engines/titanic/true_talk/tt_string_node.cpp b/engines/titanic/true_talk/tt_string_node.cpp
new file mode 100644
index 0000000000..b1e2a642e4
--- /dev/null
+++ b/engines/titanic/true_talk/tt_string_node.cpp
@@ -0,0 +1,74 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "common/textconsole.h"
+#include "titanic/true_talk/tt_string_node.h"
+
+namespace Titanic {
+
+TTstringNode::TTstringNode() : _pPrior(nullptr), _pNext(nullptr),
+ _field14(0), _mode(0), _field1C(0) {
+}
+
+void TTstringNode::initialize(int mode) {
+ _mode = mode;
+ _field14 = 0;
+
+ if (_string.isValid()) {
+ _field1C = 0;
+ } else {
+ _field1C = 11;
+ warning("TTstringNode::initialize has bad subobj");
+ }
+}
+
+void TTstringNode::addNode(TTstringNode *newNode) {
+ TTstringNode *tail = getTail();
+ tail->_pNext = newNode;
+ newNode->_pPrior = this;
+}
+
+TTstringNode *TTstringNode::getTail() const {
+ if (_pNext == nullptr)
+ return nullptr;
+
+ TTstringNode *node = _pNext;
+ while (node->_pNext)
+ node = node->_pNext;
+
+ return node;
+}
+
+/*------------------------------------------------------------------------*/
+
+TTsynonymNode::TTsynonymNode() : TTstringNode() {
+}
+
+TTsynonymNode::TTsynonymNode(int mode, const char *str, int val2) :
+ TTstringNode() {
+ _string = str;
+ initialize(mode);
+ _field14 = val2;
+}
+
+
+} // End of namespace Titanic
diff --git a/engines/titanic/true_talk/tt_string_node.h b/engines/titanic/true_talk/tt_string_node.h
new file mode 100644
index 0000000000..e588ea4883
--- /dev/null
+++ b/engines/titanic/true_talk/tt_string_node.h
@@ -0,0 +1,65 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef TITANIC_TT_STRING_NODE_H
+#define TITANIC_TT_STRING_NODE_H
+
+#include "titanic/true_talk/tt_string.h"
+
+namespace Titanic {
+
+class TTstringNode {
+private:
+ /**
+ * Returns the final node at the end of the linked list of nodes
+ */
+ TTstringNode *getTail() const;
+protected:
+ /**
+ * Initializes state for the node
+ */
+ void initialize(int mode);
+public:
+ TTstringNode *_pPrior;
+ TTstringNode *_pNext;
+ TTString _string;
+ int _field14;
+ int _mode;
+ int _field1C;
+public:
+ TTstringNode();
+
+ /**
+ * Links the passed node to this node as a linked list
+ */
+ void addNode(TTstringNode *newNode);
+};
+
+class TTsynonymNode : public TTstringNode {
+public:
+ TTsynonymNode();
+ TTsynonymNode(int mode, const char *str, int val2);
+};
+
+} // End of namespace Titanic
+
+#endif /* TITANIC_TT_STRING_NODE_H */
diff --git a/engines/titanic/true_talk/tt_word.cpp b/engines/titanic/true_talk/tt_word.cpp
index 62f924af6e..de987c281f 100644
--- a/engines/titanic/true_talk/tt_word.cpp
+++ b/engines/titanic/true_talk/tt_word.cpp
@@ -21,16 +21,38 @@
*/
#include "titanic/true_talk/tt_word.h"
+#include "titanic/true_talk/tt_string_node.h"
+#include "titanic/titanic.h"
namespace Titanic {
TTword::TTword(TTString &str, int mode, int val2) : _string(str),
- _wordMode(mode), _field1C(val2), _fieldC(0), _field10(0),
+ _wordMode(mode), _field1C(val2), _fieldC(0), _synP(nullptr),
_field20(0), _field24(0), _field28(0) {
_status = str.getStatus() == SS_VALID ? SS_VALID : SS_5;
}
int TTword::readSyn(SimpleFile *file) {
+ CString str;
+ int mode, val1;
+
+ if (!file->scanf("%s %d %d", &str, &mode, &val1))
+ return 8;
+ if (!testFileHandle(file))
+ return 5;
+
+ // Create new synanym node
+ TTsynonymNode *synNode = new TTsynonymNode(mode, str.c_str(), val1);
+
+ if (_synP) {
+ // A synonym already exists, so add new one as a tail
+ // at the end of the linked list of synonyms
+ _synP->addNode(synNode);
+ } else {
+ // Very first synonym, so set it
+ _synP = synNode;
+ }
+
return 0;
}
@@ -62,6 +84,14 @@ uint TTword::readNumber(const char *str) {
return numValue;
}
+bool TTword::testFileHandle(SimpleFile *file) const {
+ if (g_vm->_fileReader.is18Equals(3))
+ return true;
+
+ // TODO: Figure out why original compares passed file handle against specific values
+ return true;
+}
+
/*------------------------------------------------------------------------*/
TTword1::TTword1(TTString &str, int val1, int val2, int val3) :
diff --git a/engines/titanic/true_talk/tt_word.h b/engines/titanic/true_talk/tt_word.h
index a24099c2ab..0d6564a925 100644
--- a/engines/titanic/true_talk/tt_word.h
+++ b/engines/titanic/true_talk/tt_word.h
@@ -25,6 +25,7 @@
#include "titanic/support/simple_file.h"
#include "titanic/true_talk/tt_string.h"
+#include "titanic/true_talk/tt_string_node.h"
namespace Titanic {
@@ -32,7 +33,7 @@ class TTword {
protected:
TTString _string;
int _fieldC;
- int _field10;
+ TTsynonymNode *_synP;
TTStringStatus _status;
int _wordMode;
int _field1C;
@@ -44,9 +45,14 @@ protected:
* Read in a number
*/
uint readNumber(const char *str);
+
+ bool testFileHandle(SimpleFile *file) const;
public:
TTword(TTString &str, int mode, int val2);
+ /**
+ * Read in a synonym for the given word
+ */
int readSyn(SimpleFile *file);
/**