Skip to content

Commit

Permalink
FULLPIPE: Turned MfcArchive into read/write stream like in original
Browse files Browse the repository at this point in the history
  • Loading branch information
sev- committed Sep 17, 2016
1 parent 210a57c commit 8041970
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 5 deletions.
16 changes: 14 additions & 2 deletions engines/fullpipe/utils.cpp
Expand Up @@ -347,15 +347,27 @@ 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;
}

_lastIndex = 1;
_level = 0;

_stream = stream;

_objectMap.push_back(0);
_objectIdMap.push_back(kNullObject);
}
Expand Down
13 changes: 10 additions & 3 deletions engines/fullpipe/utils.h
Expand Up @@ -34,7 +34,7 @@ class NGIArchive;

typedef Common::HashMap<Common::String, int, Common::IgnoreCase_Hash, Common::IgnoreCase_EqualTo> ClassMap;

class MfcArchive : public Common::SeekableReadStream {
class MfcArchive : public Common::SeekableReadStream, Common::WriteStream {
ClassMap _classMap;
Common::Array<CObject *> _objectMap;
Common::Array<int> _objectIdMap;
Expand All @@ -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();
Expand All @@ -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 {
Expand Down

0 comments on commit 8041970

Please sign in to comment.