aboutsummaryrefslogtreecommitdiff
path: root/engines/titanic
diff options
context:
space:
mode:
Diffstat (limited to 'engines/titanic')
-rw-r--r--engines/titanic/true_talk/tt_string.cpp18
-rw-r--r--engines/titanic/true_talk/tt_string.h6
-rw-r--r--engines/titanic/true_talk/tt_vocab.cpp29
-rw-r--r--engines/titanic/true_talk/tt_vocab.h6
4 files changed, 54 insertions, 5 deletions
diff --git a/engines/titanic/true_talk/tt_string.cpp b/engines/titanic/true_talk/tt_string.cpp
index 76c109284a..90a9aaa635 100644
--- a/engines/titanic/true_talk/tt_string.cpp
+++ b/engines/titanic/true_talk/tt_string.cpp
@@ -139,4 +139,22 @@ int TTstring::deletePrefix(int count) {
return 1;
}
+int TTstring::deleteSuffix(int count) {
+ int strSize = size();
+ if (count > strSize)
+ count = strSize;
+
+ CString newStr(_data->_string.c_str(), _data->_string.c_str() + strSize - count);
+ if (_data->_referenceCount == 1) {
+ // No other references to this string, so we can just directly modify it
+ _data->_string = newStr;
+ } else {
+ // Detach string from current shared data, and create a new one with the substring
+ _data->_referenceCount--;
+ _data = new TTstringData(newStr);
+ }
+
+ return 1;
+}
+
} // End of namespace Titanic
diff --git a/engines/titanic/true_talk/tt_string.h b/engines/titanic/true_talk/tt_string.h
index faf1d6dc71..600312431c 100644
--- a/engines/titanic/true_talk/tt_string.h
+++ b/engines/titanic/true_talk/tt_string.h
@@ -156,6 +156,12 @@ public:
* Delets a specififed number of characters from the start of the string
*/
int deletePrefix(int count);
+
+ /**
+ * Delets a specififed number of characters from the end of the string
+ */
+ int deleteSuffix(int count);
+
};
} // End of namespace Titanic
diff --git a/engines/titanic/true_talk/tt_vocab.cpp b/engines/titanic/true_talk/tt_vocab.cpp
index 5a52e75bb5..073c7c2260 100644
--- a/engines/titanic/true_talk/tt_vocab.cpp
+++ b/engines/titanic/true_talk/tt_vocab.cpp
@@ -180,7 +180,7 @@ TTword *TTvocab::getWord(TTstring &str, TTword **srcWord) const {
if (!word) {
TTstring tempStr(str);
if (tempStr.size() > 2) {
- word = getPluralizedWord(tempStr);
+ word = getSuffixedWord(tempStr);
if (!word)
word = getPrefixedWord(tempStr);
@@ -224,7 +224,32 @@ TTword *TTvocab::getPrimeWord(TTstring &str, TTword **srcWord) const {
return newWord;
}
-TTword *TTvocab::getPluralizedWord(TTstring &str) const {
+TTword *TTvocab::getSuffixedWord(TTstring &str) const {
+ TTstring tempStr(str);
+ TTword *word = nullptr;
+
+ if (tempStr.hasSuffix("s")) {
+ tempStr.deleteSuffix(1);
+ word = getPrimeWord(tempStr);
+
+ if (!word) {
+ if (!tempStr.hasSuffix("e")) {
+ tempStr = str;
+ } else {
+ tempStr.deleteLastChar();
+ word = getPrimeWord(tempStr);
+ }
+ }
+
+ } else if (tempStr.hasSuffix("ing")) {
+ tempStr.deleteSuffix(3);
+ word = getPrimeWord(tempStr);
+
+ if (word) {
+
+ }
+ }
+
// TODO
return nullptr;
}
diff --git a/engines/titanic/true_talk/tt_vocab.h b/engines/titanic/true_talk/tt_vocab.h
index 7da0db3e20..c84acbe741 100644
--- a/engines/titanic/true_talk/tt_vocab.h
+++ b/engines/titanic/true_talk/tt_vocab.h
@@ -65,12 +65,12 @@ private:
TTword *getPrimeWord(TTstring &str, TTword **srcWord = nullptr) const;
/**
- * Checks the passed word for common pluralization, and if present checks
- * for a word match for the base singular word
+ * Checks the passed word for common suffixes, like 's', 'ing', etc. and, if found,
+ * checks for a word match for the base word without the suffix.
* @param str Word to check
* @returns New word instance for found match, or nullptr otherwise
*/
- TTword *getPluralizedWord(TTstring &str) const;
+ TTword *getSuffixedWord(TTstring &str) const;
/**
* Checks the passed word for common prefixes, and checks for a word