diff options
author | Eugene Sandulenko | 2016-09-18 00:59:17 +0200 |
---|---|---|
committer | Eugene Sandulenko | 2016-09-18 00:59:17 +0200 |
commit | f0d786184bb9b3cfefc16fb2be87d6c6d1017160 (patch) | |
tree | 906b396bf2634063e1ded6e3daa86317af5474e1 /engines/fullpipe | |
parent | d9457c2f07f22dae83b6702fa7b616aa41696a7f (diff) | |
download | scummvm-rg350-f0d786184bb9b3cfefc16fb2be87d6c6d1017160.tar.gz scummvm-rg350-f0d786184bb9b3cfefc16fb2be87d6c6d1017160.tar.bz2 scummvm-rg350-f0d786184bb9b3cfefc16fb2be87d6c6d1017160.zip |
FULLPIPE: Properly save object backreferences
Diffstat (limited to 'engines/fullpipe')
-rw-r--r-- | engines/fullpipe/utils.cpp | 17 | ||||
-rw-r--r-- | engines/fullpipe/utils.h | 18 |
2 files changed, 33 insertions, 2 deletions
diff --git a/engines/fullpipe/utils.cpp b/engines/fullpipe/utils.cpp index fff2dad15b..5403adec68 100644 --- a/engines/fullpipe/utils.cpp +++ b/engines/fullpipe/utils.cpp @@ -460,10 +460,23 @@ CObject *MfcArchive::parseClass(bool *isCopyReturned) { } void MfcArchive::writeObject(CObject *obj) { - if (obj == NULL) + if (obj == NULL) { writeUint16LE(0); - else + } 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) { diff --git a/engines/fullpipe/utils.h b/engines/fullpipe/utils.h index 5de919d383..44bda68cac 100644 --- a/engines/fullpipe/utils.h +++ b/engines/fullpipe/utils.h @@ -32,12 +32,30 @@ 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, public Common::WriteStream { ClassMap _classMap; Common::Array<CObject *> _objectMap; Common::Array<int> _objectIdMap; + ObjHash _objectHash; int _lastIndex; int _level; |