aboutsummaryrefslogtreecommitdiff
path: root/engines/titanic/true_talk/tt_quotes.cpp
diff options
context:
space:
mode:
authorPaul Gilbert2016-06-04 08:36:51 -0400
committerPaul Gilbert2016-07-15 19:19:23 -0400
commite9c239797d2c99ec15675513c577b92a1ea6802e (patch)
tree6774e7f30f6b0ed9d9fe091c6e9fe6f71a5c7fb5 /engines/titanic/true_talk/tt_quotes.cpp
parentb3bcf1cc4e2c22cedafd63417bb1d22ef591dd41 (diff)
downloadscummvm-rg350-e9c239797d2c99ec15675513c577b92a1ea6802e.tar.gz
scummvm-rg350-e9c239797d2c99ec15675513c577b92a1ea6802e.tar.bz2
scummvm-rg350-e9c239797d2c99ec15675513c577b92a1ea6802e.zip
TITANIC: Implement TTquotes read
Diffstat (limited to 'engines/titanic/true_talk/tt_quotes.cpp')
-rw-r--r--engines/titanic/true_talk/tt_quotes.cpp38
1 files changed, 36 insertions, 2 deletions
diff --git a/engines/titanic/true_talk/tt_quotes.cpp b/engines/titanic/true_talk/tt_quotes.cpp
index 734ad58fbd..856cba9421 100644
--- a/engines/titanic/true_talk/tt_quotes.cpp
+++ b/engines/titanic/true_talk/tt_quotes.cpp
@@ -100,12 +100,46 @@ int TTquotes::read(const char *startP, const char *endP) {
return 0;
uint index = MIN((uint)(*startP - 'a'), (uint)25);
- TTquotesLetter &letter = _alphabet[index];
+ const TTquotesLetter &letter = _alphabet[index];
if (letter._entries.empty())
// No entries for the letter, so exit immediately
return 0;
- // TODO
+ int maxSize = size + 4;
+ bool letterFlag = index != 25;
+
+ for (uint idx = 0; idx < letter._entries.size(); ++idx) {
+ const TTquotesEntry &entry = letter._entries[idx];
+ if (entry._val2 > maxSize)
+ continue;
+
+ const char *srcP = startP;
+ const char *destP = entry._strP;
+ int srcIndex = 0, destIndex = 0;
+ if (*destP) {
+ do {
+ if (!srcP[srcIndex]) {
+ break;
+ } else if (srcP[srcIndex] == '*') {
+ ++srcIndex;
+ } else if (destP[destIndex] == '-') {
+ ++destIndex;
+ if (srcP[srcIndex] == ' ')
+ ++srcIndex;
+ } else if (srcP[srcIndex] != destP[destIndex]) {
+ break;
+ } else {
+ ++destIndex;
+ ++srcIndex;
+ }
+ } while (destP[destIndex]);
+
+ if (!destP[destIndex] && (srcP[srcIndex] <= '*' ||
+ (srcP[srcIndex] == 's' && srcP[srcIndex + 1] <= '*')))
+ return entry._val1;
+ }
+ }
+
return 0;
}