diff options
-rw-r--r-- | engines/fullpipe/stateloader.cpp | 10 | ||||
-rw-r--r-- | engines/fullpipe/statesaver.cpp | 2 | ||||
-rw-r--r-- | engines/fullpipe/utils.cpp | 10 | ||||
-rw-r--r-- | engines/fullpipe/utils.h | 5 |
4 files changed, 20 insertions, 7 deletions
diff --git a/engines/fullpipe/stateloader.cpp b/engines/fullpipe/stateloader.cpp index 12895fd42a..1f327b541a 100644 --- a/engines/fullpipe/stateloader.cpp +++ b/engines/fullpipe/stateloader.cpp @@ -78,11 +78,11 @@ void GameLoader::readSavegame(const char *fname) { for (uint i = 0; i < header.encSize; i++) data[i] -= i & 0x7f; - MfcArchive *archive = new MfcArchive(new Common::MemoryReadStream(data, header.encSize)); + //Common::hexdump(data, 48); - GameVar var; + MfcArchive *archive = new MfcArchive(new Common::MemoryReadStream(data, header.encSize)); - var.load(*archive); + GameVar *var = (GameVar *)archive->readClass(); GameVar *v = _gameVar->getSubVarByName("OBJSTATES"); @@ -96,7 +96,7 @@ void GameLoader::readSavegame(const char *fname) { } } - addVar(&var, v); + addVar(var, v); getGameLoaderInventory()->loadPartial(*archive); @@ -313,6 +313,8 @@ GameVar::GameVar() { _varType = 0; _value.floatValue = 0; _varName = 0; + + _objtype = kObjTypeGameVar; } GameVar::~GameVar() { diff --git a/engines/fullpipe/statesaver.cpp b/engines/fullpipe/statesaver.cpp index eaf0352cec..406c87af10 100644 --- a/engines/fullpipe/statesaver.cpp +++ b/engines/fullpipe/statesaver.cpp @@ -97,6 +97,8 @@ void GameLoader::writeSavegame(Scene *sc, const char *fname) { for (uint i = 0; i < header.encSize; i++) stream.getData()[i] += i & 0x7f; + //Common::hexdump(stream.getData(), 48); + if (_savegameCallback) _savegameCallback(archive, true); diff --git a/engines/fullpipe/utils.cpp b/engines/fullpipe/utils.cpp index 5403adec68..ba0e180547 100644 --- a/engines/fullpipe/utils.cpp +++ b/engines/fullpipe/utils.cpp @@ -109,7 +109,7 @@ char *MfcArchive::readPascalString(bool twoByte) { return tmp; } -void MfcArchive::writePascalString(char *str, bool twoByte) { +void MfcArchive::writePascalString(const char *str, bool twoByte) { int len = strlen(str); if (twoByte) @@ -475,6 +475,14 @@ void MfcArchive::writeObject(CObject *obj) { writeUint16LE(0xffff); // New class _objectHash[obj] = _lastIndex++; + switch (obj->_objtype) { + case kObjTypeGameVar: + writePascalString(lookupObjectId(kGameVar)); + break; + default: + error("Unhandled save for object type: %d", obj->_objtype); + } + obj->save(*this); } } diff --git a/engines/fullpipe/utils.h b/engines/fullpipe/utils.h index 44bda68cac..41a54f4ce7 100644 --- a/engines/fullpipe/utils.h +++ b/engines/fullpipe/utils.h @@ -68,7 +68,7 @@ public: MfcArchive(Common::WriteStream *file); char *readPascalString(bool twoByte = false); - void writePascalString(char *str, bool twoByte = false); + void writePascalString(const char *str, bool twoByte = false); int readCount(); double readDouble(); CObject *parseClass(bool *isCopyReturned); @@ -103,7 +103,8 @@ enum ObjType { kObjTypeMctlCompound, kObjTypeObjstateCommand, kObjTypePictureObject, - kObjTypeStaticANIObject + kObjTypeStaticANIObject, + kObjTypeGameVar }; class CObject { |