diff --git a/engines/fullpipe/utils.cpp b/engines/fullpipe/utils.cpp index de7cbbbaab28..32503764d3f8 100644 --- a/engines/fullpipe/utils.cpp +++ b/engines/fullpipe/utils.cpp @@ -347,6 +347,20 @@ static CObject *createObject(int objectId) { } MfcArchive::MfcArchive(Common::SeekableReadStream *stream) { + _stream = stream; + _wstream = 0; + + init(); +} + +MfcArchive::MfcArchive(Common::WriteStream *stream) { + _wstream = stream; + _stream = 0; + + init(); +} + +void MfcArchive::init() { for (int i = 0; classMap[i].name; i++) { _classMap[classMap[i].name] = classMap[i].id; } @@ -354,8 +368,6 @@ MfcArchive::MfcArchive(Common::SeekableReadStream *stream) { _lastIndex = 1; _level = 0; - _stream = stream; - _objectMap.push_back(0); _objectIdMap.push_back(kNullObject); } diff --git a/engines/fullpipe/utils.h b/engines/fullpipe/utils.h index da3ab7ee4fba..3741b4ae0e4a 100644 --- a/engines/fullpipe/utils.h +++ b/engines/fullpipe/utils.h @@ -34,7 +34,7 @@ class NGIArchive; typedef Common::HashMap ClassMap; -class MfcArchive : public Common::SeekableReadStream { +class MfcArchive : public Common::SeekableReadStream, Common::WriteStream { ClassMap _classMap; Common::Array _objectMap; Common::Array _objectIdMap; @@ -43,9 +43,11 @@ class MfcArchive : public Common::SeekableReadStream { int _level; Common::SeekableReadStream *_stream; + Common::WriteStream *_wstream; - public: +public: MfcArchive(Common::SeekableReadStream *file); + MfcArchive(Common::WriteStream *file); char *readPascalString(bool twoByte = false); int readCount(); @@ -59,9 +61,14 @@ class MfcArchive : public Common::SeekableReadStream { virtual bool eos() const { return _stream->eos(); } virtual uint32 read(void *dataPtr, uint32 dataSize) { return _stream->read(dataPtr, dataSize); } - virtual int32 pos() const { return _stream->pos(); } + virtual int32 pos() const { return _stream ? _stream->pos() : _wstream->pos(); } virtual int32 size() const { return _stream->size(); } virtual bool seek(int32 offset, int whence = SEEK_SET) { return _stream->seek(offset, whence); } + + virtual uint32 write(const void *dataPtr, uint32 dataSize) { return _wstream->write(dataPtr, dataSize); } + +private: + void init(); }; enum ObjType {