aboutsummaryrefslogtreecommitdiff
path: root/engines/titanic/true_talk/tt_quotes_tree.cpp
diff options
context:
space:
mode:
authorPaul Gilbert2016-06-05 14:27:31 -0400
committerPaul Gilbert2016-07-15 19:20:05 -0400
commitbfe075d314f8e9d7010d0f5e60d44bb314e53846 (patch)
tree1465badfec7efda97928b9a57492c36e8b1c0c07 /engines/titanic/true_talk/tt_quotes_tree.cpp
parent51226842c8f63ffa65c397906ad7aed9dd3d9ca9 (diff)
downloadscummvm-rg350-bfe075d314f8e9d7010d0f5e60d44bb314e53846.tar.gz
scummvm-rg350-bfe075d314f8e9d7010d0f5e60d44bb314e53846.tar.bz2
scummvm-rg350-bfe075d314f8e9d7010d0f5e60d44bb314e53846.zip
TITANIC: Further fleshing out of TTquotes and TTquotesTree
Diffstat (limited to 'engines/titanic/true_talk/tt_quotes_tree.cpp')
-rw-r--r--engines/titanic/true_talk/tt_quotes_tree.cpp74
1 files changed, 73 insertions, 1 deletions
diff --git a/engines/titanic/true_talk/tt_quotes_tree.cpp b/engines/titanic/true_talk/tt_quotes_tree.cpp
index 0f10a10aa6..6eee91227a 100644
--- a/engines/titanic/true_talk/tt_quotes_tree.cpp
+++ b/engines/titanic/true_talk/tt_quotes_tree.cpp
@@ -40,7 +40,7 @@ void TTquotesTree::load() {
rec._id = r->readUint32LE();
if (rec._id == 0) {
- rec._type = ET_END;
+ // Nothing needed
} else {
byte type = r->readByte();
if (type == 0) {
@@ -59,4 +59,76 @@ void TTquotesTree::load() {
delete r;
}
+void TTquotesTree::search(const char **str, TTquotesTreeEntry *bTree,
+ TTtreeBuffer *buffer, int quoteId) {
+ buffer->_strP = nullptr;
+ (buffer + 1)->_strP = nullptr;
+
+ bool flag = false;
+ for (uint mode = bTree->_id >> 24; mode != 0;
+ ++bTree, mode = bTree->_id >> 24) {
+
+ switch (mode) {
+ case 1:
+ if (compareWord(str, bTree->_string.c_str()))
+ flag = true;
+ break;
+
+ case 2:
+ compareWord(str, bTree->_string.c_str());
+ break;
+
+ case 5:
+ warning("TODO: TTquotesTree::search");
+ break;
+
+ case 7:
+
+ default:
+ break;
+ }
+
+ if (flag) {
+ // TODO
+ break;
+ }
+ }
+
+}
+
+bool TTquotesTree::compareWord(const char **str, const char *refStr) {
+ // Skip over any spaces
+ const char *strP = *str;
+ while (*strP && *strP == ' ')
+ ++strP;
+ *str = strP;
+
+ // Compare against the reference string
+ while (*strP && *refStr && *refStr != '*') {
+ if (*refStr == '-') {
+ if (*strP == ' ')
+ ++strP;
+ } else if (*strP == *refStr) {
+ ++strP;
+ } else {
+ return false;
+ }
+ }
+
+ if (*refStr && *refStr != '*')
+ return false;
+ if (!*refStr && *strP && *strP != ' ')
+ return false;
+
+ if (*refStr == '*') {
+ // Skip over to the end of the word
+ while (*strP && *strP != ' ')
+ ++strP;
+ }
+
+ // Pass out the new updated string position
+ *str = strP;
+ return true;
+}
+
} // End of namespace Titanic