diff options
author | Paul Gilbert | 2019-05-05 09:58:14 +1000 |
---|---|---|
committer | Filippos Karapetis | 2019-05-12 11:44:15 +0300 |
commit | e2f68e24035245ec0f453c49b28207d32def4789 (patch) | |
tree | 49b75fada577f7153918c4ca54db069a3e7a4f01 /common/memstream.h | |
parent | b821e8fce47d1dbc8c94448fc3727e58814237a3 (diff) | |
download | scummvm-rg350-e2f68e24035245ec0f453c49b28207d32def4789.tar.gz scummvm-rg350-e2f68e24035245ec0f453c49b28207d32def4789.tar.bz2 scummvm-rg350-e2f68e24035245ec0f453c49b28207d32def4789.zip |
COMMON: Fix seek return values, memory stream use in create_titanic
Diffstat (limited to 'common/memstream.h')
-rw-r--r-- | common/memstream.h | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/common/memstream.h b/common/memstream.h index d7c59ffb99..991268ce10 100644 --- a/common/memstream.h +++ b/common/memstream.h @@ -210,7 +210,28 @@ public: byte *getData() { return _data; } - virtual bool seek(int32 offset, int whence = SEEK_SET) override; + virtual bool seek(int32 offs, int whence = SEEK_SET) override { + // Pre-Condition + assert(_pos <= _size); + switch (whence) { + case SEEK_END: + // SEEK_END works just like SEEK_SET, only 'reversed', i.e. from the end. + offs = _size + offs; + // Fall through + case SEEK_SET: + _ptr = _data + offs; + _pos = offs; + break; + + case SEEK_CUR: + _ptr += offs; + _pos += offs; + break; + } + + assert(_pos <= _size); + return true; + } }; /** |