diff options
author | Paul Gilbert | 2016-05-08 20:57:03 -0400 |
---|---|---|
committer | Paul Gilbert | 2016-07-10 16:38:53 -0400 |
commit | 9ce6391a94db959f3dde54ed3d0153e000aa3d5a (patch) | |
tree | 60cba99e447b562502d4b66815c94fa6bc44b7e6 /engines/titanic/support | |
parent | 71179e376363c1c59b9c7819bfbe89196c7bbc23 (diff) | |
download | scummvm-rg350-9ce6391a94db959f3dde54ed3d0153e000aa3d5a.tar.gz scummvm-rg350-9ce6391a94db959f3dde54ed3d0153e000aa3d5a.tar.bz2 scummvm-rg350-9ce6391a94db959f3dde54ed3d0153e000aa3d5a.zip |
TITANIC: Beginnings of TTWord hierarchy
Diffstat (limited to 'engines/titanic/support')
-rw-r--r-- | engines/titanic/support/file_reader.cpp | 9 | ||||
-rw-r--r-- | engines/titanic/support/file_reader.h | 13 | ||||
-rw-r--r-- | engines/titanic/support/simple_file.cpp | 23 | ||||
-rw-r--r-- | engines/titanic/support/simple_file.h | 13 |
4 files changed, 53 insertions, 5 deletions
diff --git a/engines/titanic/support/file_reader.cpp b/engines/titanic/support/file_reader.cpp index 308d748704..f31d72bda5 100644 --- a/engines/titanic/support/file_reader.cpp +++ b/engines/titanic/support/file_reader.cpp @@ -24,10 +24,13 @@ namespace Titanic { -void CFileReader::reset() { - _file.close(); - _field18 = 0; +CFileReader::CFileReader() : _owner(nullptr), _field4(0), _field8(0), + _fieldC(0), _field10(0), _field14(0), _field18(0) { } +void CFileReader::reset(CScriptHandler *owner, int val1, int val2) { + _owner = owner; + _field18 = val2; +} } // End of namespace Titanic diff --git a/engines/titanic/support/file_reader.h b/engines/titanic/support/file_reader.h index 23ab0a6fce..7d00ebd80d 100644 --- a/engines/titanic/support/file_reader.h +++ b/engines/titanic/support/file_reader.h @@ -27,12 +27,21 @@ namespace Titanic { +class CScriptHandler; + class CFileReader { public: - Common::File _file; + CScriptHandler *_owner; + int _field4; + int _field8; + int _fieldC; + int _field10; + int _field14; int _field18; public: - void reset(); + CFileReader(); + + void reset(CScriptHandler *owner, int val1, int val2); }; } // End of namespace Titanic diff --git a/engines/titanic/support/simple_file.cpp b/engines/titanic/support/simple_file.cpp index 88d74a9f47..b7f666a1ef 100644 --- a/engines/titanic/support/simple_file.cpp +++ b/engines/titanic/support/simple_file.cpp @@ -354,6 +354,29 @@ void SimpleFile::writeClassEnd(int indent) { write("}\n", 2); } +bool SimpleFile::scanf(const char *format, ...) { + va_list va; + va_start(va, format); + char c; + + CString formatStr(format); + while (!formatStr.empty()) { + if (formatStr.hasPrefix(" ")) { + formatStr.deleteChar(0); + safeRead(&c, 1); + + if (!Common::isSpace(c)) + return false; + } else if (formatStr.hasPrefix("%d")) { + formatStr = CString(formatStr.c_str() + 2); + int *param = (int *)va_arg(va, int *); + *param = readNumber(); + } + } + + va_end(va); +} + /*------------------------------------------------------------------------*/ void StdCWadFile::open(const CString &name) { diff --git a/engines/titanic/support/simple_file.h b/engines/titanic/support/simple_file.h index 115e3805da..431df016ad 100644 --- a/engines/titanic/support/simple_file.h +++ b/engines/titanic/support/simple_file.h @@ -122,6 +122,11 @@ public: void readBuffer(char *buffer = nullptr, size_t count = 0); /** + * Scan in values from the file + */ + bool scanf(const char *format, ...); + + /** * Write a string line */ void writeLine(const CString &str); @@ -197,6 +202,14 @@ public: * Write out the ending footer for a class definition */ void writeClassEnd(int indent); + + /** + * Return true if the stream has finished being read + */ + bool eos() const { + assert(_inStream); + return _inStream->eos(); + } }; /** |