aboutsummaryrefslogtreecommitdiff
path: root/engines/fullpipe/utils.h
diff options
context:
space:
mode:
Diffstat (limited to 'engines/fullpipe/utils.h')
-rw-r--r--engines/fullpipe/utils.h35
1 files changed, 32 insertions, 3 deletions
diff --git a/engines/fullpipe/utils.h b/engines/fullpipe/utils.h
index da3ab7ee4f..44bda68cac 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(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 {
@@ -84,6 +112,7 @@ public:
CObject() : _objtype(kObjTypeDefault) {}
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);