mirror of
https://github.com/libretro/scummvm.git
synced 2025-01-19 00:15:30 +00:00
FULLPIPE: Properly save object backreferences
This commit is contained in:
parent
d9457c2f07
commit
f0d786184b
@ -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) {
|
||||
|
@ -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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user