diff options
Diffstat (limited to 'engines/fullpipe/utils.h')
-rw-r--r-- | engines/fullpipe/utils.h | 41 |
1 files changed, 36 insertions, 5 deletions
diff --git a/engines/fullpipe/utils.h b/engines/fullpipe/utils.h index da3ab7ee4f..2f9b75c07f 100644 --- a/engines/fullpipe/utils.h +++ b/engines/fullpipe/utils.h @@ -32,36 +32,64 @@ namespace Fullpipe { class CObject; class NGIArchive; +struct Pointer_EqualTo { + bool operator()(const void *x, const void *y) const { return x == y; } +}; + +struct Pointer_Hash { + uint operator()(const void *x) const { +#ifdef SCUMM_64BITS + uint64 v = (uint64)x; + return (v >> 32) ^ (v & 0xffffffff); +#else + return (uint)x; +#endif + } +}; + +typedef Common::HashMap<void *, int, Pointer_Hash, Pointer_EqualTo> ObjHash; + typedef Common::HashMap<Common::String, int, Common::IgnoreCase_Hash, Common::IgnoreCase_EqualTo> ClassMap; -class MfcArchive : public Common::SeekableReadStream { +class MfcArchive : public Common::SeekableReadStream, public Common::WriteStream { ClassMap _classMap; Common::Array<CObject *> _objectMap; Common::Array<int> _objectIdMap; + ObjHash _objectHash; int _lastIndex; int _level; Common::SeekableReadStream *_stream; + Common::WriteStream *_wstream; - public: +public: MfcArchive(Common::SeekableReadStream *file); + MfcArchive(Common::WriteStream *file); char *readPascalString(bool twoByte = false); + void writePascalString(const char *str, bool twoByte = false); int readCount(); double readDouble(); CObject *parseClass(bool *isCopyReturned); CObject *readClass(); + void writeObject(CObject *obj); + void incLevel() { _level++; } void decLevel() { _level--; } int getLevel() { return _level; } 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 { @@ -75,15 +103,18 @@ enum ObjType { kObjTypeMctlCompound, kObjTypeObjstateCommand, kObjTypePictureObject, - kObjTypeStaticANIObject + kObjTypeStaticANIObject, + kObjTypeGameVar }; class CObject { public: ObjType _objtype; + uint _cnum; - CObject() : _objtype(kObjTypeDefault) {} + CObject() : _objtype(kObjTypeDefault), _cnum(0) {} virtual bool load(MfcArchive &in) { return true; } + virtual void save(MfcArchive &out) { error("Not implemented for obj type: %d", _objtype); } virtual ~CObject() {} bool loadFile(const char *fname); |