aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorPaul Gilbert2016-07-26 20:25:44 -0400
committerPaul Gilbert2016-07-26 20:25:44 -0400
commit04931130b49482262f24bf330a698d254690bb90 (patch)
treec2728901970a468619fc57544565458d39b38ef1 /engines
parentde494c8c27ac2ede69f6e73b76fa48c3a9597314 (diff)
downloadscummvm-rg350-04931130b49482262f24bf330a698d254690bb90.tar.gz
scummvm-rg350-04931130b49482262f24bf330a698d254690bb90.tar.bz2
scummvm-rg350-04931130b49482262f24bf330a698d254690bb90.zip
TITANIC: Split NPC script support data structures to their own file
Diffstat (limited to 'engines')
-rw-r--r--engines/titanic/module.mk1
-rw-r--r--engines/titanic/true_talk/script_support.cpp143
-rw-r--r--engines/titanic/true_talk/script_support.h130
-rw-r--r--engines/titanic/true_talk/tt_npc_script.cpp117
-rw-r--r--engines/titanic/true_talk/tt_npc_script.h99
5 files changed, 275 insertions, 215 deletions
diff --git a/engines/titanic/module.mk b/engines/titanic/module.mk
index 60a95bc094..1107fddaf5 100644
--- a/engines/titanic/module.mk
+++ b/engines/titanic/module.mk
@@ -481,6 +481,7 @@ MODULE_OBJS := \
true_talk/succubus_script.o \
true_talk/title_engine.o \
true_talk/script_handler.o \
+ true_talk/script_support.o \
true_talk/true_talk_manager.o \
true_talk/tt_action.o \
true_talk/tt_adj.o \
diff --git a/engines/titanic/true_talk/script_support.cpp b/engines/titanic/true_talk/script_support.cpp
new file mode 100644
index 0000000000..857d774f82
--- /dev/null
+++ b/engines/titanic/true_talk/script_support.cpp
@@ -0,0 +1,143 @@
+/* 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/script_support.h"
+#include "titanic/titanic.h"
+
+namespace Titanic {
+
+int TTnpcScriptResponse::size() const {
+ for (int idx = 0; idx < 4; ++idx) {
+ if (_values[idx] == 0)
+ return idx;
+ }
+
+ return 4;
+}
+
+/*------------------------------------------------------------------------*/
+
+TTscriptRange::TTscriptRange(uint id, const Common::Array<uint> &values,
+ bool isRandom, bool isSequential) :
+ _id(id), _nextP(nullptr) {
+ _mode = SF_NONE;
+ if (isRandom)
+ _mode = SF_RANDOM;
+ if (isSequential)
+ _mode = SF_SEQUENTIAL;
+
+ for (uint idx = 0; idx < values.size(); ++idx)
+ _values.push_back(values[idx]);
+}
+
+/*------------------------------------------------------------------------*/
+
+
+bool TTsentenceEntry::load(Common::SeekableReadStream *s) {
+ if (s->pos() >= s->size())
+ return false;
+
+ _field0 = s->readUint32LE();
+ _field4 = s->readUint32LE();
+ _string8 = readStringFromStream(s);
+ _fieldC = s->readUint32LE();
+ _string10 = readStringFromStream(s);
+ _string14 = readStringFromStream(s);
+ _string18 = readStringFromStream(s);
+ _string1C = readStringFromStream(s);
+ _field20 = s->readUint32LE();
+ _string24 = readStringFromStream(s);
+ _field28 = s->readUint32LE();
+ _field2C = s->readUint32LE();
+ _field30 = s->readUint32LE();
+
+ return true;
+}
+
+/*------------------------------------------------------------------------*/
+
+void TTsentenceEntries::load(const CString &resName) {
+ TTsentenceEntry entry;
+ Common::SeekableReadStream *r = g_vm->_filesManager->getResource(resName);
+
+ while (entry.load(r))
+ push_back(entry);
+
+ delete r;
+}
+
+/*------------------------------------------------------------------------*/
+
+TTscriptMapping::TTscriptMapping() : _id(0) {
+ Common::fill(&_values[0], &_values[8], 0);
+}
+
+/*------------------------------------------------------------------------*/
+
+void TTscriptMappings::load(const char *name, int valuesPerMapping) {
+ Common::SeekableReadStream *r = g_vm->_filesManager->getResource(name);
+ _valuesPerMapping = valuesPerMapping;
+
+ while (r->pos() < r->size()) {
+ resize(size() + 1);
+ TTscriptMapping &m = (*this)[size() - 1];
+
+ m._id = r->readUint32LE();
+ for (int idx = 0; idx < valuesPerMapping; ++idx)
+ m._values[idx] = r->readUint32LE();
+ }
+
+ delete r;
+}
+
+/*------------------------------------------------------------------------*/
+
+void TTtagMappings::load(const char *name) {
+ Common::SeekableReadStream *r = g_vm->_filesManager->getResource(name);
+
+ while (r->pos() < r->size()) {
+ uint src = r->readUint32LE();
+ uint dest = r->readUint32LE();
+
+ push_back(TTtagMapping(src, dest));
+ }
+
+ delete r;
+}
+
+/*------------------------------------------------------------------------*/
+
+void TTwordEntries::load(const char *name) {
+ Common::SeekableReadStream *r = g_vm->_filesManager->getResource(name);
+
+ while (r->pos() < r->size()) {
+ TTwordEntry we;
+ we._id = r->readUint32LE();
+ we._text = readStringFromStream(r);
+
+ push_back(we);
+ }
+
+ delete r;
+}
+
+} // End of namespace Titanic
diff --git a/engines/titanic/true_talk/script_support.h b/engines/titanic/true_talk/script_support.h
new file mode 100644
index 0000000000..c87b553367
--- /dev/null
+++ b/engines/titanic/true_talk/script_support.h
@@ -0,0 +1,130 @@
+/* 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_SCRIPT_SUPPORT_H
+#define TITANIC_SCRIPT_SUPPORT_H
+
+#include "titanic/support/simple_file.h"
+
+namespace Titanic {
+
+#define DIALS_ARRAY_COUNT 10
+
+enum ScriptArrayFlag { SF_NONE = 0, SF_RANDOM = 1, SF_SEQUENTIAL = 2 };
+
+struct TTnpcScriptResponse {
+ uint _tag;
+ uint _values[4];
+
+ /**
+ * Returns the size of the values list plus 1
+ */
+ int size() const;
+};
+
+struct TTscriptRange {
+ uint _id;
+ Common::Array<uint> _values;
+ TTscriptRange *_nextP;
+ uint _priorIndex;
+ ScriptArrayFlag _mode;
+
+ TTscriptRange() : _id(0), _nextP(nullptr),
+ _priorIndex(0), _mode(SF_NONE) {}
+ TTscriptRange(uint id, const Common::Array<uint> &values, bool isRandom,
+ bool isSequential);
+};
+
+
+struct TTsentenceEntry {
+ int _field0;
+ int _field4;
+ CString _string8;
+ int _fieldC;
+ CString _string10;
+ CString _string14;
+ CString _string18;
+ CString _string1C;
+ int _field20;
+ CString _string24;
+ int _field28;
+ int _field2C;
+ int _field30;
+
+ TTsentenceEntry() : _field0(0), _field4(0), _fieldC(0),
+ _field20(0), _field28(0), _field2C(0), _field30(0) {}
+
+ /**
+ * Load an entry from the passed stream, and returns true
+ * if an entry was successfully loaded
+ */
+ bool load(Common::SeekableReadStream *s);
+};
+
+class TTsentenceEntries : public Common::Array<TTsentenceEntry> {
+public:
+ /**
+ * Load a list of entries from the specified resource
+ */
+ void load(const CString &resName);
+};
+
+struct TTscriptMapping {
+ uint _id;
+ uint _values[8];
+
+ TTscriptMapping();
+};
+
+class TTscriptMappings : public Common::Array<TTscriptMapping> {
+public:
+ int _valuesPerMapping;
+
+ void load(const char *name, int valuesPerMapping);
+};
+
+struct TTtagMapping {
+ uint _src, _dest;
+ TTtagMapping() : _src(0), _dest(0) {}
+ TTtagMapping(uint src, uint dest) : _src(src), _dest(dest) {}
+};
+
+class TTtagMappings : public Common::Array<TTtagMapping> {
+public:
+ void load(const char *name);
+};
+
+struct TTwordEntry {
+ uint _id;
+ CString _text;
+
+ TTwordEntry() : _id(0) {}
+};
+
+class TTwordEntries : public Common::Array<TTwordEntry> {
+public:
+ void load(const char *name);
+};
+
+} // End of namespace Titanic
+
+#endif /* TITANIC_TT_NPC_SCRIPT_H */
diff --git a/engines/titanic/true_talk/tt_npc_script.cpp b/engines/titanic/true_talk/tt_npc_script.cpp
index 7a2ab856d8..dde16d15ca 100644
--- a/engines/titanic/true_talk/tt_npc_script.cpp
+++ b/engines/titanic/true_talk/tt_npc_script.cpp
@@ -105,123 +105,6 @@ static const uint RANDOM9[] = {
/*------------------------------------------------------------------------*/
-int TTnpcScriptResponse::size() const {
- for (int idx = 0; idx < 4; ++idx) {
- if (_values[idx] == 0)
- return idx;
- }
-
- return 4;
-}
-
-/*------------------------------------------------------------------------*/
-
-TTscriptRange::TTscriptRange(uint id, const Common::Array<uint> &values,
- bool isRandom, bool isSequential) :
- _id(id), _nextP(nullptr) {
- _mode = SF_NONE;
- if (isRandom)
- _mode = SF_RANDOM;
- if (isSequential)
- _mode = SF_SEQUENTIAL;
-
- for (uint idx = 0; idx < values.size(); ++idx)
- _values.push_back(values[idx]);
-}
-
-/*------------------------------------------------------------------------*/
-
-
-bool TTsentenceEntry::load(Common::SeekableReadStream *s) {
- if (s->pos() >= s->size())
- return false;
-
- _field0 = s->readUint32LE();
- _field4 = s->readUint32LE();
- _string8 = readStringFromStream(s);
- _fieldC = s->readUint32LE();
- _string10 = readStringFromStream(s);
- _string14 = readStringFromStream(s);
- _string18 = readStringFromStream(s);
- _string1C = readStringFromStream(s);
- _field20 = s->readUint32LE();
- _string24 = readStringFromStream(s);
- _field28 = s->readUint32LE();
- _field2C = s->readUint32LE();
- _field30 = s->readUint32LE();
-
- return true;
-}
-
-/*------------------------------------------------------------------------*/
-
-void TTsentenceEntries::load(const CString &resName) {
- TTsentenceEntry entry;
- Common::SeekableReadStream *r = g_vm->_filesManager->getResource(resName);
-
- while (entry.load(r))
- push_back(entry);
-
- delete r;
-}
-
-/*------------------------------------------------------------------------*/
-
-TTscriptMapping::TTscriptMapping() : _id(0) {
- Common::fill(&_values[0], &_values[8], 0);
-}
-
-/*------------------------------------------------------------------------*/
-
-void TTscriptMappings::load(const char *name, int valuesPerMapping) {
- Common::SeekableReadStream *r = g_vm->_filesManager->getResource(name);
- _valuesPerMapping = valuesPerMapping;
-
- while (r->pos() < r->size()) {
- resize(size() + 1);
- TTscriptMapping &m = (*this)[size() - 1];
-
- m._id = r->readUint32LE();
- for (int idx = 0; idx < valuesPerMapping; ++idx)
- m._values[idx] = r->readUint32LE();
- }
-
- delete r;
-}
-
-/*------------------------------------------------------------------------*/
-
-void TTtagMappings::load(const char *name) {
- Common::SeekableReadStream *r = g_vm->_filesManager->getResource(name);
-
- while (r->pos() < r->size()) {
- uint src = r->readUint32LE();
- uint dest = r->readUint32LE();
-
- push_back(TTtagMapping(src, dest));
- }
-
- delete r;
-}
-
-/*------------------------------------------------------------------------*/
-
-void TTwordEntries::load(const char *name) {
- Common::SeekableReadStream *r = g_vm->_filesManager->getResource(name);
-
- while (r->pos() < r->size()) {
- TTwordEntry we;
- we._id = r->readUint32LE();
- we._text = readStringFromStream(r);
-
- push_back(we);
- }
-
- delete r;
-}
-
-/*------------------------------------------------------------------------*/
-
TTnpcScriptBase::TTnpcScriptBase(int charId, const char *charClass, int v2,
const char *charName, int v3, int val2, int v4, int v5, int v6, int v7) :
TTscriptBase(0, charClass, v2, charName, v3, v4, v5, v6, v7),
diff --git a/engines/titanic/true_talk/tt_npc_script.h b/engines/titanic/true_talk/tt_npc_script.h
index 5b992f0675..111298ca27 100644
--- a/engines/titanic/true_talk/tt_npc_script.h
+++ b/engines/titanic/true_talk/tt_npc_script.h
@@ -25,112 +25,15 @@
#include "titanic/support/simple_file.h"
#include "titanic/true_talk/tt_script_base.h"
+#include "titanic/true_talk/script_support.h"
namespace Titanic {
#define DIALS_ARRAY_COUNT 10
-enum ScriptArrayFlag { SF_NONE = 0, SF_RANDOM = 1, SF_SEQUENTIAL = 2 };
-
class CGameManager;
class CPetControl;
class TTroomScript;
-class TTsentence;
-struct TTsentenceEntry;
-
-struct TTnpcScriptResponse {
- uint _tag;
- uint _values[4];
-
- /**
- * Returns the size of the values list plus 1
- */
- int size() const;
-};
-
-struct TTscriptRange {
- uint _id;
- Common::Array<uint> _values;
- TTscriptRange *_nextP;
- uint _priorIndex;
- ScriptArrayFlag _mode;
-
- TTscriptRange() : _id(0), _nextP(nullptr),
- _priorIndex(0), _mode(SF_NONE) {}
- TTscriptRange(uint id, const Common::Array<uint> &values, bool isRandom,
- bool isSequential);
-};
-
-
-struct TTsentenceEntry {
- int _field0;
- int _field4;
- CString _string8;
- int _fieldC;
- CString _string10;
- CString _string14;
- CString _string18;
- CString _string1C;
- int _field20;
- CString _string24;
- int _field28;
- int _field2C;
- int _field30;
-
- TTsentenceEntry() : _field0(0), _field4(0), _fieldC(0),
- _field20(0), _field28(0), _field2C(0), _field30(0) {}
-
- /**
- * Load an entry from the passed stream, and returns true
- * if an entry was successfully loaded
- */
- bool load(Common::SeekableReadStream *s);
-};
-
-class TTsentenceEntries : public Common::Array<TTsentenceEntry> {
-public:
- /**
- * Load a list of entries from the specified resource
- */
- void load(const CString &resName);
-};
-
-struct TTscriptMapping {
- uint _id;
- uint _values[8];
-
- TTscriptMapping();
-};
-
-class TTscriptMappings : public Common::Array<TTscriptMapping> {
-public:
- int _valuesPerMapping;
-
- void load(const char *name, int valuesPerMapping);
-};
-
-struct TTtagMapping {
- uint _src, _dest;
- TTtagMapping() : _src(0), _dest(0) {}
- TTtagMapping(uint src, uint dest) : _src(src), _dest(dest) {}
-};
-
-class TTtagMappings : public Common::Array<TTtagMapping> {
-public:
- void load(const char *name);
-};
-
-struct TTwordEntry {
- uint _id;
- CString _text;
-
- TTwordEntry() : _id(0) {}
-};
-
-class TTwordEntries : public Common::Array<TTwordEntry> {
-public:
- void load(const char *name);
-};
class TTnpcScriptBase : public TTscriptBase {
protected: