FULLPIPE: Turned MfcArchive into read/write stream like in original

This commit is contained in:
Eugene Sandulenko 2016-09-17 20:41:15 +02:00
parent 210a57c4c0
commit 80419708d0
2 changed files with 24 additions and 5 deletions

View File

@ -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);
}

View File

@ -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;
@ -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 {