aboutsummaryrefslogtreecommitdiff
path: root/engines/titanic
diff options
context:
space:
mode:
authorPaul Gilbert2016-05-10 21:27:46 -0400
committerPaul Gilbert2016-07-10 16:39:07 -0400
commit33ef893b04bc218a6149b3ff5b6782655767e60f (patch)
tree4e78dedbf271f851ea0105d2f145de6fc1759d0f /engines/titanic
parent3a464e8770606d75ec7a641eac207b58c95303c1 (diff)
downloadscummvm-rg350-33ef893b04bc218a6149b3ff5b6782655767e60f.tar.gz
scummvm-rg350-33ef893b04bc218a6149b3ff5b6782655767e60f.tar.bz2
scummvm-rg350-33ef893b04bc218a6149b3ff5b6782655767e60f.zip
TITANIC: Implemented vocab findWord
Diffstat (limited to 'engines/titanic')
-rw-r--r--engines/titanic/true_talk/st_vocab.cpp38
-rw-r--r--engines/titanic/true_talk/st_vocab.h12
-rw-r--r--engines/titanic/true_talk/tt_string.h3
-rw-r--r--engines/titanic/true_talk/tt_word.cpp7
-rw-r--r--engines/titanic/true_talk/tt_word.h8
5 files changed, 63 insertions, 5 deletions
diff --git a/engines/titanic/true_talk/st_vocab.cpp b/engines/titanic/true_talk/st_vocab.cpp
index 1b03474292..b5223a0ae5 100644
--- a/engines/titanic/true_talk/st_vocab.cpp
+++ b/engines/titanic/true_talk/st_vocab.cpp
@@ -26,7 +26,7 @@
namespace Titanic {
-STVocab::STVocab(int val): _field0(0), _field4(0), _word(nullptr),
+STVocab::STVocab(int val): _vocab(nullptr), _field4(0), _word(nullptr),
_fieldC(0), _field10(0), _field18(val) {
_field14 = load("STVOCAB.TXT");
}
@@ -98,10 +98,46 @@ int STVocab::load(const CString &name) {
result = 4;
break;
}
+
+ if (!skipFlag && _word) {
+ if (result) {
+ // Something wrong occurred, so delete word
+ delete _word;
+ _word = nullptr;
+ } else {
+ // Add the word to the master vocab list
+ addWord(_word);
+ }
+ }
}
+ // Close resource and return result
delete file;
return result;
}
+void STVocab::addWord(TTword *word) {
+ // TODO
+}
+
+TTword *STVocab::findWord(const TTString &str) {
+ TTsynonymNode *tempNode = new TTsynonymNode();
+ bool flag = false;
+ TTword *word = _vocab;
+
+ while (!flag) {
+ if (_field18 != 3 || strcmp(word->c_str(), str)) {
+ if (word->fn1(str, tempNode, _field18))
+ word = word->_pNext;
+ else
+ flag = true;
+ } else {
+ flag = true;
+ }
+ }
+
+ delete tempNode;
+ return word;
+}
+
} // End of namespace Titanic
diff --git a/engines/titanic/true_talk/st_vocab.h b/engines/titanic/true_talk/st_vocab.h
index c44c4ddda0..19fe0b24a6 100644
--- a/engines/titanic/true_talk/st_vocab.h
+++ b/engines/titanic/true_talk/st_vocab.h
@@ -31,7 +31,7 @@ namespace Titanic {
class STVocab {
private:
- int _field0;
+ TTword *_vocab;
int _field4;
TTword *_word;
int _fieldC;
@@ -43,6 +43,16 @@ private:
* Load the vocab data
*/
int load(const CString &name);
+
+ /**
+ * Adds a specified word to the vocab list
+ */
+ void addWord(TTword *word);
+
+ /**
+ * Scans the vocab list for an existing word match
+ */
+ TTword *findWord(const TTString &str);
public:
STVocab(int val);
};
diff --git a/engines/titanic/true_talk/tt_string.h b/engines/titanic/true_talk/tt_string.h
index c7c88ff2a8..7d231b123a 100644
--- a/engines/titanic/true_talk/tt_string.h
+++ b/engines/titanic/true_talk/tt_string.h
@@ -63,7 +63,8 @@ public:
*/
TTStringStatus getStatus() const { return _status; }
- operator const char *() const { return _data->_string.c_str(); }
+ const char *c_str() const { return _data->_string.c_str(); }
+ operator const char *() const { return c_str(); }
};
} // End of namespace Titanic
diff --git a/engines/titanic/true_talk/tt_word.cpp b/engines/titanic/true_talk/tt_word.cpp
index de987c281f..263b519edd 100644
--- a/engines/titanic/true_talk/tt_word.cpp
+++ b/engines/titanic/true_talk/tt_word.cpp
@@ -27,7 +27,7 @@
namespace Titanic {
TTword::TTword(TTString &str, int mode, int val2) : _string(str),
- _wordMode(mode), _field1C(val2), _fieldC(0), _synP(nullptr),
+ _wordMode(mode), _field1C(val2), _pNext(nullptr), _synP(nullptr),
_field20(0), _field24(0), _field28(0) {
_status = str.getStatus() == SS_VALID ? SS_VALID : SS_5;
}
@@ -92,6 +92,11 @@ bool TTword::testFileHandle(SimpleFile *file) const {
return true;
}
+TTword *TTword::fn1(const TTString &str, TTsynonymNode *node, int val) {
+ // TODO
+ return nullptr;
+}
+
/*------------------------------------------------------------------------*/
TTword1::TTword1(TTString &str, int val1, int val2, int val3) :
diff --git a/engines/titanic/true_talk/tt_word.h b/engines/titanic/true_talk/tt_word.h
index 0d6564a925..589dcf7bbe 100644
--- a/engines/titanic/true_talk/tt_word.h
+++ b/engines/titanic/true_talk/tt_word.h
@@ -32,7 +32,6 @@ namespace Titanic {
class TTword {
protected:
TTString _string;
- int _fieldC;
TTsynonymNode *_synP;
TTStringStatus _status;
int _wordMode;
@@ -48,6 +47,8 @@ protected:
bool testFileHandle(SimpleFile *file) const;
public:
+ TTword *_pNext;
+public:
TTword(TTString &str, int mode, int val2);
/**
@@ -59,6 +60,11 @@ public:
* Load the word
*/
int load(SimpleFile *file, int mode);
+
+ TTword *fn1(const TTString &str, TTsynonymNode *node, int val);
+
+ const char *c_str() const { return _string.c_str(); }
+ operator const char *() const { return c_str(); }
};
class TTword1 : public TTword {