diff options
Diffstat (limited to 'engines/fullpipe/utils.cpp')
-rw-r--r-- | engines/fullpipe/utils.cpp | 51 |
1 files changed, 48 insertions, 3 deletions
diff --git a/engines/fullpipe/utils.cpp b/engines/fullpipe/utils.cpp index de7cbbbaab..5403adec68 100644 --- a/engines/fullpipe/utils.cpp +++ b/engines/fullpipe/utils.cpp @@ -109,6 +109,17 @@ char *MfcArchive::readPascalString(bool twoByte) { return tmp; } +void MfcArchive::writePascalString(char *str, bool twoByte) { + int len = strlen(str); + + if (twoByte) + writeUint16LE(len); + else + writeByte(len); + + write(str, len); +} + MemoryObject::MemoryObject() { _memfilename = 0; _mfield_8 = 0; @@ -347,6 +358,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 +379,6 @@ MfcArchive::MfcArchive(Common::SeekableReadStream *stream) { _lastIndex = 1; _level = 0; - _stream = stream; - _objectMap.push_back(0); _objectIdMap.push_back(kNullObject); } @@ -379,7 +402,9 @@ CObject *MfcArchive::parseClass(bool *isCopyReturned) { debugC(7, kDebugLoading, "parseClass::obTag = %d (%04x) at 0x%08x", obTag, obTag, pos() - 2); - if (obTag == 0xffff) { + if (obTag == 0x0000) { + return NULL; + } else if (obTag == 0xffff) { int schema = readUint16LE(); debugC(7, kDebugLoading, "parseClass::schema = %d", schema); @@ -434,6 +459,26 @@ CObject *MfcArchive::parseClass(bool *isCopyReturned) { return res; } +void MfcArchive::writeObject(CObject *obj) { + if (obj == NULL) { + writeUint16LE(0); + } else if (_objectHash.contains(obj)) { + int32 idx = _objectHash[obj]; + + if (idx < 0x7fff) { + writeUint16LE(idx); + } else { + writeUint16LE(0x7fff); + writeUint32LE(idx); + } + } else { + writeUint16LE(0xffff); // New class + _objectHash[obj] = _lastIndex++; + + obj->save(*this); + } +} + char *genFileName(int superId, int sceneId, const char *ext) { char *s = (char *)calloc(256, 1); |