aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
Diffstat (limited to 'engines')
-rw-r--r--engines/titanic/support/simple_file.cpp43
-rw-r--r--engines/titanic/support/simple_file.h31
-rw-r--r--engines/titanic/true_talk/script_handler.cpp2
-rw-r--r--engines/titanic/true_talk/script_handler.h2
-rw-r--r--engines/titanic/true_talk/true_talk_manager.cpp2
-rw-r--r--engines/titanic/true_talk/tt_action.cpp2
-rw-r--r--engines/titanic/true_talk/tt_action.h4
-rw-r--r--engines/titanic/true_talk/tt_adj.cpp2
-rw-r--r--engines/titanic/true_talk/tt_adj.h15
-rw-r--r--engines/titanic/true_talk/tt_major_word.cpp14
-rw-r--r--engines/titanic/true_talk/tt_major_word.h9
-rw-r--r--engines/titanic/true_talk/tt_picture.cpp33
-rw-r--r--engines/titanic/true_talk/tt_picture.h23
-rw-r--r--engines/titanic/true_talk/tt_pronoun.cpp2
-rw-r--r--engines/titanic/true_talk/tt_pronoun.h11
-rw-r--r--engines/titanic/true_talk/tt_script_base.h2
-rw-r--r--engines/titanic/true_talk/tt_string.cpp31
-rw-r--r--engines/titanic/true_talk/tt_string.h37
-rw-r--r--engines/titanic/true_talk/tt_string_node.h2
-rw-r--r--engines/titanic/true_talk/tt_synonym.cpp27
-rw-r--r--engines/titanic/true_talk/tt_synonym.h7
-rw-r--r--engines/titanic/true_talk/tt_title_script.h2
-rw-r--r--engines/titanic/true_talk/tt_vocab.cpp6
-rw-r--r--engines/titanic/true_talk/tt_vocab.h4
-rw-r--r--engines/titanic/true_talk/tt_word.cpp4
-rw-r--r--engines/titanic/true_talk/tt_word.h50
26 files changed, 263 insertions, 104 deletions
diff --git a/engines/titanic/support/simple_file.cpp b/engines/titanic/support/simple_file.cpp
index 61d941b680..f4351f920f 100644
--- a/engines/titanic/support/simple_file.cpp
+++ b/engines/titanic/support/simple_file.cpp
@@ -73,7 +73,7 @@ size_t SimpleFile::unsafeRead(void *dst, size_t count) {
return _inStream->read(dst, count);
}
-size_t SimpleFile::write(const void *src, size_t count) {
+size_t SimpleFile::write(const void *src, size_t count) const {
assert(_outStream);
return _outStream->write(src, count);
}
@@ -237,12 +237,12 @@ void SimpleFile::readBuffer(char *buffer, size_t count) {
}
}
-void SimpleFile::writeLine(const CString &str) {
+void SimpleFile::writeLine(const CString &str) const {
write(str.c_str(), str.size());
write("\r\n", 2);
}
-void SimpleFile::writeString(const CString &str) {
+void SimpleFile::writeString(const CString &str) const {
if (str.empty())
return;
@@ -279,58 +279,69 @@ void SimpleFile::writeString(const CString &str) {
}
}
-void SimpleFile::writeQuotedString(const CString &str) {
+void SimpleFile::writeQuotedString(const CString &str) const {
write("\"", 1);
writeString(str);
write("\" ", 2);
}
-void SimpleFile::writeQuotedLine(const CString &str, int indent) {
+void SimpleFile::writeQuotedLine(const CString &str, int indent) const {
writeIndent(indent);
writeQuotedString(str);
write("\n", 1);
}
-void SimpleFile::writeNumber(int val) {
+void SimpleFile::writeNumber(int val) const {
CString str = CString::format("%d ", val);
write(str.c_str(), str.size());
}
-void SimpleFile::writeNumberLine(int val, int indent) {
+void SimpleFile::writeNumberLine(int val, int indent) const {
writeIndent(indent);
writeNumber(val);
write("\n", 1);
}
-void SimpleFile::writeFloat(double val) {
+void SimpleFile::writeFloat(double val) const {
Common::String valStr = Common::String::format("%f ", val);
write(valStr.c_str(), valStr.size());
}
-void SimpleFile::writeFloatLine(double val, int indent) {
+void SimpleFile::writeFloatLine(double val, int indent) const {
writeIndent(indent);
writeFloat(val);
write("\n", 1);
}
-void SimpleFile::writePoint(const Point &pt, int indent) {
+void SimpleFile::writePoint(const Point &pt, int indent) const {
writeIndent(indent);
writeNumber(pt.x);
writeNumber(pt.y);
write("\n", 1);
}
-void SimpleFile::writeRect(const Rect &r, int indent) {
+void SimpleFile::writeRect(const Rect &r, int indent) const {
writePoint(Point(r.left, r.top), indent);
writePoint(Point(r.right, r.bottom), indent);
}
-void SimpleFile::writeBounds(const Rect &r, int indent) {
+void SimpleFile::writeBounds(const Rect &r, int indent) const {
writePoint(Point(r.left, r.top), indent);
writePoint(Point(r.width(), r.height()), indent);
}
-void SimpleFile::writeIndent(uint indent) {
+void SimpleFile::writeFormat(const char *format, ...) const {
+ // Convert the format specifier and params to a string
+ va_list va;
+ va_start(va, format);
+ CString line = CString::vformat(format, va);
+ va_end(va);
+
+ // Write out the string
+ write(format, strlen(format));
+}
+
+void SimpleFile::writeIndent(uint indent) const {
for (uint idx = 0; idx < indent; ++idx)
write("\t", 1);
}
@@ -383,7 +394,7 @@ bool SimpleFile::scanf(const char *format, ...) {
*param = readNumber();
if (!eos())
- _inStream->skip(-1);
+ _inStream->seek(-1, SEEK_CUR);
} else if (formatStr.hasPrefix("%s")) {
// Read in text until the next space
formatStr = CString(formatStr.c_str() + 2);
@@ -393,7 +404,7 @@ bool SimpleFile::scanf(const char *format, ...) {
*str += c;
if (!eos())
- _inStream->skip(-1);
+ _inStream->seek(-1, SEEK_CUR);
}
}
@@ -408,7 +419,7 @@ void SimpleFile::skipSpaces() {
safeRead(&c, 1);
if (!eos())
- _inStream->skip(-1);
+ _inStream->seek(-1, SEEK_CUR);
}
/*------------------------------------------------------------------------*/
diff --git a/engines/titanic/support/simple_file.h b/engines/titanic/support/simple_file.h
index 2a4cfdbbc0..cf89e5d72c 100644
--- a/engines/titanic/support/simple_file.h
+++ b/engines/titanic/support/simple_file.h
@@ -89,7 +89,7 @@ public:
/**
* Write out data
*/
- virtual size_t write(const void *src, size_t count);
+ virtual size_t write(const void *src, size_t count) const;
/**
* Read a byte
@@ -139,62 +139,67 @@ public:
/**
* Write a string line
*/
- void writeLine(const CString &str);
+ void writeLine(const CString &str) const;
/**
* Write a string
*/
- void writeString(const CString &str);
+ void writeString(const CString &str) const;
/**
* Write a quoted string
*/
- void writeQuotedString(const CString &str);
+ void writeQuotedString(const CString &str) const;
/**
* Write a quoted string line
*/
- void writeQuotedLine(const CString &str, int indent);
+ void writeQuotedLine(const CString &str, int indent) const;
/**
* Write a number to file
*/
- void writeNumber(int val);
+ void writeNumber(int val) const;
/**
* Write a number line to file
*/
- void writeNumberLine(int val, int indent);
+ void writeNumberLine(int val, int indent) const;
/**
* Write a floating point number
*/
- void writeFloat(double val);
+ void writeFloat(double val) const;
/**
* Write a floating point number as a line
*/
- void writeFloatLine(double val, int indent);
+ void writeFloatLine(double val, int indent) const;
/**
* Write out a point line
*/
- void writePoint(const Point &pt, int indent);
+ void writePoint(const Point &pt, int indent)const;
/**
* Write out a rect line
*/
- void writeRect(const Rect &r, int indent);
+ void writeRect(const Rect &r, int indent) const;
/**
* Write out a bounds line
*/
- void writeBounds(const Rect &r, int indent);
+ void writeBounds(const Rect &r, int indent) const;
+
+ /**
+ * Write out a string using a format specifier, just like fprintf
+ */
+ void writeFormat(const char *format, ...) const;
/**
* Write out a number of tabs to form an indent in the output
*/
- void writeIndent(uint indent);
+ void writeIndent(uint indent) const;
/**
* Validates that the following non-space character is either
diff --git a/engines/titanic/true_talk/script_handler.cpp b/engines/titanic/true_talk/script_handler.cpp
index 65ec60039c..e923c377da 100644
--- a/engines/titanic/true_talk/script_handler.cpp
+++ b/engines/titanic/true_talk/script_handler.cpp
@@ -58,7 +58,7 @@ ScriptChangedResult CScriptHandler::scriptChanged(TTRoomScript *roomScript, TTNp
}
void CScriptHandler::processInput(TTRoomScript *roomScript, TTNpcScript *npcScript,
- const TTString &line) {
+ const TTstring &line) {
if (!roomScript || !line.isValid())
return;
diff --git a/engines/titanic/true_talk/script_handler.h b/engines/titanic/true_talk/script_handler.h
index 7692959e71..2da9371e7d 100644
--- a/engines/titanic/true_talk/script_handler.h
+++ b/engines/titanic/true_talk/script_handler.h
@@ -72,7 +72,7 @@ public:
ScriptChangedResult scriptChanged(TTRoomScript *roomScript, TTNpcScript *npcScript, uint dialogueId);
void processInput(TTRoomScript *roomScript, TTNpcScript *npcScript,
- const TTString &line);
+ const TTstring &line);
/**
* Open a resource for access
diff --git a/engines/titanic/true_talk/true_talk_manager.cpp b/engines/titanic/true_talk/true_talk_manager.cpp
index 4892259341..7743d81509 100644
--- a/engines/titanic/true_talk/true_talk_manager.cpp
+++ b/engines/titanic/true_talk/true_talk_manager.cpp
@@ -310,7 +310,7 @@ void CTrueTalkManager::processInput(CTrueTalkNPC *npc, CTextInputMsg *msg, CView
if (npcScript && roomScript) {
_currentNPC = npc;
_titleEngine._scriptHandler->processInput(roomScript, npcScript,
- TTString(msg->_input));
+ TTstring(msg->_input));
_currentNPC = nullptr;
loadAssets(npc, npcScript->charId());
diff --git a/engines/titanic/true_talk/tt_action.cpp b/engines/titanic/true_talk/tt_action.cpp
index 041f4a27a4..39e31747ee 100644
--- a/engines/titanic/true_talk/tt_action.cpp
+++ b/engines/titanic/true_talk/tt_action.cpp
@@ -26,7 +26,7 @@ namespace Titanic {
bool TTaction::_staticFlag;
-TTaction::TTaction(TTString &str, int val1, int val2, int val3, int val4) :
+TTaction::TTaction(TTstring &str, int val1, int val2, int val3, int val4) :
TTmajorWord(str, val1, val2, val3), _field30(val4) {
}
diff --git a/engines/titanic/true_talk/tt_action.h b/engines/titanic/true_talk/tt_action.h
index 0d0b69a733..822ba4a3a2 100644
--- a/engines/titanic/true_talk/tt_action.h
+++ b/engines/titanic/true_talk/tt_action.h
@@ -33,7 +33,7 @@ private:
protected:
int _field30;
public:
- TTaction(TTString &str, int val1, int val2, int val3, int val4);
+ TTaction(TTstring &str, int val1, int val2, int val3, int val4);
TTaction(TTaction *src);
/**
@@ -45,6 +45,8 @@ public:
* Creates a copy of the word
*/
virtual TTword *copy();
+
+ virtual bool proc12(int val) const { return _field30 == val; }
};
} // End of namespace Titanic
diff --git a/engines/titanic/true_talk/tt_adj.cpp b/engines/titanic/true_talk/tt_adj.cpp
index 5b942131a3..8f62bb8e0a 100644
--- a/engines/titanic/true_talk/tt_adj.cpp
+++ b/engines/titanic/true_talk/tt_adj.cpp
@@ -26,7 +26,7 @@ namespace Titanic {
bool TTadj::_staticFlag;
-TTadj::TTadj(TTString &str, int val1, int val2, int val3, int val4) :
+TTadj::TTadj(TTstring &str, int val1, int val2, int val3, int val4) :
TTmajorWord(str, val1, val2, val3) {
if (val4 >= 0 && val4 <= 9) {
_field30 = val4;
diff --git a/engines/titanic/true_talk/tt_adj.h b/engines/titanic/true_talk/tt_adj.h
index 02d09b56c4..301023ed5e 100644
--- a/engines/titanic/true_talk/tt_adj.h
+++ b/engines/titanic/true_talk/tt_adj.h
@@ -33,7 +33,7 @@ private:
protected:
int _field30;
public:
- TTadj(TTString &str, int val1, int val2, int val3, int val4);
+ TTadj(TTstring &str, int val1, int val2, int val3, int val4);
TTadj(TTadj *src);
/**
@@ -45,6 +45,19 @@ public:
* Creates a copy of the word
*/
virtual TTword *copy();
+
+ virtual bool proc14(int val) const { return _field30 == val; }
+ virtual int proc15() const { return _field30; }
+ virtual bool proc16() const { return _field30 >= 7; }
+ virtual bool proc17() const { return _field30 <= 3; }
+ virtual bool proc18() const { return _field30 > 3 && _field30 < 7; }
+
+ /**
+ * Dumps data associated with the word to file
+ */
+ virtual int save(SimpleFile *file) const {
+ return saveData(file, _field30);
+ }
};
} // End of namespace Titanic
diff --git a/engines/titanic/true_talk/tt_major_word.cpp b/engines/titanic/true_talk/tt_major_word.cpp
index b56a484aa0..68af628dbb 100644
--- a/engines/titanic/true_talk/tt_major_word.cpp
+++ b/engines/titanic/true_talk/tt_major_word.cpp
@@ -26,7 +26,7 @@ namespace Titanic {
bool TTmajorWord::_staticFlag;
-TTmajorWord::TTmajorWord(TTString &str, int val1, int val2, int val3) :
+TTmajorWord::TTmajorWord(TTstring &str, int val1, int val2, int val3) :
TTword(str, val1, val2), _field2C(val3) {
}
@@ -39,6 +39,18 @@ TTmajorWord::TTmajorWord(TTmajorWord *src) : TTword(src) {
}
}
+int TTmajorWord::saveData(SimpleFile *file, int val) const {
+ int result = TTword::save(file);
+ if (!result) {
+ file->writeFormat("%1.0d", val);
+ file->writeFormat("%c", '\n');
+ if (_synP)
+ result = _synP->save(file);
+ }
+
+ return result;
+}
+
TTword *TTmajorWord::copy() {
TTmajorWord *returnWordP = new TTmajorWord(this);
returnWordP->_status = _status;
diff --git a/engines/titanic/true_talk/tt_major_word.h b/engines/titanic/true_talk/tt_major_word.h
index 140419dda2..962fbaab6d 100644
--- a/engines/titanic/true_talk/tt_major_word.h
+++ b/engines/titanic/true_talk/tt_major_word.h
@@ -32,14 +32,21 @@ private:
static bool _staticFlag;
protected:
int _field2C;
+protected:
+ /**
+ * Dumps data for the word to a file
+ */
+ int saveData(SimpleFile *file, int val) const;
public:
- TTmajorWord(TTString &str, int val1, int val2, int val3);
+ TTmajorWord(TTstring &str, int val1, int val2, int val3);
TTmajorWord(TTmajorWord *src);
/**
* Creates a copy of the word
*/
virtual TTword *copy();
+
+ virtual bool proc2(int val) const { return _field2C == val; }
};
} // End of namespace Titanic
diff --git a/engines/titanic/true_talk/tt_picture.cpp b/engines/titanic/true_talk/tt_picture.cpp
index 2cc69a1fe8..6213cd557b 100644
--- a/engines/titanic/true_talk/tt_picture.cpp
+++ b/engines/titanic/true_talk/tt_picture.cpp
@@ -26,20 +26,20 @@ namespace Titanic {
bool TTpicture::_staticFlag;
-TTpicture::TTpicture(TTString &str, int val1, int val2, int val3, int val4, int val5, int val6) :
- TTmajorWord(str, val1, val2, val4), _field34(val3), _field30(val5), _field3C(val6),
+TTpicture::TTpicture(TTstring &str, int val1, int val2, int val3, int val4, int val5, int val6) :
+ TTmajorWord(str, val1, val2, val4), _tag(val3), _field30(val5), _field3C(val6),
_field38(0) {
}
TTpicture::TTpicture(TTpicture *src) : TTmajorWord(src) {
if (getStatus()) {
- _field34 = 0;
+ _tag = 0;
_field30 = 0;
_field38 = 0;
_field3C = 0;
_status = SS_5;
} else {
- _field34 = src->_field34;
+ _tag = src->_tag;
_field30 = src->_field30;
_field38 = src->_field38;
_field3C = src->_field3C;
@@ -51,7 +51,7 @@ int TTpicture::load(SimpleFile *file) {
int val1, val2;
if (!TTword::load(file, 2) && file->scanf("%s %d %d", &str, &val1, &val2)) {
- _field34 = readNumber(str.c_str());
+ _tag = readNumber(str.c_str());
_field30 = val1;
_field3C = val2;
return 0;
@@ -76,4 +76,27 @@ TTword *TTpicture::copy() {
}
}
+bool TTpicture::checkTag() const {
+ return _tag == MKTAG('S', 'E', 'X', 'X') ||
+ _tag == MKTAG('E', 'X', 'C', 'R') ||
+ _tag == MKTAG('P', 'P', 'R', 'T') ||
+ _tag == MKTAG('B', 'L', 'A', 'S');
+}
+
+bool TTpicture::compareTagTo(uint tag) const {
+ return _tag == tag;
+}
+
+uint TTpicture::getTag() const {
+ return _tag;
+}
+
+bool TTpicture::proc9(int val) const {
+ return _field3C == val;
+}
+
+int TTpicture::proc10() const {
+ return _field3C;
+}
+
} // End of namespace Titanic
diff --git a/engines/titanic/true_talk/tt_picture.h b/engines/titanic/true_talk/tt_picture.h
index 1910bc6911..c4cc2c19d3 100644
--- a/engines/titanic/true_talk/tt_picture.h
+++ b/engines/titanic/true_talk/tt_picture.h
@@ -32,11 +32,11 @@ private:
static bool _staticFlag;
protected:
int _field30;
- int _field34;
+ uint _tag;
int _field38;
int _field3C;
public:
- TTpicture(TTString &str, int val1, int val2, int val3, int val4, int val5, int val6);
+ TTpicture(TTstring &str, int val1, int val2, int val3, int val4, int val5, int val6);
TTpicture(TTpicture *src);
/**
@@ -48,6 +48,25 @@ public:
* Creates a copy of the word
*/
virtual TTword *copy();
+
+ /**
+ * Checks whether the word's tag is a known type
+ */
+ virtual bool checkTag() const;
+
+ /**
+ * Compare the word's tag to a given tag value
+ */
+ virtual bool compareTagTo(uint tag) const;
+
+ /**
+ * Return the tag associated with the word
+ */
+ virtual uint getTag() const;
+
+ virtual bool proc9(int val) const;
+ virtual int proc10() const;
+
};
} // End of namespace Titanic
diff --git a/engines/titanic/true_talk/tt_pronoun.cpp b/engines/titanic/true_talk/tt_pronoun.cpp
index 120946bb59..4b20b3341b 100644
--- a/engines/titanic/true_talk/tt_pronoun.cpp
+++ b/engines/titanic/true_talk/tt_pronoun.cpp
@@ -26,7 +26,7 @@ namespace Titanic {
bool TTpronoun::_staticFlag;
-TTpronoun::TTpronoun(TTString &str, int val1, int val2, int val3, int val4) :
+TTpronoun::TTpronoun(TTstring &str, int val1, int val2, int val3, int val4) :
TTmajorWord(str, val1, val2, val3), _field30(val4) {
}
diff --git a/engines/titanic/true_talk/tt_pronoun.h b/engines/titanic/true_talk/tt_pronoun.h
index 8f55a36f07..6bb8113e15 100644
--- a/engines/titanic/true_talk/tt_pronoun.h
+++ b/engines/titanic/true_talk/tt_pronoun.h
@@ -33,7 +33,7 @@ private:
protected:
int _field30;
public:
- TTpronoun(TTString &str, int val1, int val2, int val3, int val4);
+ TTpronoun(TTstring &str, int val1, int val2, int val3, int val4);
TTpronoun(TTpronoun *src);
/**
@@ -45,6 +45,15 @@ public:
* Creates a copy of the word
*/
virtual TTword *copy();
+
+ virtual bool proc19(int val) const { return _field30 == val; }
+
+ /**
+ * Dumps data associated with the word to file
+ */
+ virtual int save(SimpleFile *file) const {
+ return saveData(file, _field30);
+ }
};
} // End of namespace Titanic
diff --git a/engines/titanic/true_talk/tt_script_base.h b/engines/titanic/true_talk/tt_script_base.h
index fe999ab290..dc0db2ceb8 100644
--- a/engines/titanic/true_talk/tt_script_base.h
+++ b/engines/titanic/true_talk/tt_script_base.h
@@ -38,7 +38,7 @@ protected:
int _field4;
int _field8;
int _fieldC;
- TTString _charName, _charClass;
+ TTstring _charName, _charClass;
int _field20;
int _field24;
int _field28;
diff --git a/engines/titanic/true_talk/tt_string.cpp b/engines/titanic/true_talk/tt_string.cpp
index 78ef8222ab..7a39d7163f 100644
--- a/engines/titanic/true_talk/tt_string.cpp
+++ b/engines/titanic/true_talk/tt_string.cpp
@@ -21,23 +21,24 @@
*/
#include "titanic/true_talk/tt_string.h"
+#include "titanic/support/simple_file.h"
namespace Titanic {
-TTString::TTString() : _status(SS_VALID) {
- _data = new TTStringData();
+TTstring::TTstring() : _status(SS_VALID) {
+ _data = new TTstringData();
}
-TTString::TTString(const char *str) : _status(SS_VALID) {
- _data = new TTStringData(str);
+TTstring::TTstring(const char *str) : _status(SS_VALID) {
+ _data = new TTstringData(str);
}
-TTString::TTString(const CString &str) {
+TTstring::TTstring(const CString &str) {
_status = SS_VALID;
- _data = new TTStringData(str);
+ _data = new TTstringData(str);
}
-TTString::TTString(TTString &str) {
+TTstring::TTstring(TTstring &str) {
if (str._status != SS_VALID) {
_status = SS_5;
_data = nullptr;
@@ -48,12 +49,12 @@ TTString::TTString(TTString &str) {
}
}
-TTString::~TTString() {
+TTstring::~TTstring() {
if (_data && --_data->_referenceCount == 0)
delete _data;
}
-void TTString::operator=(const TTString &str) {
+void TTstring::operator=(const TTstring &str) {
// Delete old string reference, if any
if (_data && --_data->_referenceCount == 0)
delete _data;
@@ -65,22 +66,26 @@ void TTString::operator=(const TTString &str) {
_data->_referenceCount++;
}
-void TTString::operator=(const CString &str) {
+void TTstring::operator=(const CString &str) {
operator=(str.c_str());
}
-void TTString::operator=(const char *str) {
+void TTstring::operator=(const char *str) {
// Delete old string reference, if any
if (_data && --_data->_referenceCount == 0)
delete _data;
// Create new string data
- _data = new TTStringData(str);
+ _data = new TTstringData(str);
_status = SS_VALID;
}
-bool TTString::isValid() const {
+bool TTstring::isValid() const {
return _status == SS_VALID;
}
+void TTstring::save(SimpleFile *file) const {
+ file->writeFormat("%s", c_str());
+}
+
} // End of namespace Titanic
diff --git a/engines/titanic/true_talk/tt_string.h b/engines/titanic/true_talk/tt_string.h
index a881c59ecb..0256f1022f 100644
--- a/engines/titanic/true_talk/tt_string.h
+++ b/engines/titanic/true_talk/tt_string.h
@@ -27,29 +27,31 @@
namespace Titanic {
-struct TTStringData {
+class SimpleFile;
+
+struct TTstringData {
CString _string;
int _referenceCount;
- TTStringData() : _referenceCount(1) {}
- TTStringData(const char *str) : _string(str), _referenceCount(1) {}
- TTStringData(const CString &str) : _string(str), _referenceCount(1) {}
+ TTstringData() : _referenceCount(1) {}
+ TTstringData(const char *str) : _string(str), _referenceCount(1) {}
+ TTstringData(const CString &str) : _string(str), _referenceCount(1) {}
};
-enum TTStringStatus { SS_VALID = 0, SS_5 = 5, SS_7 = 7, SS_8 = 8, SS_13 = 13 };
+enum TTstringStatus { SS_VALID = 0, SS_5 = 5, SS_7 = 7, SS_8 = 8, SS_13 = 13 };
-class TTString {
+class TTstring {
private:
- TTStringData *_data;
- TTStringStatus _status;
+ TTstringData *_data;
+ TTstringStatus _status;
public:
- TTString();
- TTString(const char *str);
- TTString(const CString &str);
- TTString(TTString &str);
- virtual ~TTString();
+ TTstring();
+ TTstring(const char *str);
+ TTstring(const CString &str);
+ TTstring(TTstring &str);
+ virtual ~TTstring();
- void operator=(const TTString &str);
+ void operator=(const TTstring &str);
void operator=(const CString &str);
void operator=(const char *str);
@@ -61,7 +63,7 @@ public:
/**
* Get the status of the string
*/
- TTStringStatus getStatus() const { return _status; }
+ TTstringStatus getStatus() const { return _status; }
/**
* Get a char * pointer to the string data
@@ -77,6 +79,11 @@ public:
* Get a character at a specified index
*/
char charAt(int index) const { return *(c_str() + index); }
+
+ /**
+ * Save the sring to a passed file
+ */
+ void save(SimpleFile *file) const;
};
} // 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 6994a0d1cd..f9f73ce545 100644
--- a/engines/titanic/true_talk/tt_string_node.h
+++ b/engines/titanic/true_talk/tt_string_node.h
@@ -47,7 +47,7 @@ protected:
public:
TTstringNode *_pPrior;
TTstringNode *_pNext;
- TTString _string;
+ TTstring _string;
FileHandle _file;
int _mode;
int _field1C;
diff --git a/engines/titanic/true_talk/tt_synonym.cpp b/engines/titanic/true_talk/tt_synonym.cpp
index 3ce3b12ee2..cac9f647cc 100644
--- a/engines/titanic/true_talk/tt_synonym.cpp
+++ b/engines/titanic/true_talk/tt_synonym.cpp
@@ -40,7 +40,7 @@ TTsynonym::TTsynonym(int mode, const char *str, FileHandle file) :
_file = file;
}
-TTsynonym *TTsynonym::findByName(TTsynonym *start, const TTString &str, int mode) {
+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()))
@@ -68,4 +68,29 @@ TTsynonym *TTsynonym::copy(TTsynonym *src) {
}
}
+int TTsynonym::save(SimpleFile *file) {
+ for (TTstringNode *synP = this; synP; synP = synP->_pNext) {
+ file->writeFormat("%s", " 0 ");
+ synP->_string.save(file);
+ file->writeFormat("%c", ' ');
+
+ if (synP->_mode) {
+ file->writeFormat("%1.0d", synP->_mode);
+ } else {
+ file->writeFormat("%c", '0');
+ }
+
+ file->writeFormat("%c", ' ');
+
+ if (synP->_file) {
+ file->writeFormat("%2.0d", synP->_file);
+ } else {
+ file->writeFormat("%c", ' ');
+ }
+ file->writeFormat("%c", '\n');
+ }
+
+ return 0;
+}
+
} // End of namespace Titanic
diff --git a/engines/titanic/true_talk/tt_synonym.h b/engines/titanic/true_talk/tt_synonym.h
index b661c166e0..40f7ad3449 100644
--- a/engines/titanic/true_talk/tt_synonym.h
+++ b/engines/titanic/true_talk/tt_synonym.h
@@ -24,6 +24,7 @@
#define TITANIC_TT_SYNONYM_H
#include "titanic/true_talk/tt_string_node.h"
+#include "titanic/support/simple_file.h"
namespace Titanic {
@@ -41,8 +42,12 @@ public:
/**
* Scan for a synonym with a given string
*/
- static TTsynonym *findByName(TTsynonym *start, const TTString &str, int mode);
+ static TTsynonym *findByName(TTsynonym *start, const TTstring &str, int mode);
+ /**
+ * Save data for the synonym to file
+ */
+ int save(SimpleFile *file);
};
} // End of namespace Titanic
diff --git a/engines/titanic/true_talk/tt_title_script.h b/engines/titanic/true_talk/tt_title_script.h
index 7876ba8a71..a1efd11270 100644
--- a/engines/titanic/true_talk/tt_title_script.h
+++ b/engines/titanic/true_talk/tt_title_script.h
@@ -31,7 +31,7 @@ namespace Titanic {
class TTTitleScript : public TTScriptBase {
private:
int _field50;
- TTString _string1;
+ TTstring _string1;
int _field5C;
int _field60;
public:
diff --git a/engines/titanic/true_talk/tt_vocab.cpp b/engines/titanic/true_talk/tt_vocab.cpp
index 1826a43d08..3d2a9d98c8 100644
--- a/engines/titanic/true_talk/tt_vocab.cpp
+++ b/engines/titanic/true_talk/tt_vocab.cpp
@@ -53,7 +53,7 @@ int TTvocab::load(const CString &name) {
while (!result && !file->eos()) {
skipFlag = false;
int mode = file->readNumber();
- TTString space(" ");
+ TTstring space(" ");
switch (mode) {
case 0: {
@@ -154,7 +154,7 @@ void TTvocab::addWord(TTword *word) {
}
}
-TTword *TTvocab::findWord(const TTString &str) {
+TTword *TTvocab::findWord(const TTstring &str) {
TTsynonym *tempNode = new TTsynonym();
bool flag = false;
TTword *word = _pHead;
@@ -174,7 +174,7 @@ TTword *TTvocab::findWord(const TTString &str) {
return word;
}
-TTword *TTvocab::getPrimeWord(TTString &str, TTword **words) {
+TTword *TTvocab::getPrimeWord(TTstring &str, TTword **words) {
TTsynonym *synonym = new TTsynonym();
char c = str.charAt(0);
TTword *vocabList = _pHead;
diff --git a/engines/titanic/true_talk/tt_vocab.h b/engines/titanic/true_talk/tt_vocab.h
index b7e948680a..804d8cbae3 100644
--- a/engines/titanic/true_talk/tt_vocab.h
+++ b/engines/titanic/true_talk/tt_vocab.h
@@ -52,12 +52,12 @@ private:
/**
* Scans the vocab list for an existing word match
*/
- TTword *findWord(const TTString &str);
+ TTword *findWord(const TTstring &str);
public:
TTvocab(int val);
~TTvocab();
- TTword *getPrimeWord(TTString &str, TTword **words);
+ TTword *getPrimeWord(TTstring &str, TTword **words);
};
} // End of namespace Titanic
diff --git a/engines/titanic/true_talk/tt_word.cpp b/engines/titanic/true_talk/tt_word.cpp
index ea68b3433a..aa602d869c 100644
--- a/engines/titanic/true_talk/tt_word.cpp
+++ b/engines/titanic/true_talk/tt_word.cpp
@@ -26,7 +26,7 @@
namespace Titanic {
-TTword::TTword(TTString &str, int mode, int val2) : _string(str),
+TTword::TTword(TTstring &str, int mode, int val2) : _string(str),
_wordMode(mode), _field1C(val2), _pNext(nullptr), _synP(nullptr),
_field20(0), _field24(0), _field28(0) {
_status = str.getStatus() == SS_VALID ? SS_VALID : SS_5;
@@ -143,7 +143,7 @@ bool TTword::testFileHandle(FileHandle file) const {
return true;
}
-TTword *TTword::scanCopy(const TTString &str, TTsynonym *node, int mode) {
+TTword *TTword::scanCopy(const TTstring &str, TTsynonym *node, int mode) {
if (_synP) {
TTsynonym *strNode = TTsynonym::findByName(_synP, str, mode);
if (strNode) {
diff --git a/engines/titanic/true_talk/tt_word.h b/engines/titanic/true_talk/tt_word.h
index 3d9001bd5d..f77f11ce75 100644
--- a/engines/titanic/true_talk/tt_word.h
+++ b/engines/titanic/true_talk/tt_word.h
@@ -31,7 +31,7 @@ namespace Titanic {
class TTword {
protected:
- TTStringStatus _status;
+ TTstringStatus _status;
int _wordMode;
int _field1C;
int _field20;
@@ -48,9 +48,9 @@ protected:
public:
TTword *_pNext;
TTsynonym *_synP;
- TTString _string;
+ TTstring _string;
public:
- TTword(TTString &str, int mode, int val2);
+ TTword(TTstring &str, int mode, int val2);
TTword(TTword *src);
/**
@@ -73,7 +73,7 @@ public:
*/
int load(SimpleFile *file, int mode);
- TTword *scanCopy(const TTString &str, TTsynonym *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(); }
@@ -81,31 +81,44 @@ public:
/**
* Return the status of the word
*/
- TTStringStatus getStatus() const { return _status; }
+ TTstringStatus getStatus() const { return _status; }
/**
* Creates a copy of the word
*/
virtual TTword *copy();
- virtual int proc2() const { return 0; }
+ virtual bool proc2(int val) const { return false; }
virtual int proc3() const { return -1; }
virtual void proc4() {}
virtual void proc5() {}
- virtual int proc6() const { return 0; }
- virtual int proc7() const { return 0; }
- virtual int proc8() const { return 0; }
- virtual int proc9() const { return 0; }
+
+ /**
+ * Checks whether the word's tag is a known type
+ */
+ virtual bool checkTag() const { return false; }
+
+ /**
+ * Compare the word's tag to a given tag value
+ */
+ virtual bool compareTagTo(uint tag) const { return false; }
+
+ /**
+ * Return the tag associated with the word
+ */
+ virtual uint getTag() const { return 0; }
+
+ virtual bool proc9(int val) const { return false; }
virtual int proc10() const { return 0; }
virtual void proc11() {}
- virtual int proc12() const { return 0; }
+ virtual bool proc12(int val) const { return false; }
virtual int proc13() const { return 0; }
- virtual int proc14() const { return 0; }
+ virtual bool proc14(int val) const { return false; }
virtual int proc15() const { return -1; }
- virtual int proc16() const { return 0; }
- virtual int proc17() const { return 0; }
- virtual int proc18() const { return 0; }
- virtual int proc19() const { return 0; }
+ virtual bool proc16() const { return false; }
+ virtual bool proc17() const { return false; }
+ virtual bool proc18() const { return false; }
+ virtual bool proc19(int val) const { return false; }
virtual int proc20() const { return 0; }
/**
@@ -124,7 +137,10 @@ public:
*/
virtual void setSynFile(FileHandle file);
- virtual int proc24() const { return 0; }
+ /**
+ * Dumps data associated with the word to file
+ */
+ virtual int save(SimpleFile *file) const { return 0; }
};
} // End of namespace Titanic