diff options
-rw-r--r-- | engines/titanic/true_talk/tt_parser.cpp | 6 | ||||
-rw-r--r-- | engines/titanic/true_talk/tt_parser.h | 2 | ||||
-rw-r--r-- | engines/titanic/true_talk/tt_sentence.h | 2 | ||||
-rw-r--r-- | engines/titanic/true_talk/tt_string.cpp | 19 | ||||
-rw-r--r-- | engines/titanic/true_talk/tt_string.h | 6 |
5 files changed, 32 insertions, 3 deletions
diff --git a/engines/titanic/true_talk/tt_parser.cpp b/engines/titanic/true_talk/tt_parser.cpp index d2563d4c05..9c955299cf 100644 --- a/engines/titanic/true_talk/tt_parser.cpp +++ b/engines/titanic/true_talk/tt_parser.cpp @@ -27,7 +27,7 @@ namespace Titanic { -TTparser::TTparser(CScriptHandler *owner) : _owner(owner), _field4(0), +TTparser::TTparser(CScriptHandler *owner) : _owner(owner), _sentenceSub(nullptr), _sentence(nullptr), _fieldC(0), _field10(0), _field14(0), _field18(0) { loadArrays(); } @@ -466,6 +466,10 @@ const NumberEntry *TTparser::replaceNumbers2(TTstring &line, int *startIndex) { } int TTparser::findFrames(TTsentence *sentence) { + static bool flag; + _sentenceSub = &sentence->_sub; + _sentence = sentence; + // TODO return 0; } diff --git a/engines/titanic/true_talk/tt_parser.h b/engines/titanic/true_talk/tt_parser.h index fcf39ea822..9ef84f93ad 100644 --- a/engines/titanic/true_talk/tt_parser.h +++ b/engines/titanic/true_talk/tt_parser.h @@ -114,7 +114,7 @@ private: const NumberEntry *replaceNumbers2(TTstring &line, int *startIndex); public: CScriptHandler *_owner; - int _field4; + TTsentenceSub *_sentenceSub; TTsentence *_sentence; int _fieldC; int _field10; diff --git a/engines/titanic/true_talk/tt_sentence.h b/engines/titanic/true_talk/tt_sentence.h index 450280b430..9f6d18ee06 100644 --- a/engines/titanic/true_talk/tt_sentence.h +++ b/engines/titanic/true_talk/tt_sentence.h @@ -55,7 +55,6 @@ public: class TTsentence { private: CScriptHandler *_owner; - TTsentenceSub _sub; int _field2C; int _inputCtr; int _field34; @@ -72,6 +71,7 @@ private: */ void copyFrom(const TTsentence &src); public: + TTsentenceSub _sub; TTstring _initialLine; TTstring _normalizedLine; public: diff --git a/engines/titanic/true_talk/tt_string.cpp b/engines/titanic/true_talk/tt_string.cpp index 7a0078788d..70d6fe3fcf 100644 --- a/engines/titanic/true_talk/tt_string.cpp +++ b/engines/titanic/true_talk/tt_string.cpp @@ -99,4 +99,23 @@ void TTstring::save(SimpleFile *file) const { file->writeFormat("%s", c_str()); } +TTstring TTstring::tokenize(const char *delim) { + const char *strP = _data->_string.c_str(); + const char *splitP = nullptr, *chP; + + for (const char *d = delim; d; ++d) { + chP = strchr(strP, *d); + if (chP && (splitP == nullptr || chP < splitP)) + splitP = chP; + } + + if (splitP) { + TTstring result(CString(strP, splitP)); + _data->_string = CString(splitP + 1); + return result; + } else { + return TTstring(); + } +} + } // End of namespace Titanic diff --git a/engines/titanic/true_talk/tt_string.h b/engines/titanic/true_talk/tt_string.h index 1b208cc26a..cae1a5dc2f 100644 --- a/engines/titanic/true_talk/tt_string.h +++ b/engines/titanic/true_talk/tt_string.h @@ -134,6 +134,12 @@ public: bool compareAt(int index, const char *str) const { return !strncmp(c_str() + index, str, strlen(str)); } + + /** + * Split off everything in the string until the first occurance + * of any specified delimiter character + */ + TTstring tokenize(const char *delim); }; } // End of namespace Titanic |