aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Gilbert2016-05-18 19:59:42 -0400
committerPaul Gilbert2016-07-15 19:13:05 -0400
commit2b9fcd2cdaa537d79310915a69c48fab0b4ae105 (patch)
tree6b25221404b4161f2f1bdd2530d5849d80b10f22
parentdefd50c9261366be392f91a1807e4b952ad5a28e (diff)
downloadscummvm-rg350-2b9fcd2cdaa537d79310915a69c48fab0b4ae105.tar.gz
scummvm-rg350-2b9fcd2cdaa537d79310915a69c48fab0b4ae105.tar.bz2
scummvm-rg350-2b9fcd2cdaa537d79310915a69c48fab0b4ae105.zip
TITANIC: Finished TTvocab getPrimeWord
-rw-r--r--engines/titanic/true_talk/tt_vocab.cpp41
-rw-r--r--engines/titanic/true_talk/tt_vocab.h10
2 files changed, 31 insertions, 20 deletions
diff --git a/engines/titanic/true_talk/tt_vocab.cpp b/engines/titanic/true_talk/tt_vocab.cpp
index fe8b622d70..102ed2cbdd 100644
--- a/engines/titanic/true_talk/tt_vocab.cpp
+++ b/engines/titanic/true_talk/tt_vocab.cpp
@@ -174,35 +174,38 @@ TTword *TTvocab::findWord(const TTstring &str) {
return word;
}
-TTword *TTvocab::getPrimeWord(TTstring &str, TTword **words) {
- TTsynonym *synonym = new TTsynonym();
+TTword *TTvocab::getPrimeWord(TTstring &str, TTword **srcWord) const {
+ TTsynonym tempSyn;
char c = str.charAt(0);
- TTword *returnWord = nullptr;
+ TTword *newWord = nullptr;
+ TTword *vocabP;
if (!Common::isDigit(c)) {
- returnWord = new TTword(str, 3, 300);
+ vocabP = _headP;
+ newWord = new TTword(str, 3, 300);
} else {
- TTword *foundWord = nullptr;
- for (TTword *vocabP = _headP; vocabP && !foundWord; vocabP = vocabP->_nextP) {
+ for (vocabP = _headP; vocabP && !newWord; vocabP = vocabP->_nextP) {
if (_vocabMode == 3 && !strcmp(str.c_str(), vocabP->c_str())) {
- foundWord = vocabP->copy();
- foundWord->_nextP = nullptr;
- foundWord->setSyn(nullptr);
- } else {
- vocabP->findSynByName(str, synonym, _vocabMode);
- // TODO
+ newWord = vocabP->copy();
+ newWord->_nextP = nullptr;
+ newWord->setSyn(nullptr);
+ } else if (vocabP->findSynByName(str, &tempSyn, _vocabMode)) {
+ // Create a copy of the word and the found synonym
+ TTsynonym *newSyn = new TTsynonym(tempSyn);
+ newSyn->_nextP = newSyn->_priorP = nullptr;
+ newWord = vocabP->copy();
+ newWord->_nextP = nullptr;
+ newWord->setSyn(newSyn);
}
}
-
- // TODO
-
}
-// if (words)
-// *words = vocabList;
- delete synonym;
+ if (srcWord)
+ // Pass out the pointer to the original word
+ *srcWord = vocabP;
- return returnWord;
+ // Return the new copy of the word
+ return newWord;
}
} // End of namespace Titanic
diff --git a/engines/titanic/true_talk/tt_vocab.h b/engines/titanic/true_talk/tt_vocab.h
index c417c7bf36..e1dcfe6fe2 100644
--- a/engines/titanic/true_talk/tt_vocab.h
+++ b/engines/titanic/true_talk/tt_vocab.h
@@ -57,7 +57,15 @@ public:
TTvocab(int val);
~TTvocab();
- TTword *getPrimeWord(TTstring &str, TTword **words);
+ /**
+ * Scans the vocab list for a word with a synonym matching the passed string.
+ * If found, creates a new word instance that only has the matching synonym
+ * linked to it.
+ * @param str Word text to scan for
+ * @param srcWord Optional pointer to store the original word match was found on
+ * @returns A new word instance if a match if found, or null if not
+ */
+ TTword *getPrimeWord(TTstring &str, TTword **srcWord) const;
};
} // End of namespace Titanic