FULLPIPE: Fix saving object to savegames

This commit is contained in:
Eugene Sandulenko 2016-09-19 18:58:39 +02:00
parent 1e9351efaf
commit 783d968e20
4 changed files with 20 additions and 7 deletions

View File

@ -78,11 +78,11 @@ void GameLoader::readSavegame(const char *fname) {
for (uint i = 0; i < header.encSize; i++)
data[i] -= i & 0x7f;
//Common::hexdump(data, 48);
MfcArchive *archive = new MfcArchive(new Common::MemoryReadStream(data, header.encSize));
GameVar var;
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() {

View File

@ -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);

View File

@ -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);
}
}

View File

@ -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 {