aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorPaul Gilbert2016-05-18 23:24:50 -0400
committerPaul Gilbert2016-07-15 19:13:12 -0400
commit72add4230f881a8e2cb57475eda9692242f59611 (patch)
tree09577488f58bf1cb57c5b8d87a61d09cf3b1b4ca /engines
parent6fdaa608f1e78dac127acb38f634294d58b78415 (diff)
downloadscummvm-rg350-72add4230f881a8e2cb57475eda9692242f59611.tar.gz
scummvm-rg350-72add4230f881a8e2cb57475eda9692242f59611.tar.bz2
scummvm-rg350-72add4230f881a8e2cb57475eda9692242f59611.zip
TITANIC: Finished TTvocab getPrefixedWord
Diffstat (limited to 'engines')
-rw-r--r--engines/titanic/true_talk/tt_parser.cpp2
-rw-r--r--engines/titanic/true_talk/tt_string.h2
-rw-r--r--engines/titanic/true_talk/tt_synonym.cpp5
-rw-r--r--engines/titanic/true_talk/tt_synonym.h1
-rw-r--r--engines/titanic/true_talk/tt_vocab.cpp57
-rw-r--r--engines/titanic/true_talk/tt_vocab.h8
-rw-r--r--engines/titanic/true_talk/tt_word.cpp14
-rw-r--r--engines/titanic/true_talk/tt_word.h14
8 files changed, 85 insertions, 18 deletions
diff --git a/engines/titanic/true_talk/tt_parser.cpp b/engines/titanic/true_talk/tt_parser.cpp
index 1658a27b55..efed166a6b 100644
--- a/engines/titanic/true_talk/tt_parser.cpp
+++ b/engines/titanic/true_talk/tt_parser.cpp
@@ -474,7 +474,7 @@ int TTparser::findFrames(TTsentence *sentence) {
TTstring wordString;
for (;;) {
// Keep stripping words off the start of the passed input
- TTstring wordString = line->tokenize(" \n");
+ wordString = line->tokenize(" \n");
if (wordString.empty())
break;
diff --git a/engines/titanic/true_talk/tt_string.h b/engines/titanic/true_talk/tt_string.h
index 3cc1e5ec40..faf1d6dc71 100644
--- a/engines/titanic/true_talk/tt_string.h
+++ b/engines/titanic/true_talk/tt_string.h
@@ -86,7 +86,7 @@ public:
bool hasPrefix(const CString &str) const {
return _data->_string.hasPrefix(str);
}
- bool hasPrefix(const const char *str) const {
+ bool hasPrefix(const char *str) const {
return _data->_string.hasPrefix(str);
}
bool hasSuffix(const CString &str) const {
diff --git a/engines/titanic/true_talk/tt_synonym.cpp b/engines/titanic/true_talk/tt_synonym.cpp
index 636b4438f1..0f56c5cb22 100644
--- a/engines/titanic/true_talk/tt_synonym.cpp
+++ b/engines/titanic/true_talk/tt_synonym.cpp
@@ -42,6 +42,11 @@ TTsynonym::TTsynonym(int mode, const char *str, FileHandle file) :
_file = file;
}
+TTsynonym::TTsynonym(int mode, TTstring *str) : TTstringNode() {
+ _string = *str;
+ initialize(mode);
+}
+
TTsynonym *TTsynonym::copyFrom(const TTsynonym *src) {
if (src->_field1C) {
_field1C = 5;
diff --git a/engines/titanic/true_talk/tt_synonym.h b/engines/titanic/true_talk/tt_synonym.h
index e95a6d4faa..d5dc2be09e 100644
--- a/engines/titanic/true_talk/tt_synonym.h
+++ b/engines/titanic/true_talk/tt_synonym.h
@@ -38,6 +38,7 @@ public:
TTsynonym();
TTsynonym(const TTsynonym *src);
TTsynonym(int mode, const char *str, FileHandle file);
+ TTsynonym(int mode, TTstring *str);
/**
* Copies data from one synonym to another
diff --git a/engines/titanic/true_talk/tt_vocab.cpp b/engines/titanic/true_talk/tt_vocab.cpp
index dfe894dcd1..5145e4f1b9 100644
--- a/engines/titanic/true_talk/tt_vocab.cpp
+++ b/engines/titanic/true_talk/tt_vocab.cpp
@@ -208,7 +208,7 @@ TTword *TTvocab::getPrimeWord(TTstring &str, TTword **srcWord) const {
return newWord;
}
-void TTvocab::fn1(TTstring &str) {
+TTword *TTvocab::getPrefixedWord(TTstring &str) {
TTstring tempStr(str);
TTword *word = nullptr;
int prefixLen = 0;
@@ -221,28 +221,57 @@ void TTvocab::fn1(TTstring &str) {
prefixLen = 5;
} else if (tempStr.hasPrefix("over") || tempStr.hasPrefix("post") || tempStr.hasPrefix("self")) {
prefixLen = 4;
- }
+ }
+
if (prefixLen) {
// Known prefix found, so scan for word without prefix
tempStr.deletePrefix(prefixLen);
word = getPrimeWord(tempStr);
if (word)
tempStr = str;
- } else {
- if (tempStr.hasPrefix("anti"))
- prefixLen = 4;
- else if (tempStr.hasPrefix("counter"))
- prefixLen = 7;
-
- if (prefixLen) {
- tempStr.deletePrefix(prefixLen);
- word = getPrimeWord(tempStr);
- if (word)
- tempStr = str;
+
+ } else if (tempStr.hasPrefix("anti") || tempStr.hasPrefix("counter")) {
+ prefixLen = tempStr[0] == 'a' ? 4 : 7;
+
+ tempStr.deletePrefix(prefixLen);
+ word = getPrimeWord(tempStr);
+ if (!word)
+ tempStr = str;
+ else if (word->_wordMode == 8) {
+ delete word;
+ word = nullptr;
}
+
+ } else if (tempStr.hasPrefix("hyper") || tempStr.hasPrefix("super") ||
+ tempStr.hasPrefix("ultra")) {
+ tempStr.deletePrefix(5);
+ word = getPrimeWord(tempStr);
+
+ if (!word)
+ tempStr = str;
+ else if (word->_wordMode == 8) {
+ int val1 = word->proc15();
+ int val2 = word->proc15();
+
+ if (val2 < 5) {
+ if (--val1 > 0)
+ word->unkFn1(val1);
+ } else if (++val1 < 11) {
+ word->unkFn1(val1);
+ }
+ }
+ }
+
+ if (word) {
+ // Set the original word on either the found word or synonym
+ if (word->hasSynonyms())
+ word->setSynStr(&str);
+ else
+ word->_string = str;
}
- // TODO
+ delete tempStr;
+ return word;
}
} // End of namespace Titanic
diff --git a/engines/titanic/true_talk/tt_vocab.h b/engines/titanic/true_talk/tt_vocab.h
index 16515cee26..8b2a080ce9 100644
--- a/engines/titanic/true_talk/tt_vocab.h
+++ b/engines/titanic/true_talk/tt_vocab.h
@@ -67,7 +67,13 @@ public:
*/
TTword *getPrimeWord(TTstring &str, TTword **srcWord = nullptr) const;
- void fn1(TTstring &str);
+ /**
+ * Checks the passed word for common prefixes, and checks for a word
+ * match for the word without the given prefix
+ * @param str Word to check
+ * @returns New word instance for found match, or nullptr otherwise
+ */
+ TTword *getPrefixedWord(TTstring &str);
};
} // End of namespace Titanic
diff --git a/engines/titanic/true_talk/tt_word.cpp b/engines/titanic/true_talk/tt_word.cpp
index a09af4ab34..bc029d001a 100644
--- a/engines/titanic/true_talk/tt_word.cpp
+++ b/engines/titanic/true_talk/tt_word.cpp
@@ -109,6 +109,16 @@ void TTword::setSyn(TTsynonym *synP) {
_synP = synP;
}
+int TTword::setSynStr(TTstring *str) {
+ if (str->empty())
+ return 4;
+
+ TTstring *newStr = new TTstring(*str);
+ TTsynonym *newSyn = new TTsynonym(4, newStr);
+ setSyn(newSyn);
+ return 0;
+}
+
void TTword::appendNode(TTsynonym *node) {
if (_synP)
_synP->addNode(node);
@@ -172,6 +182,10 @@ TTword *TTword::copy() {
return new TTword(this);
}
+void TTword::unkFn1(int val) {
+ // TODO: This method seems to reference a field beyond the size of TTword
+}
+
FileHandle TTword::getSynFile() const {
return _synP ? _synP->_file : HANDLE_STDIN;
}
diff --git a/engines/titanic/true_talk/tt_word.h b/engines/titanic/true_talk/tt_word.h
index 885409ccb0..7f0f916677 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:
TTstringStatus _status;
- int _wordMode;
int _field1C;
int _field20;
int _field24;
@@ -49,6 +48,7 @@ public:
TTword *_nextP;
TTsynonym *_synP;
TTstring _string;
+ int _wordMode;
public:
TTword(TTstring &str, int mode, int val2);
TTword(TTword *src);
@@ -69,6 +69,16 @@ public:
void setSyn(TTsynonym *synP);
/**
+ * Set a new synonym string
+ */
+ int setSynStr(TTstring *str);
+
+ /**
+ * Returns true if synonyms have been set for the word
+ */
+ bool hasSynonyms() const { return _synP != nullptr; }
+
+ /**
* Either sets the first synonym for a word, or adds it to an existing one
*/
void appendNode(TTsynonym *node);
@@ -99,6 +109,8 @@ public:
*/
virtual TTword *copy();
+ void unkFn1(int val);
+
virtual bool proc2(int val) const { return false; }
virtual int proc3() const { return -1; }
virtual void proc4() {}