aboutsummaryrefslogtreecommitdiff
path: root/engines/xeen/files.h
diff options
context:
space:
mode:
authorPaul Gilbert2018-01-14 14:16:58 -0500
committerPaul Gilbert2018-01-14 14:16:58 -0500
commit700bcc73e1b829cb15b1dcc56027b8da364c2468 (patch)
treefec52bf51ef2908a4e653409deb833be4e4c9db4 /engines/xeen/files.h
parenta506a8f7eb7d5d4897afda90bb0c5501c0d556ab (diff)
downloadscummvm-rg350-700bcc73e1b829cb15b1dcc56027b8da364c2468.tar.gz
scummvm-rg350-700bcc73e1b829cb15b1dcc56027b8da364c2468.tar.bz2
scummvm-rg350-700bcc73e1b829cb15b1dcc56027b8da364c2468.zip
XEEN: Fixes for encryption and resource offsets in save files
Diffstat (limited to 'engines/xeen/files.h')
-rw-r--r--engines/xeen/files.h27
1 files changed, 26 insertions, 1 deletions
diff --git a/engines/xeen/files.h b/engines/xeen/files.h
index ff10db5228..37b2422e2d 100644
--- a/engines/xeen/files.h
+++ b/engines/xeen/files.h
@@ -64,8 +64,9 @@ struct CCEntry {
uint16 _id;
uint32 _offset;
uint16 _size;
+ uint32 _writeOffset;
- CCEntry() : _id(0), _offset(0), _size(0) {}
+ CCEntry() : _id(0), _offset(0), _size(0), _writeOffset(0) {}
CCEntry(uint16 id, uint32 offset, uint32 size)
: _id(id), _offset(offset), _size(size) {
}
@@ -185,6 +186,30 @@ public:
static bool exists(const Common::String &filename, int ccMode);
};
+/**
+ * SubWriteStream provides a way of compartmentalizing writing to a subsection of
+ * a file. This is primarily useful for the pos() function which can, for example,
+ * be used in asserts to ensure writing is being done at the correct offset within
+ * the bounds of the structure being written.
+*/
+class SubWriteStream : virtual public Common::WriteStream {
+protected:
+ Common::WriteStream *_parentStream;
+ uint32 _begin;
+ DisposeAfterUse::Flag _disposeAfterUse;
+public:
+ SubWriteStream(Common::WriteStream *parentStream) :
+ _parentStream(parentStream), _begin(parentStream->pos()) {
+ }
+
+ virtual uint32 write(const void *dataPtr, uint32 dataSize) {
+ return _parentStream->write(dataPtr, dataSize);
+ }
+ virtual bool flush() { return _parentStream->flush(); }
+ virtual void finalize() {}
+ virtual int32 pos() const { return _parentStream->pos() - _begin; }
+};
+
class StringArray : public Common::StringArray {
public:
StringArray() {}