diff options
author | Paul Gilbert | 2016-05-11 21:06:14 -0400 |
---|---|---|
committer | Paul Gilbert | 2016-07-10 16:39:18 -0400 |
commit | 01320c06cbb6a25ee226c1037152d5348b73cd68 (patch) | |
tree | a52c8dd7065e046288997c8da4df9a3290257b5a /engines | |
parent | 96a11a08bd4c59cc17a0d502e45c3c0480925c3f (diff) | |
download | scummvm-rg350-01320c06cbb6a25ee226c1037152d5348b73cd68.tar.gz scummvm-rg350-01320c06cbb6a25ee226c1037152d5348b73cd68.tar.bz2 scummvm-rg350-01320c06cbb6a25ee226c1037152d5348b73cd68.zip |
TITANIC: Vocab list is now completely loading
Diffstat (limited to 'engines')
-rw-r--r-- | engines/titanic/support/simple_file.cpp | 16 | ||||
-rw-r--r-- | engines/titanic/support/simple_file.h | 7 | ||||
-rw-r--r-- | engines/titanic/true_talk/tt_word.cpp | 4 |
3 files changed, 20 insertions, 7 deletions
diff --git a/engines/titanic/support/simple_file.cpp b/engines/titanic/support/simple_file.cpp index 85f42aeeb5..80f5178298 100644 --- a/engines/titanic/support/simple_file.cpp +++ b/engines/titanic/support/simple_file.cpp @@ -368,16 +368,14 @@ bool SimpleFile::scanf(const char *format, ...) { CString formatStr(format); while (!formatStr.empty()) { if (formatStr.hasPrefix(" ")) { - // Skip over whitespaces formatStr.deleteChar(0); safeRead(&c, 1); if (!Common::isSpace(c)) return false; - while (Common::isSpace(c)) - safeRead(&c, 1); - _inStream->skip(-1); + // Skip over whitespaces + skipSpaces(); } else if (formatStr.hasPrefix("%d")) { // Read in a number formatStr = CString(formatStr.c_str() + 2); @@ -399,10 +397,20 @@ bool SimpleFile::scanf(const char *format, ...) { } } + skipSpaces(); va_end(va); return !eos(); } +void SimpleFile::skipSpaces() { + char c = ' '; + while (!eos() && Common::isSpace(c)) + safeRead(&c, 1); + + if (!eos()) + _inStream->skip(-1); +} + /*------------------------------------------------------------------------*/ void StdCWadFile::open(const CString &name) { diff --git a/engines/titanic/support/simple_file.h b/engines/titanic/support/simple_file.h index db453c46c7..2a4cfdbbc0 100644 --- a/engines/titanic/support/simple_file.h +++ b/engines/titanic/support/simple_file.h @@ -48,6 +48,11 @@ public: * This class implements basic reading and writing to files */ class SimpleFile { +private: + /** + * Skip over any pending spaces + */ + void skipSpaces(); protected: Common::SeekableReadStream *_inStream; Common::OutSaveFile *_outStream; @@ -213,7 +218,7 @@ public: */ bool eos() const { assert(_inStream); - return _inStream->eos(); + return _inStream->pos() >= _inStream->size(); } }; diff --git a/engines/titanic/true_talk/tt_word.cpp b/engines/titanic/true_talk/tt_word.cpp index 067560bfa8..143e1dfbd2 100644 --- a/engines/titanic/true_talk/tt_word.cpp +++ b/engines/titanic/true_talk/tt_word.cpp @@ -171,7 +171,7 @@ TTword4::TTword4(TTString &str, int val1, int val2, int val3, int val4) : int TTword4::load(SimpleFile *file) { int val; - if (!TTword::load(file, 1) && file->scanf("%d", &val)) { + if (!TTword::load(file, 8) && file->scanf("%d", &val)) { _field30 = val; return 0; } else { @@ -188,7 +188,7 @@ TTword5::TTword5(TTString &str, int val1, int val2, int val3, int val4) : int TTword5::load(SimpleFile *file) { int val; - if (!TTword::load(file, 1) && file->scanf("%d", &val)) { + if (!TTword::load(file, 6) && file->scanf("%d", &val)) { if (val >= 0 && val <= 12) { _field30 = val; return 0; |