aboutsummaryrefslogtreecommitdiff
path: root/engines/titanic
diff options
context:
space:
mode:
Diffstat (limited to 'engines/titanic')
-rw-r--r--engines/titanic/module.mk1
-rw-r--r--engines/titanic/true_talk/st_vocab.cpp2
-rw-r--r--engines/titanic/true_talk/tt_string_node.cpp46
-rw-r--r--engines/titanic/true_talk/tt_string_node.h14
-rw-r--r--engines/titanic/true_talk/tt_synonym.cpp71
-rw-r--r--engines/titanic/true_talk/tt_synonym.h47
-rw-r--r--engines/titanic/true_talk/tt_word.cpp8
-rw-r--r--engines/titanic/true_talk/tt_word.h8
8 files changed, 128 insertions, 69 deletions
diff --git a/engines/titanic/module.mk b/engines/titanic/module.mk
index 23354b40f6..42103e77da 100644
--- a/engines/titanic/module.mk
+++ b/engines/titanic/module.mk
@@ -467,6 +467,7 @@ MODULE_OBJS := \
true_talk/tt_scripts.o \
true_talk/tt_string.o \
true_talk/tt_string_node.o \
+ true_talk/tt_synonym.o \
true_talk/tt_talker.o \
true_talk/tt_title_script.o \
true_talk/tt_word.o
diff --git a/engines/titanic/true_talk/st_vocab.cpp b/engines/titanic/true_talk/st_vocab.cpp
index 138af06854..084393bf87 100644
--- a/engines/titanic/true_talk/st_vocab.cpp
+++ b/engines/titanic/true_talk/st_vocab.cpp
@@ -141,7 +141,7 @@ void STVocab::addWord(TTword *word) {
}
TTword *STVocab::findWord(const TTString &str) {
- TTsynonymNode *tempNode = new TTsynonymNode();
+ TTsynonym *tempNode = new TTsynonym();
bool flag = false;
TTword *word = _pHead;
diff --git a/engines/titanic/true_talk/tt_string_node.cpp b/engines/titanic/true_talk/tt_string_node.cpp
index 95b6465137..cf01ac6063 100644
--- a/engines/titanic/true_talk/tt_string_node.cpp
+++ b/engines/titanic/true_talk/tt_string_node.cpp
@@ -59,17 +59,6 @@ void TTstringNode::initialize(TTstringNode *oldNode) {
delete oldNode;
}
-TTstringNode *TTstringNode::scan(TTstringNode *start, const TTString &str, int mode) {
- for (; start; start = start->_pNext) {
- if (start->_mode == mode || (mode == 3 && start->_mode < 3)) {
- if (!strcmp(start->_string.c_str(), str.c_str()))
- start;
- }
- }
-
- return nullptr;
-}
-
void TTstringNode::addNode(TTstringNode *newNode) {
TTstringNode *tail = getTail();
tail->_pNext = newNode;
@@ -95,39 +84,4 @@ TTstringNode *TTstringNode::getTail() {
return node;
}
-/*------------------------------------------------------------------------*/
-
-TTsynonymNode::TTsynonymNode() : TTstringNode() {
-}
-
-TTsynonymNode::TTsynonymNode(const TTstringNode *src) {
- _string = src->_string;
- initialize(src->_mode);
- _field14 = src->_field14;
-}
-
-TTsynonymNode::TTsynonymNode(int mode, const char *str, int val2) :
- TTstringNode() {
- _string = str;
- initialize(mode);
- _field14 = val2;
-}
-
-TTsynonymNode *TTsynonymNode::copy(TTstringNode *src) {
- if (src->_field1C) {
- _field1C = 5;
- return this;
- } else {
- _field1C = 0;
- if (src == this)
- return this;
-
- _string = src->_string;
- TTsynonymNode *newNode = new TTsynonymNode(src);
- initialize(newNode);
-
- return this;
- }
-}
-
} // End of namespace Titanic
diff --git a/engines/titanic/true_talk/tt_string_node.h b/engines/titanic/true_talk/tt_string_node.h
index 2c6a4e148d..dddef8db0f 100644
--- a/engines/titanic/true_talk/tt_string_node.h
+++ b/engines/titanic/true_talk/tt_string_node.h
@@ -63,20 +63,6 @@ public:
* Detaches a node from any predecessor and/or successor
*/
void detach();
-
- /**
- * Scan for a node with a given string
- */
- static TTstringNode *scan(TTstringNode *start, const TTString &str, int mode);
-};
-
-class TTsynonymNode : public TTstringNode {
-public:
- TTsynonymNode();
- TTsynonymNode(const TTstringNode *src);
- TTsynonymNode(int mode, const char *str, int val2);
-
- TTsynonymNode *copy(TTstringNode *src);
};
} // End of namespace Titanic
diff --git a/engines/titanic/true_talk/tt_synonym.cpp b/engines/titanic/true_talk/tt_synonym.cpp
new file mode 100644
index 0000000000..5da124ab27
--- /dev/null
+++ b/engines/titanic/true_talk/tt_synonym.cpp
@@ -0,0 +1,71 @@
+/* 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 "titanic/true_talk/tt_synonym.h"
+
+namespace Titanic {
+
+TTsynonym::TTsynonym() : TTstringNode() {
+}
+
+TTsynonym::TTsynonym(const TTstringNode *src) {
+ _string = src->_string;
+ initialize(src->_mode);
+ _field14 = src->_field14;
+}
+
+TTsynonym::TTsynonym(int mode, const char *str, int val2) :
+ TTstringNode() {
+ _string = str;
+ initialize(mode);
+ _field14 = val2;
+}
+
+TTsynonym *TTsynonym::findByName(TTsynonym *start, const TTString &str, int mode) {
+ for (; start; start = static_cast<TTsynonym *>(start->_pNext)) {
+ if (start->_mode == mode || (mode == 3 && start->_mode < 3)) {
+ if (!strcmp(start->_string.c_str(), str.c_str()))
+ start;
+ }
+ }
+
+ return nullptr;
+}
+
+TTsynonym *TTsynonym::copy(TTstringNode *src) {
+ if (src->_field1C) {
+ _field1C = 5;
+ return this;
+ } else {
+ _field1C = 0;
+ if (src == this)
+ return this;
+
+ _string = src->_string;
+ TTsynonym *newNode = new TTsynonym(src);
+ initialize(newNode);
+
+ return this;
+ }
+}
+
+} // End of namespace Titanic
diff --git a/engines/titanic/true_talk/tt_synonym.h b/engines/titanic/true_talk/tt_synonym.h
new file mode 100644
index 0000000000..6a20ef37a4
--- /dev/null
+++ b/engines/titanic/true_talk/tt_synonym.h
@@ -0,0 +1,47 @@
+/* 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_SYNONYM_H
+#define TITANIC_TT_SYNONYM_H
+
+#include "titanic/true_talk/tt_string_node.h"
+
+namespace Titanic {
+
+class TTsynonym : public TTstringNode {
+public:
+ TTsynonym();
+ TTsynonym(const TTstringNode *src);
+ TTsynonym(int mode, const char *str, int val2);
+
+ TTsynonym *copy(TTstringNode *src);
+
+ /**
+ * Scan for a synonym with a given string
+ */
+ static TTsynonym *findByName(TTsynonym *start, const TTString &str, int mode);
+
+};
+
+} // End of namespace Titanic
+
+#endif /* TITANIC_TT_SYNONYM_H */
diff --git a/engines/titanic/true_talk/tt_word.cpp b/engines/titanic/true_talk/tt_word.cpp
index 3fa5381684..431a1d8767 100644
--- a/engines/titanic/true_talk/tt_word.cpp
+++ b/engines/titanic/true_talk/tt_word.cpp
@@ -42,7 +42,7 @@ int TTword::readSyn(SimpleFile *file) {
return 5;
// Create new synanym node
- TTsynonymNode *synNode = new TTsynonymNode(mode, str.c_str(), val1);
+ TTsynonym *synNode = new TTsynonym(mode, str.c_str(), val1);
if (_synP) {
// A synonym already exists, so add new one as a tail
@@ -56,7 +56,7 @@ int TTword::readSyn(SimpleFile *file) {
return 0;
}
-void TTword::appendNode(TTsynonymNode *node) {
+void TTword::appendNode(TTsynonym *node) {
if (_synP)
_synP->addNode(node);
else
@@ -99,9 +99,9 @@ bool TTword::testFileHandle(SimpleFile *file) const {
return true;
}
-TTword *TTword::scanCopy(const TTString &str, TTsynonymNode *node, int mode) {
+TTword *TTword::scanCopy(const TTString &str, TTsynonym *node, int mode) {
if (_synP) {
- TTstringNode *strNode = _synP->scan(_synP, str, mode);
+ TTstringNode *strNode = TTsynonym::findByName(_synP, str, mode);
if (strNode) {
node->copy(strNode);
node->_pPrior = nullptr;
diff --git a/engines/titanic/true_talk/tt_word.h b/engines/titanic/true_talk/tt_word.h
index a535cac834..850b6957f8 100644
--- a/engines/titanic/true_talk/tt_word.h
+++ b/engines/titanic/true_talk/tt_word.h
@@ -25,7 +25,7 @@
#include "titanic/support/simple_file.h"
#include "titanic/true_talk/tt_string.h"
-#include "titanic/true_talk/tt_string_node.h"
+#include "titanic/true_talk/tt_synonym.h"
namespace Titanic {
@@ -46,7 +46,7 @@ protected:
bool testFileHandle(SimpleFile *file) const;
public:
TTword *_pNext;
- TTsynonymNode *_synP;
+ TTsynonym *_synP;
TTString _string;
public:
TTword(TTString &str, int mode, int val2);
@@ -59,14 +59,14 @@ public:
/**
* Either sets the first synonym for a word, or adds it to an existing one
*/
- void appendNode(TTsynonymNode *node);
+ void appendNode(TTsynonym *node);
/**
* Load the word
*/
int load(SimpleFile *file, int mode);
- TTword *scanCopy(const TTString &str, TTsynonymNode *node, int mode);
+ TTword *scanCopy(const TTString &str, TTsynonym *node, int mode);
const char *c_str() const { return _string.c_str(); }
operator const char *() const { return c_str(); }