aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorPaul Gilbert2016-06-05 00:10:54 -0400
committerPaul Gilbert2016-07-15 19:20:02 -0400
commit51226842c8f63ffa65c397906ad7aed9dd3d9ca9 (patch)
tree940a185148bc2af5ebff01eb76ed8cad7990345e /engines
parent253cf2f57457d430236a4d972a1d6295511c21fa (diff)
downloadscummvm-rg350-51226842c8f63ffa65c397906ad7aed9dd3d9ca9.tar.gz
scummvm-rg350-51226842c8f63ffa65c397906ad7aed9dd3d9ca9.tar.bz2
scummvm-rg350-51226842c8f63ffa65c397906ad7aed9dd3d9ca9.zip
TITANIC: Start of new TTvocabTree class; added load method
Diffstat (limited to 'engines')
-rw-r--r--engines/titanic/module.mk1
-rw-r--r--engines/titanic/true_talk/true_talk_manager.cpp4
-rw-r--r--engines/titanic/true_talk/true_talk_manager.h2
-rw-r--r--engines/titanic/true_talk/tt_quotes.cpp7
-rw-r--r--engines/titanic/true_talk/tt_quotes.h4
-rw-r--r--engines/titanic/true_talk/tt_quotes_tree.cpp62
-rw-r--r--engines/titanic/true_talk/tt_quotes_tree.h56
7 files changed, 129 insertions, 7 deletions
diff --git a/engines/titanic/module.mk b/engines/titanic/module.mk
index 2b604ec29d..2879713758 100644
--- a/engines/titanic/module.mk
+++ b/engines/titanic/module.mk
@@ -472,6 +472,7 @@ MODULE_OBJS := \
true_talk/tt_picture.o \
true_talk/tt_pronoun.o \
true_talk/tt_quotes.o \
+ true_talk/tt_quotes_tree.o \
true_talk/tt_response.o \
true_talk/tt_room_script.o \
true_talk/tt_script_base.o \
diff --git a/engines/titanic/true_talk/true_talk_manager.cpp b/engines/titanic/true_talk/true_talk_manager.cpp
index 555d0e6a1b..91e6c9e36b 100644
--- a/engines/titanic/true_talk/true_talk_manager.cpp
+++ b/engines/titanic/true_talk/true_talk_manager.cpp
@@ -49,7 +49,9 @@ CTrueTalkManager::CTrueTalkManager(CGameManager *owner) :
_gameManager(owner), _scripts(&_titleEngine), _currentCharId(0),
_dialogueFile(nullptr), _dialogueId(0) {
_titleEngine.setup(3, 3);
- _quotes.load("TEXT/JRQUOTES.TXT");
+ _quotes.load();
+ _quotesTree.load();
+
_currentNPC = nullptr;
g_vm->_trueTalkManager = this;
}
diff --git a/engines/titanic/true_talk/true_talk_manager.h b/engines/titanic/true_talk/true_talk_manager.h
index 754a9955ca..ad378af9fc 100644
--- a/engines/titanic/true_talk/true_talk_manager.h
+++ b/engines/titanic/true_talk/true_talk_manager.h
@@ -28,6 +28,7 @@
#include "titanic/true_talk/dialogue_file.h"
#include "titanic/true_talk/title_engine.h"
#include "titanic/true_talk/tt_quotes.h"
+#include "titanic/true_talk/tt_quotes_tree.h"
#include "titanic/true_talk/tt_scripts.h"
#include "titanic/true_talk/tt_talker.h"
@@ -131,6 +132,7 @@ public:
static void setFlags(int index, int val);
public:
TTquotes _quotes;
+ TTquotesTree _quotesTree;
public:
/**
* Get a specified state value from the currently set NPC
diff --git a/engines/titanic/true_talk/tt_quotes.cpp b/engines/titanic/true_talk/tt_quotes.cpp
index 8e9978bbb9..a2afa1a949 100644
--- a/engines/titanic/true_talk/tt_quotes.cpp
+++ b/engines/titanic/true_talk/tt_quotes.cpp
@@ -37,8 +37,8 @@ TTquotes::~TTquotes() {
delete[] _dataP;
}
-void TTquotes::load(const CString &name) {
- Common::SeekableReadStream *r = g_vm->_filesManager->getResource(name);
+void TTquotes::load() {
+ Common::SeekableReadStream *r = g_vm->_filesManager->getResource("TEXT/JRQUOTES.TXT");
size_t size = r->readUint32LE();
_dataSize = _field544 = size;
@@ -106,7 +106,6 @@ int TTquotes::read(const char *startP, const char *endP) {
return 0;
int maxSize = size + 4;
- bool letterFlag = index != 25;
for (uint idx = 0; idx < letter._entries.size(); ++idx) {
const TTquotesEntry &entry = letter._entries[idx];
@@ -115,7 +114,7 @@ int TTquotes::read(const char *startP, const char *endP) {
const char *srcP = startP;
const char *destP = entry._strP;
- int srcIndex = 0, destIndex = 0;
+ int srcIndex = index != 25 ? 1 : 0, destIndex = 0;
if (*destP) {
do {
if (!srcP[srcIndex]) {
diff --git a/engines/titanic/true_talk/tt_quotes.h b/engines/titanic/true_talk/tt_quotes.h
index db105265ee..a90c70e9cc 100644
--- a/engines/titanic/true_talk/tt_quotes.h
+++ b/engines/titanic/true_talk/tt_quotes.h
@@ -59,9 +59,9 @@ public:
~TTquotes();
/**
- * Load quotes from the specified resource
+ * Load quotes data resource
*/
- void load(const CString &name);
+ void load();
/**
* Test whether a passed string contains one of the quotes,
diff --git a/engines/titanic/true_talk/tt_quotes_tree.cpp b/engines/titanic/true_talk/tt_quotes_tree.cpp
new file mode 100644
index 0000000000..0f10a10aa6
--- /dev/null
+++ b/engines/titanic/true_talk/tt_quotes_tree.cpp
@@ -0,0 +1,62 @@
+/* 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/algorithm.h"
+#include "titanic/true_talk/tt_quotes_tree.h"
+#include "titanic/titanic.h"
+
+namespace Titanic {
+
+/**
+ * Specifies the starting index for each of the three main trees
+ */
+static uint TABLE_INDEXES[3] = { 922, 1015, 1018 };
+
+void TTquotesTree::load() {
+ Common::SeekableReadStream *r = g_vm->_filesManager->getResource("TEXT/TREE");
+
+ for (int idx = 0; idx < QUOTES_TREE_COUNT; ++idx) {
+ TTquotesTree::TTquotesTreeEntry &rec = _entries[idx];
+ assert(r->pos() < r->size());
+
+ rec._id = r->readUint32LE();
+ if (rec._id == 0) {
+ rec._type = ET_END;
+ } else {
+ byte type = r->readByte();
+ if (type == 0) {
+ // Index to sub-table
+ rec._subTable = &_entries[0] + r->readUint32LE();
+ } else {
+ // Read in string for entry
+ char c;
+ while ((c = r->readByte()) != '\0')
+ rec._string += c;
+ }
+ }
+ }
+
+ assert(r->pos() == r->size());
+ delete r;
+}
+
+} // End of namespace Titanic
diff --git a/engines/titanic/true_talk/tt_quotes_tree.h b/engines/titanic/true_talk/tt_quotes_tree.h
new file mode 100644
index 0000000000..9496fa8887
--- /dev/null
+++ b/engines/titanic/true_talk/tt_quotes_tree.h
@@ -0,0 +1,56 @@
+/* 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_QUOTES_TREE_H
+#define TITANIC_TT_QUOTES_TREE_H
+
+#include "common/scummsys.h"
+#include "common/stream.h"
+#include "titanic/support/string.h"
+
+namespace Titanic {
+
+#define QUOTES_TREE_COUNT 1022
+
+enum TreeEntryType { ET_END = 0, ET_TABLE = 1, ET_STRING = 2 };
+
+class TTquotesTree {
+ struct TTquotesTreeEntry {
+ uint _id;
+ TreeEntryType _type;
+ TTquotesTreeEntry *_subTable;
+ CString _string;
+
+ TTquotesTreeEntry() : _id(0), _type(ET_END), _subTable(nullptr) {}
+ };
+private:
+ TTquotesTreeEntry _entries[QUOTES_TREE_COUNT];
+public:
+ /**
+ * Load data for the quotes tree
+ */
+ void load();
+};
+
+} // End of namespace Titanic
+
+#endif /* TITANIC_TT_QUOTES_TREE_H */