diff options
author | Paul Gilbert | 2016-06-04 08:36:51 -0400 |
---|---|---|
committer | Paul Gilbert | 2016-07-15 19:19:23 -0400 |
commit | e9c239797d2c99ec15675513c577b92a1ea6802e (patch) | |
tree | 6774e7f30f6b0ed9d9fe091c6e9fe6f71a5c7fb5 | |
parent | b3bcf1cc4e2c22cedafd63417bb1d22ef591dd41 (diff) | |
download | scummvm-rg350-e9c239797d2c99ec15675513c577b92a1ea6802e.tar.gz scummvm-rg350-e9c239797d2c99ec15675513c577b92a1ea6802e.tar.bz2 scummvm-rg350-e9c239797d2c99ec15675513c577b92a1ea6802e.zip |
TITANIC: Implement TTquotes read
-rw-r--r-- | engines/titanic/true_talk/tt_quotes.cpp | 38 | ||||
-rw-r--r-- | engines/titanic/true_talk/tt_quotes.h | 8 |
2 files changed, 44 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; } diff --git a/engines/titanic/true_talk/tt_quotes.h b/engines/titanic/true_talk/tt_quotes.h index 6649c1f744..f67216cf72 100644 --- a/engines/titanic/true_talk/tt_quotes.h +++ b/engines/titanic/true_talk/tt_quotes.h @@ -49,6 +49,10 @@ private: size_t _dataSize; int _field544; private: + /** + * Test whether a substring contains one of the quotes, + * and if so, returns the Id associated with it + */ int read(const char *startP, const char *endP); public: TTquotes(); @@ -59,6 +63,10 @@ public: */ void load(const CString &name); + /** + * Test whether a passed string contains one of the quotes, + * and if so, returns the Id associated with it + */ int read(const char *str); }; |