diff options
author | Paul Gilbert | 2016-05-09 20:42:55 -0400 |
---|---|---|
committer | Paul Gilbert | 2016-07-10 16:39:00 -0400 |
commit | b99fa6ba8c7f4a5407ff59812e5e6023c8a3301c (patch) | |
tree | cfe33ee075dc37361e739dea50f1290768472f3b /engines/titanic | |
parent | 3822d46341d111ccf29d0dbea4bd7223f546e51b (diff) | |
download | scummvm-rg350-b99fa6ba8c7f4a5407ff59812e5e6023c8a3301c.tar.gz scummvm-rg350-b99fa6ba8c7f4a5407ff59812e5e6023c8a3301c.tar.bz2 scummvm-rg350-b99fa6ba8c7f4a5407ff59812e5e6023c8a3301c.zip |
TITANIC: Fix to SimpleFile scanf
Diffstat (limited to 'engines/titanic')
-rw-r--r-- | engines/titanic/support/simple_file.cpp | 15 | ||||
-rw-r--r-- | engines/titanic/true_talk/tt_string.cpp | 2 |
2 files changed, 14 insertions, 3 deletions
diff --git a/engines/titanic/support/simple_file.cpp b/engines/titanic/support/simple_file.cpp index 18a75864a8..85f42aeeb5 100644 --- a/engines/titanic/support/simple_file.cpp +++ b/engines/titanic/support/simple_file.cpp @@ -368,23 +368,34 @@ bool SimpleFile::scanf(const char *format, ...) { CString formatStr(format); while (!formatStr.empty()) { if (formatStr.hasPrefix(" ")) { + // Skip over whitespaces formatStr.deleteChar(0); - safeRead(&c, 1); + safeRead(&c, 1); if (!Common::isSpace(c)) return false; + + while (Common::isSpace(c)) + safeRead(&c, 1); + _inStream->skip(-1); } else if (formatStr.hasPrefix("%d")) { // Read in a number formatStr = CString(formatStr.c_str() + 2); int *param = (int *)va_arg(va, int *); *param = readNumber(); + + if (!eos()) + _inStream->skip(-1); } else if (formatStr.hasPrefix("%s")) { // Read in text until the next space formatStr = CString(formatStr.c_str() + 2); CString *str = (CString *)va_arg(va, CString *); str->clear(); - while (!eos() && (c = readByte()) != ' ') + while (!eos() && !Common::isSpace(c = readByte())) *str += c; + + if (!eos()) + _inStream->skip(-1); } } diff --git a/engines/titanic/true_talk/tt_string.cpp b/engines/titanic/true_talk/tt_string.cpp index ffe6509e07..2308afa75d 100644 --- a/engines/titanic/true_talk/tt_string.cpp +++ b/engines/titanic/true_talk/tt_string.cpp @@ -54,7 +54,7 @@ TTString::TTString(TTString &str) { } TTString::~TTString() { - if (--_data->_referenceCount == 0) + if (_data && --_data->_referenceCount == 0) delete _data; } |