static void syncBackgroundTable(Common::Serializer &s) { // restore backgroundTable for (int i = 0; i < 8; i++) { if (s.isSaving() && (strlen(backgroundTable[i].name) > 8)) warning("Saving a background resource that has too long a name"); s.syncBytes((byte *)backgroundTable[i].name, 9); s.syncBytes((byte *)backgroundTable[i].extention, 6); } }
static bool syncSaveGameHeader(Common::Serializer &s, SaveGameHeader &hdr) { s.syncAsUint32LE(hdr.id); s.syncAsUint32LE(hdr.size); s.syncAsUint32LE(hdr.ver); s.syncBytes((byte *)hdr.desc, SG_DESC_LEN); hdr.desc[SG_DESC_LEN - 1] = 0; syncTime(s, hdr.dateTime); int tmp = hdr.size - s.bytesSynced(); // NOTE: We can't use SAVEGAME_ID here when attempting to remove a saved game from the launcher, // as there is no TinselEngine initialized then. This means that we can't check if this is a DW1 // or DW2 savegame in this case, but it doesn't really matter, as the saved game is about to be // deleted anyway. Refer to bug #3387551. bool correctID = _vm ? (hdr.id == SAVEGAME_ID) : (hdr.id == DW1_SAVEGAME_ID || hdr.id == DW2_SAVEGAME_ID); // Perform sanity check if (tmp < 0 || !correctID || hdr.ver > CURRENT_VER || hdr.size > 1024) return false; // Skip over any extra bytes s.skip(tmp); return true; }
static void DoSync(Common::Serializer &s) { syncBasicInfo(s); _vm->sound().doSync(s); syncPalette(s, newPal); syncPalette(s, workpal); s.syncBytes((byte *)currentCtpName, 40); syncBackgroundTable(s); syncPalScreen(s); syncSoundList(s); for (int i = 0; i < stateID; ++i) s.syncAsSint16LE(globalVars[i]); syncFilesDatabase(s); syncOverlays1(s); syncPreloadData(s); syncOverlays2(s); syncScript(s, &procHead); syncScript(s, &relHead); syncCell(s); syncIncrust(s); syncActors(s); syncSongs(s); syncCT(s); }
static void syncSavedData(Common::Serializer &s, SAVED_DATA &sd, int numInterp) { s.syncAsUint32LE(sd.SavedSceneHandle); s.syncAsUint32LE(sd.SavedBgroundHandle); for (int i = 0; i < MAX_MOVERS; ++i) syncSavedMover(s, sd.SavedMoverInfo[i]); for (int i = 0; i < MAX_SAVED_ACTORS; ++i) syncSavedActor(s, sd.SavedActorInfo[i]); s.syncAsSint32LE(sd.NumSavedActors); s.syncAsSint32LE(sd.SavedLoffset); s.syncAsSint32LE(sd.SavedToffset); for (int i = 0; i < numInterp; ++i) sd.SavedICInfo[i].syncWithSerializer(s); for (int i = 0; i < MAX_POLY; ++i) s.syncAsUint32LE(sd.SavedDeadPolys[i]); s.syncAsUint32LE(sd.SavedControl); s.syncAsUint32LE(sd.SavedMidi); s.syncAsUint32LE(sd.SavedLoop); s.syncAsUint32LE(sd.SavedNoBlocking); // SavedNoScrollData for (int i = 0; i < MAX_VNOSCROLL; ++i) syncNoScrollB(s, sd.SavedNoScrollData.NoVScroll[i]); for (int i = 0; i < MAX_HNOSCROLL; ++i) syncNoScrollB(s, sd.SavedNoScrollData.NoHScroll[i]); s.syncAsUint32LE(sd.SavedNoScrollData.NumNoV); s.syncAsUint32LE(sd.SavedNoScrollData.NumNoH); // Tinsel 2 fields if (TinselV2) { // SavedNoScrollData s.syncAsUint32LE(sd.SavedNoScrollData.xTrigger); s.syncAsUint32LE(sd.SavedNoScrollData.xDistance); s.syncAsUint32LE(sd.SavedNoScrollData.xSpeed); s.syncAsUint32LE(sd.SavedNoScrollData.yTriggerTop); s.syncAsUint32LE(sd.SavedNoScrollData.yTriggerBottom); s.syncAsUint32LE(sd.SavedNoScrollData.yDistance); s.syncAsUint32LE(sd.SavedNoScrollData.ySpeed); for (int i = 0; i < NUM_ZPOSITIONS; ++i) syncZPosition(s, sd.zPositions[i]); s.syncBytes(sd.savedActorZ, MAX_SAVED_ACTOR_Z); for (int i = 0; i < MAX_POLY; ++i) syncPolyVolatile(s, sd.SavedPolygonStuff[i]); for (int i = 0; i < 3; ++i) s.syncAsUint32LE(sd.SavedTune[i]); s.syncAsByte(sd.bTinselDim); s.syncAsSint32LE(sd.SavedScrollFocus); for (int i = 0; i < SV_TOPVALID; ++i) s.syncAsSint32LE(sd.SavedSystemVars[i]); for (int i = 0; i < MAX_SOUNDREELS; ++i) syncSoundReel(s, sd.SavedSoundReels[i]); } }
void syncScript(Common::Serializer &s, scriptInstanceStruct *entry) { int numScripts = 0; uint32 dummyLong = 0; uint16 dummyWord = 0; if (s.isSaving()) { // Figure out the number of scripts to save scriptInstanceStruct* pCurrent = entry->nextScriptPtr; while (pCurrent) { ++numScripts; pCurrent = pCurrent->nextScriptPtr; } } s.syncAsSint16LE(numScripts); scriptInstanceStruct *ptr = entry->nextScriptPtr; for (int i = 0; i < numScripts; ++i) { if (s.isLoading()) ptr = (scriptInstanceStruct *)mallocAndZero(sizeof(scriptInstanceStruct)); s.syncAsUint16LE(dummyWord); s.syncAsSint16LE(ptr->ccr); s.syncAsSint16LE(ptr->scriptOffset); s.syncAsUint32LE(dummyLong); s.syncAsSint16LE(ptr->dataSize); s.syncAsSint16LE(ptr->scriptNumber); s.syncAsSint16LE(ptr->overlayNumber); s.syncAsSint16LE(ptr->sysKey); s.syncAsSint16LE(ptr->freeze); s.syncAsSint16LE(ptr->type); s.syncAsSint16LE(ptr->var16); s.syncAsSint16LE(ptr->var18); s.syncAsSint16LE(ptr->var1A); s.syncAsSint16LE(ptr->dataSize); if (ptr->dataSize) { if (s.isLoading()) ptr->data = (byte *)mallocAndZero(ptr->dataSize); s.syncBytes(ptr->data, ptr->dataSize); } if (s.isLoading()) { ptr->nextScriptPtr = NULL; entry->nextScriptPtr = ptr; entry = ptr; } else { ptr = ptr->nextScriptPtr; } } }
static bool syncSaveGameHeader(Common::Serializer &s, SaveGameHeader &hdr) { s.syncAsUint32LE(hdr.id); s.syncAsUint32LE(hdr.size); s.syncAsUint32LE(hdr.ver); s.syncBytes((byte *)hdr.desc, SG_DESC_LEN); hdr.desc[SG_DESC_LEN - 1] = 0; syncTime(s, hdr.dateTime); int tmp = hdr.size - s.bytesSynced(); // NOTE: We can't use SAVEGAME_ID here when attempting to remove a saved game from the launcher, // as there is no TinselEngine initialized then. This means that we can't check if this is a DW1 // or DW2 savegame in this case, but it doesn't really matter, as the saved game is about to be // deleted anyway. Refer to bug #3387551. bool correctID = _vm ? (hdr.id == SAVEGAME_ID) : (hdr.id == DW1_SAVEGAME_ID || hdr.id == DW2_SAVEGAME_ID); // Perform sanity check if (tmp < 0 || !correctID || hdr.ver > CURRENT_VER || hdr.size > 1024) return false; if (tmp > 0) { // If there's header space left, handling syncing the Scn flag and game language s.syncAsByte(hdr.scnFlag); s.syncAsByte(hdr.language); tmp -= 2; if (_vm && s.isLoading()) { // If the engine is loaded, ensure the Scn/Gra usage is correct, and it's the correct language if ((hdr.scnFlag != ((_vm->getFeatures() & GF_SCNFILES) != 0)) || (hdr.language != _vm->_config->_language)) return false; } } // Handle the number of interpreter contexts that will be saved in the savegame if (tmp >= 2) { tmp -= 2; hdr.numInterpreters = NUM_INTERPRET; s.syncAsUint16LE(hdr.numInterpreters); } else { hdr.numInterpreters = (TinselV2 ? 70 : 64) - 20; } // Skip over any extra bytes s.skip(tmp); return true; }
static void syncSongs(Common::Serializer &s) { int size = 0; if (songLoaded) { // TODO: implement s.syncAsByte(size); if (s.isLoading()) { saveVar1 = size; if (saveVar1) s.syncBytes(saveVar2, saveVar1); } } else { s.syncAsByte(size); } }
static void syncPreloadData(Common::Serializer &s) { uint8 dummyByte = 0; uint32 dummyLong = 0; for (int i = 0; i < 64; i++) { preloadStruct &pe = preloadData[i]; s.syncBytes((byte *)pe.name, 15); s.syncAsByte(dummyByte); s.syncAsUint32LE(pe.size); s.syncAsUint32LE(pe.sourceSize); s.syncAsUint32LE(dummyLong); s.syncAsUint16LE(pe.nofree); s.syncAsUint16LE(pe.protect); s.syncAsUint16LE(pe.ovl); } }
static bool syncSaveGameHeader(Common::Serializer &s, SaveGameHeader &hdr) { s.syncAsUint32LE(hdr.id); s.syncAsUint32LE(hdr.size); s.syncAsUint32LE(hdr.ver); s.syncBytes((byte *)hdr.desc, SG_DESC_LEN); hdr.desc[SG_DESC_LEN - 1] = 0; syncTime(s, hdr.dateTime); int tmp = hdr.size - s.bytesSynced(); // Perform sanity check if (tmp < 0 || hdr.id != SAVEGAME_ID || hdr.ver > CURRENT_VER || hdr.size > 1024) return false; // Skip over any extra bytes s.skip(tmp); return true; }
void CGEEngine::syncHeader(Common::Serializer &s) { debugC(1, kCGEDebugEngine, "CGEEngine::syncHeader(s)"); int i = kDemo; s.syncAsUint16LE(_now); s.syncAsUint16LE(_oldLev); s.syncAsUint16LE(i); // unused Demo string id for (i = 0; i < 5; i++) s.syncAsUint16LE(_game); s.syncAsSint16LE(i); // unused VGA::Mono variable s.syncAsUint16LE(_music); s.syncBytes(_volume, 2); for (i = 0; i < 4; i++) s.syncAsUint16LE(_flag[i]); if (s.isLoading()) { // Reset scene values initSceneValues(); } for (i = 0; i < kSceneMax; i++) { s.syncAsSint16LE(_heroXY[i].x); s.syncAsUint16LE(_heroXY[i].y); } for (i = 0; i < 1 + kSceneMax; i++) { s.syncAsByte(_barriers[i]._horz); s.syncAsByte(_barriers[i]._vert); } for (i = 0; i < kPocketNX; i++) s.syncAsUint16LE(_pocref[i]); if (s.isSaving()) { // Write checksum int checksum = kSavegameCheckSum; s.syncAsUint16LE(checksum); } else { // Read checksum and validate it uint16 checksum = 0; s.syncAsUint16LE(checksum); if (checksum != kSavegameCheckSum) error("%s", _text->getText(kBadSVG)); } }
static void syncOverlays1(Common::Serializer &s) { uint8 dummyByte = 0; uint32 dummyLong = 0; for (int i = 0; i < numOfLoadedOverlay; i++) { overlayStruct &oe = overlayTable[i]; s.syncBytes((byte *)oe.overlayName, 13); s.syncAsByte(dummyByte); s.syncAsUint32LE(dummyLong); s.syncAsUint16LE(oe.alreadyLoaded); s.syncAsUint16LE(oe.state); s.syncAsUint32LE(dummyLong); s.syncAsUint32LE(dummyLong); s.syncAsUint32LE(dummyLong); s.syncAsUint32LE(dummyLong); s.syncAsUint16LE(oe.executeScripts); } }
void SaveLoadManager::syncSavegameData(Common::Serializer &s, int version) { // The brief version 3 had the highscores embedded. They're in a separate file now, so skip if (version == 3 && s.isLoading()) s.skip(100); s.syncBytes(&_vm->_globals->_saveData->_data[0], 2050); syncCharacterLocation(s, _vm->_globals->_saveData->_cloneHopkins); syncCharacterLocation(s, _vm->_globals->_saveData->_realHopkins); syncCharacterLocation(s, _vm->_globals->_saveData->_samantha); for (int i = 0; i < 35; ++i) s.syncAsSint16LE(_vm->_globals->_saveData->_inventory[i]); if (version > 1) { s.syncAsSint16LE(_vm->_globals->_saveData->_mapCarPosX); s.syncAsSint16LE(_vm->_globals->_saveData->_mapCarPosY); } else { _vm->_globals->_saveData->_mapCarPosX = _vm->_globals->_saveData->_mapCarPosY = 0; } }
static void syncFilesDatabase(Common::Serializer &s) { uint8 dummyVal = 0; uint32 tmp; for (int i = 0; i < NUM_FILE_ENTRIES; i++) { dataFileEntry &fe = filesDatabase[i]; s.syncAsUint16LE(fe.widthInColumn); s.syncAsUint16LE(fe.width); s.syncAsUint16LE(fe.resType); s.syncAsUint16LE(fe.height); // Remember whether this file database was open or not. // Upon loading, loadSavegameData uses this information // in order to re-open the file databases accordingly. tmp = (fe.subData.ptr) ? 1 : 0; s.syncAsUint32LE(tmp); if (s.isLoading()) { fe.subData.ptr = tmp ? (uint8 *)1 : 0; } s.syncAsSint16LE(fe.subData.index); s.syncBytes((byte *)fe.subData.name, 13); s.syncAsByte(dummyVal); s.syncAsSint16LE(fe.subData.transparency); // Treat fe.subData.ptrMask the same as fe.subData.ptr. tmp = (fe.subData.ptrMask) ? 1 : 0; s.syncAsUint32LE(tmp); if (s.isLoading()) { fe.subData.ptrMask = tmp ? (uint8 *)1 : 0; } s.syncAsUint16LE(fe.subData.resourceType); s.syncAsSint16LE(fe.subData.compression); } }
static void syncFilesDatabase(Common::Serializer &s) { uint8 dummyVal = 0; uint32 tmp; for (int i = 0; i < NUM_FILE_ENTRIES; i++) { dataFileEntry &fe = filesDatabase[i]; s.syncAsUint16LE(fe.widthInColumn); s.syncAsUint16LE(fe.width); s.syncAsUint16LE(fe.resType); s.syncAsUint16LE(fe.height); // TODO: Have a look at the saving/loading of this pointer tmp = (fe.subData.ptr) ? 1 : 0; s.syncAsUint32LE(tmp); if (s.isLoading()) { fe.subData.ptr = (uint8 *)tmp; } s.syncAsSint16LE(fe.subData.index); s.syncBytes((byte *)fe.subData.name, 13); s.syncAsByte(dummyVal); s.syncAsSint16LE(fe.subData.transparency); // TODO: Have a look at the saving/loading of this pointer tmp = (fe.subData.ptrMask) ? 1 : 0; s.syncAsUint32LE(tmp); if (s.isLoading()) { fe.subData.ptrMask = (uint8 *)tmp; } s.syncAsUint16LE(fe.subData.resourceType); s.syncAsSint16LE(fe.subData.compression); } }
void AvalancheEngine::synchronize(Common::Serializer &sz) { _animation->synchronize(sz); _parser->synchronize(sz); _nim->synchronize(sz); _sequence->synchronize(sz); _background->synchronize(sz); sz.syncAsByte(_carryNum); for (int i = 0; i < kObjectNum; i++) sz.syncAsByte(_objects[i]); sz.syncAsSint16LE(_score); sz.syncAsSint32LE(_money); sz.syncAsByte(_room); if (sz.isSaving()) _saveNum++; sz.syncAsByte(_saveNum); sz.syncBytes(_roomCount, 100); sz.syncAsByte(_wonNim); sz.syncAsByte(_wineState); sz.syncAsByte(_cwytalotGone); sz.syncAsByte(_passwordNum); sz.syncAsByte(_aylesIsAwake); sz.syncAsByte(_drawbridgeOpen); sz.syncAsByte(_avariciusTalk); sz.syncAsByte(_rottenOnion); sz.syncAsByte(_onionInVinegar); sz.syncAsByte(_givenToSpludwick); sz.syncAsByte(_brummieStairs); sz.syncAsByte(_cardiffQuestionNum); sz.syncAsByte(_passedCwytalotInHerts); sz.syncAsByte(_avvyIsAwake); sz.syncAsByte(_avvyInBed); sz.syncAsByte(_userMovesAvvy); sz.syncAsByte(_npcFacing); sz.syncAsByte(_givenBadgeToIby); sz.syncAsByte(_friarWillTieYouUp); sz.syncAsByte(_tiedUp); sz.syncAsByte(_boxContent); sz.syncAsByte(_talkedToCrapulus); sz.syncAsByte(_jacquesState); sz.syncAsByte(_bellsAreRinging); sz.syncAsByte(_standingOnDais); sz.syncAsByte(_takenPen); sz.syncAsByte(_arrowInTheDoor); if (sz.isSaving()) { uint16 like2drinkSize = _favoriteDrink.size(); sz.syncAsUint16LE(like2drinkSize); for (uint16 i = 0; i < like2drinkSize; i++) { char actChr = _favoriteDrink[i]; sz.syncAsByte(actChr); } uint16 favoriteSongSize = _favoriteSong.size(); sz.syncAsUint16LE(favoriteSongSize); for (uint16 i = 0; i < favoriteSongSize; i++) { char actChr = _favoriteSong[i]; sz.syncAsByte(actChr); } uint16 worst_place_on_earthSize = _worstPlaceOnEarth.size(); sz.syncAsUint16LE(worst_place_on_earthSize); for (uint16 i = 0; i < worst_place_on_earthSize; i++) { char actChr = _worstPlaceOnEarth[i]; sz.syncAsByte(actChr); } uint16 spare_eveningSize = _spareEvening.size(); sz.syncAsUint16LE(spare_eveningSize); for (uint16 i = 0; i < spare_eveningSize; i++) { char actChr = _spareEvening[i]; sz.syncAsByte(actChr); } } else { if (!_favoriteDrink.empty()) _favoriteDrink.clear(); uint16 like2drinkSize = 0; char actChr = ' '; sz.syncAsUint16LE(like2drinkSize); for (uint16 i = 0; i < like2drinkSize; i++) { sz.syncAsByte(actChr); _favoriteDrink += actChr; } if (!_favoriteSong.empty()) _favoriteSong.clear(); uint16 favoriteSongSize = 0; sz.syncAsUint16LE(favoriteSongSize); for (uint16 i = 0; i < favoriteSongSize; i++) { sz.syncAsByte(actChr); _favoriteSong += actChr; } if (!_worstPlaceOnEarth.empty()) _worstPlaceOnEarth.clear(); uint16 worst_place_on_earthSize = 0; sz.syncAsUint16LE(worst_place_on_earthSize); for (uint16 i = 0; i < worst_place_on_earthSize; i++) { sz.syncAsByte(actChr); _worstPlaceOnEarth += actChr; } if (!_spareEvening.empty()) _spareEvening.clear(); uint16 spare_eveningSize = 0; sz.syncAsUint16LE(spare_eveningSize); for (uint16 i = 0; i < spare_eveningSize; i++) { sz.syncAsByte(actChr); _spareEvening += actChr; } } sz.syncAsSint32LE(_totalTime); sz.syncAsByte(_jumpStatus); sz.syncAsByte(_mushroomGrowing); sz.syncAsByte(_spludwickAtHome); sz.syncAsByte(_lastRoom); sz.syncAsByte(_lastRoomNotMap); sz.syncAsByte(_crapulusWillTell); sz.syncAsByte(_enterCatacombsFromLustiesRoom); sz.syncAsByte(_teetotal); sz.syncAsByte(_malagauche); sz.syncAsByte(_drinking); sz.syncAsByte(_enteredLustiesRoomAsMonk); sz.syncAsByte(_catacombX); sz.syncAsByte(_catacombY); sz.syncAsByte(_avvysInTheCupboard); sz.syncAsByte(_geidaFollows); sz.syncAsByte(_givenPotionToGeida); sz.syncAsByte(_lustieIsAsleep); sz.syncAsByte(_beenTiedUp); sz.syncAsByte(_sittingInPub); sz.syncAsByte(_spurgeTalkCount); sz.syncAsByte(_metAvaroid); sz.syncAsByte(_takenMushroom); sz.syncAsByte(_givenPenToAyles); sz.syncAsByte(_askedDogfoodAboutNim); for (int i = 0; i < 7; i++) { sz.syncAsSint32LE(_timer->_times[i]._timeLeft); sz.syncAsByte(_timer->_times[i]._action); sz.syncAsByte(_timer->_times[i]._reason); } }
void Sprite::sync(Common::Serializer &s) { uint16 unused = 0; s.syncAsUint16LE(unused); s.syncAsUint16LE(unused); // _ext s.syncAsUint16LE(_ref); s.syncAsByte(_scene); // bitfield in-memory storage is unpredictable, so to avoid // any issues, pack/unpack everything manually uint16 flags = 0; if (s.isLoading()) { s.syncAsUint16LE(flags); _flags._hide = flags & 0x0001 ? true : false; _flags._near = flags & 0x0002 ? true : false; _flags._drag = flags & 0x0004 ? true : false; _flags._hold = flags & 0x0008 ? true : false; _flags._____ = flags & 0x0010 ? true : false; _flags._slav = flags & 0x0020 ? true : false; _flags._syst = flags & 0x0040 ? true : false; _flags._kill = flags & 0x0080 ? true : false; _flags._xlat = flags & 0x0100 ? true : false; _flags._port = flags & 0x0200 ? true : false; _flags._kept = flags & 0x0400 ? true : false; _flags._east = flags & 0x0800 ? true : false; _flags._shad = flags & 0x1000 ? true : false; _flags._back = flags & 0x2000 ? true : false; _flags._bDel = flags & 0x4000 ? true : false; _flags._tran = flags & 0x8000 ? true : false; } else { flags = (flags << 1) | _flags._tran; flags = (flags << 1) | _flags._bDel; flags = (flags << 1) | _flags._back; flags = (flags << 1) | _flags._shad; flags = (flags << 1) | _flags._east; flags = (flags << 1) | _flags._kept; flags = (flags << 1) | _flags._port; flags = (flags << 1) | _flags._xlat; flags = (flags << 1) | _flags._kill; flags = (flags << 1) | _flags._syst; flags = (flags << 1) | _flags._slav; flags = (flags << 1) | _flags._____; flags = (flags << 1) | _flags._hold; flags = (flags << 1) | _flags._drag; flags = (flags << 1) | _flags._near; flags = (flags << 1) | _flags._hide; s.syncAsUint16LE(flags); } s.syncAsUint16LE(_x); s.syncAsUint16LE(_y); s.syncAsByte(_z); s.syncAsUint16LE(_w); s.syncAsUint16LE(_h); s.syncAsUint16LE(_time); s.syncAsByte(_nearPtr); s.syncAsByte(_takePtr); s.syncAsSint16LE(_seqPtr); s.syncAsUint16LE(_shpCnt); s.syncBytes((byte *)&_file[0], 9); _file[8] = '\0'; s.syncAsUint16LE(unused); // _prev s.syncAsUint16LE(unused); // _next }
static void syncPalette(Common::Serializer &s, uint8 *p) { // This is different from the original, where palette entries are 2 bytes each s.syncBytes(p, NBCOLORS * 3); }
static void syncIncrust(Common::Serializer &s) { int numEntries = 0; backgroundIncrustStruct *pl, *pl1; uint8 dummyByte = 0; uint16 dummyWord = 0; uint32 dummyLong = 0; if (s.isSaving()) { // Figure out the number of entries to save pl = backgroundIncrustHead.next; while (pl) { ++numEntries; pl = pl->next; } } s.syncAsSint16LE(numEntries); pl = s.isSaving() ? backgroundIncrustHead.next : &backgroundIncrustHead; pl1 = &backgroundIncrustHead; for (int i = 0; i < numEntries; ++i) { backgroundIncrustStruct *t = s.isSaving() ? pl : (backgroundIncrustStruct *)mallocAndZero(sizeof(backgroundIncrustStruct)); s.syncAsUint32LE(dummyLong); s.syncAsSint16LE(t->objectIdx); s.syncAsSint16LE(t->type); s.syncAsSint16LE(t->overlayIdx); s.syncAsSint16LE(t->X); s.syncAsSint16LE(t->Y); s.syncAsSint16LE(t->frame); s.syncAsSint16LE(t->scale); s.syncAsSint16LE(t->backgroundIdx); s.syncAsSint16LE(t->scriptNumber); s.syncAsSint16LE(t->scriptOverlayIdx); s.syncAsUint32LE(dummyLong); s.syncAsSint16LE(t->saveWidth); s.syncAsSint16LE(t->saveHeight); s.syncAsSint16LE(t->saveSize); s.syncAsSint16LE(t->savedX); s.syncAsSint16LE(t->savedY); s.syncBytes((byte *)t->name, 13); s.syncAsByte(dummyByte); s.syncAsSint16LE(t->spriteId); s.syncAsUint16LE(dummyWord); if (t->saveSize) { if (s.isLoading()) t->ptr = (byte *)MemAlloc(t->saveSize); s.syncBytes(t->ptr, t->saveSize); } if (s.isSaving()) pl = pl->next; else { t->next = NULL; pl->next = t; t->prev = pl1->prev; pl1->prev = t; pl = t; } } }
bool BuriedEngine::syncGlobalFlags(Common::Serializer &s, GlobalFlags &flags) { uint32 startBytes = s.bytesSynced(); s.syncAsByte(flags.cgWallExploded); s.syncAsByte(flags.cgHookPresent); s.syncAsByte(flags.cgArrowPresent); s.syncAsByte(flags.cgHammerPresent); s.syncAsByte(flags.cgSmithyStatus); s.syncAsByte(flags.cgSmithyGuard); s.syncAsByte(flags.cgBaileyOneWayGuard); s.syncAsByte(flags.cgBaileyTwoWayGuards); s.syncAsByte(flags.cgTapestryFlag); s.syncAsByte(flags.cgBurnedLetterPresent); s.syncAsByte(flags.cgGoldCoinsPresent); s.syncAsByte(flags.cgStorageRoomVisit); s.syncAsByte(flags.bcTranslateEnabled); s.syncAsByte(flags.bcCloakingEnabled); s.syncAsByte(flags.bcLocateEnabled); s.syncAsByte(flags.myPickedUpCeramicBowl); s.syncAsByte(flags.myTPCodeWheelStatus); s.syncAsByte(flags.myTPCodeWheelLeftIndex); s.syncAsByte(flags.myTPCodeWheelRightIndex); s.syncAsByte(flags.myMCPickedUpSkull); s.syncAsByte(flags.myMCDeathGodOfferings); s.syncAsByte(flags.myWGPlacedRope); s.syncAsByte(flags.myWGRetrievedJadeBlock); s.syncAsByte(flags.myWTRetrievedLimestoneBlock); s.syncAsByte(flags.myWTCurrentBridgeStatus); s.syncAsByte(flags.myAGRetrievedEntrySkull); s.syncAsByte(flags.myAGRetrievedSpearSkull); s.syncAsByte(flags.myAGRetrievedCopperMedal); s.syncAsByte(flags.myAGRetrievedObsidianBlock); s.syncAsByte(flags.myAGHeadAStatus); s.syncAsByte(flags.myAGHeadBStatus); s.syncAsByte(flags.myAGHeadCStatus); s.syncAsByte(flags.myAGHeadDStatus); s.syncAsByte(flags.myAGHeadAStatusSkullID); s.syncAsByte(flags.myAGHeadBStatusSkullID); s.syncAsByte(flags.myAGHeadCStatusSkullID); s.syncAsByte(flags.myAGHeadDStatusSkullID); s.syncAsByte(flags.myAGTimerHeadID); SYNC_FLAG_UINT32(myAGTimerStartTime); s.syncAsByte(flags.myDGOfferedHeart); s.syncAsByte(flags.takenEnvironCart); s.syncAsByte(flags.alRDTakenLiveCore); s.syncAsByte(flags.alRDTakenDeadCore); s.syncAsByte(flags.alNMWrongAlienPrefixCode); s.syncAsByte(flags.faKIOvenStatus); s.syncAsByte(flags.faKIPostBoxSlotA); s.syncAsByte(flags.faKIPostBoxSlotB); s.syncAsByte(flags.faKIPostBoxSlotC); s.syncAsByte(flags.faERCurrentCartridge); s.syncAsByte(flags.faERTakenRemoteControl); s.syncAsByte(flags.myMCStingerID); s.syncAsByte(flags.myMCStingerChannelID); s.syncAsByte(flags.faStingerID); s.syncAsByte(flags.faStingerChannelID); s.syncBytes(flags.unused0, sizeof(flags.unused0)); SYNC_FLAG_UINT32(cgMWCatapultData); SYNC_FLAG_UINT32(cgMWCatapultOffset); s.syncAsByte(flags.cgTSTriedDoor); s.syncAsByte(flags.cgMBCrossedMoat); s.syncAsByte(flags.cgKSSmithyEntryRead); s.syncAsByte(flags.cgKSSmithyEntryTranslated); s.syncAsByte(flags.cgBSFoundMold); s.syncAsByte(flags.readBurnedLetter); s.syncAsByte(flags.evcapNumCaptured); s.syncBytes(flags.evcapBaseID, sizeof(flags.evcapBaseID)); s.syncBytes(flags.unused1, sizeof(flags.unused1)); s.syncAsByte(flags.faMNEnvironDoor); s.syncAsByte(flags.faMNClockClicked); s.syncAsByte(flags.faMNBooksClicked); s.syncAsByte(flags.faMNTazClicked); s.syncAsByte(flags.faMNPongClicked); s.syncAsByte(flags.faKIBirdsBobbed); s.syncAsByte(flags.faKICoffeeSpilled); s.syncAsByte(flags.cgViewedKeepPlans); s.syncAsByte(flags.cgFoundChestPanel); s.syncAsByte(flags.cgTRFoundSword); s.syncAsByte(flags.faHeardAgentFigure); s.syncAsByte(flags.jumpBCNoInfoMessageCycle); s.syncAsByte(flags.myTPCalendarTopTranslated); s.syncAsByte(flags.myTPCalendarListTranslated); s.syncAsByte(flags.myTPTextTranslated); s.syncAsByte(flags.myMCTransDoor); s.syncAsByte(flags.myMCTransAGOffering); s.syncAsByte(flags.myMCTransWGOffering); s.syncAsByte(flags.myMCTransWTOffering); s.syncAsByte(flags.myMCTransDGOffering); s.syncAsByte(flags.myMCTransMadeAnOffering); s.syncAsByte(flags.myWGTransDoorTop); s.syncAsByte(flags.myWGSeenLowerPassage); s.syncAsByte(flags.myWGCrossedRopeBridge); s.syncAsByte(flags.myMCViewedDeathGodDoor); s.syncAsByte(flags.myTPTransBreathOfItzamna); SYNC_FLAG_UINT32(myAGHeadAOpenedTime); SYNC_FLAG_UINT32(myAGHeadBOpenedTime); SYNC_FLAG_UINT32(myAGHeadCOpenedTime); SYNC_FLAG_UINT32(myAGHeadDOpenedTime); s.syncAsByte(flags.myAGHeadATouched); s.syncAsByte(flags.myAGHeadBTouched); s.syncAsByte(flags.myAGHeadCTouched); s.syncAsByte(flags.myAGHeadDTouched); s.syncAsByte(flags.lensFilterActivated); s.syncAsByte(flags.dsPTElevatorPresent); s.syncAsByte(flags.dsPTElevatorLeverA); s.syncAsByte(flags.dsPTElevatorLeverB); s.syncAsByte(flags.dsPTDoorLocked); s.syncAsByte(flags.dsWSPickedUpWheelAssembly); s.syncAsByte(flags.dsWSPickedUpGearAssembly); s.syncAsByte(flags.dsWSPickedUpPegs); s.syncAsByte(flags.dsWSSiegeCycleStatus); s.syncAsByte(flags.dsWSGrabbedSiegeCycle); s.syncAsByte(flags.dsPTUseElevatorControls); s.syncAsByte(flags.dsPTTransElevatorControls); s.syncAsByte(flags.dsGDTakenCoilOfRope); s.syncAsByte(flags.dsCTUnlockedDoor); s.syncAsByte(flags.dsCTViewedAgent3); s.syncAsByte(flags.dsPTViewedAgent3); s.syncAsByte(flags.dsCTRetrievedLens); s.syncAsByte(flags.dsCTTakenHeart); s.syncAsByte(flags.dsCYFiredCannon); s.syncAsByte(flags.dsCYBallistaStatus); s.syncAsByte(flags.dsCYPlacedSiegeCycle); s.syncAsByte(flags.dsCYBallistaXPos); s.syncAsByte(flags.dsCYBallistaYPos); s.syncAsByte(flags.aiHWStingerID); s.syncAsByte(flags.aiHWStingerChannelID); s.syncAsByte(flags.aiCRStingerID); s.syncAsByte(flags.aiCRStingerChannelID); s.syncAsByte(flags.aiDBStingerID); s.syncAsByte(flags.aiDBStingerChannelID); s.syncAsByte(flags.aiCRGrabbedMetalBar); s.syncAsByte(flags.aiICGrabbedWaterCanister); s.syncAsByte(flags.aiOxygenTimer); s.syncAsByte(flags.aiCRPressurized); s.syncAsByte(flags.aiCRPressurizedAttempted); s.syncAsByte(flags.aiMRPressurized); s.syncAsByte(flags.aiIceMined); s.syncAsByte(flags.aiOxygenReserves); s.syncAsByte(flags.aiSCHeardInitialSpeech); s.syncAsByte(flags.aiSCInitialAudioChannel); s.syncAsByte(flags.aiSCDBDoorWarning); s.syncAsByte(flags.aiSCMoveCenterWarning); s.syncAsByte(flags.aiSCConversationStatus); s.syncAsByte(flags.aiHWIceDoorUnlocked); s.syncAsByte(flags.aiICWaterInFillHandle); s.syncAsByte(flags.aiICTakenWaterCanister); s.syncAsByte(flags.aiSWStingerID); s.syncAsByte(flags.aiSWStingerChannelID); s.syncAsByte(flags.aiMRCorrectFreqSet); s.syncAsByte(flags.aiSCHeardNexusDoorComment); s.syncAsByte(flags.aiSCHeardNexusDoorCode); s.syncAsByte(flags.asInitialGuardsPass); s.syncAsByte(flags.asRBPodAStatus); s.syncAsByte(flags.asRBPodBStatus); s.syncAsByte(flags.asRBPodCStatus); s.syncAsByte(flags.asRBPodDStatus); s.syncAsByte(flags.asRBPodEStatus); s.syncAsByte(flags.asRBPodFStatus); s.syncAsByte(flags.asRBPodATakenEnvironCart); s.syncAsByte(flags.asRBPodBTakenPuzzleBox); s.syncAsByte(flags.asRBPodCTakenCodex); s.syncAsByte(flags.asRBPodDTakenSculpture); s.syncAsByte(flags.asRBPodETakenSword); s.syncAsByte(flags.asTakenEvidenceThisTrip); s.syncAsByte(flags.asDangerDoorASealed); s.syncAsByte(flags.asDoorBGuardsSeen); s.syncAsByte(flags.asAmbassadorEncounter); s.syncAsByte(flags.dsCTTriedLockedDoor); s.syncAsByte(flags.dsCTCodexTranslateAttempted); s.syncAsByte(flags.dsCTCodexFormulaeFound); s.syncAsByte(flags.dsCTCodexAtlanticusPage2); s.syncAsByte(flags.dsCTTriedElevatorControls); s.syncAsByte(flags.aiDBPlayedMomComment); s.syncAsByte(flags.aiDBPlayedFirstArthur); s.syncAsByte(flags.aiDBPlayedSecondArthur); s.syncAsByte(flags.aiDBPlayedThirdArthur); s.syncAsByte(flags.aiDBPlayedFourthArthur); s.syncAsByte(flags.aiSCPlayedNoStinger); s.syncAsByte(flags.faKITakenPostboxItem); s.syncAsByte(flags.cgMBVisited); s.syncAsByte(flags.cgKCVisited); s.syncAsByte(flags.cgTRVisited); s.syncAsByte(flags.cgKSReadJournal); s.syncAsByte(flags.cgSRClickedOnLockedChest); s.syncAsByte(flags.cgSROpenedChest); s.syncAsByte(flags.dsVisitedCodexTower); s.syncAsByte(flags.dsPTRaisedPlatform); s.syncAsByte(flags.dsPTWalkedDownElevator); s.syncAsByte(flags.dsPTBeenOnBalcony); s.syncAsByte(flags.dsGDClickedOnCodexDoor); s.syncAsByte(flags.dsWSSeenCycleSketch); s.syncAsByte(flags.dsWSSeenBallistaSketch); s.syncAsByte(flags.genHadSiegeCycle); s.syncAsByte(flags.genHadDriveAssembly); s.syncAsByte(flags.genHadWheelAssembly); s.syncAsByte(flags.dsCYNeverConnectedHook); s.syncAsByte(flags.dsCYNeverShotBallista); s.syncAsByte(flags.dsCYNeverUsedCrank); s.syncAsByte(flags.dsCYNeverOpenedBalconyDoor); s.syncAsByte(flags.dsCYTranslatedCodex); s.syncAsByte(flags.dsCYTriedOpeningDoor); s.syncAsByte(flags.dsCYTriedElevator); s.syncAsByte(flags.dsCYFoundCodexes); s.syncAsByte(flags.myVisitedMainCavern); s.syncAsByte(flags.myVisitedArrowGod); s.syncAsByte(flags.myVisitedWaterGod); s.syncAsByte(flags.myVisitedWealthGod); s.syncAsByte(flags.myVisitedDeathGod); s.syncAsByte(flags.myVisitedSpecRooms); s.syncAsByte(flags.myWTSteppedOnSwings); s.syncAsByte(flags.myWTSteppedOnFarLedge); s.syncAsByte(flags.myDGOpenedPuzzleBox); s.syncAsByte(flags.myAGVisitedAltar); s.syncAsByte(flags.dsCTPlayedBallistaFalling); s.syncAsByte(flags.cgTSTriedDoorA); s.syncAsByte(flags.cgTSTriedDoorB); s.syncAsByte(flags.aiHWLastCommentPlayed); s.syncAsByte(flags.aiNXPlayedBrainComment); s.syncAsByte(flags.asRBLastStingerID); s.syncAsByte(flags.asRBStingerID); s.syncAsByte(flags.aiICProcessedOxygen); s.syncAsByte(flags.dsCYWeebleClicked); s.syncAsByte(flags.aiICUsedMiningControls); s.syncAsByte(flags.aiSWAttemptedPresMR); s.syncAsByte(flags.aiICRefilledOxygen); s.syncAsByte(flags.aiMRUsedHarmonicsInterface); s.syncAsByte(flags.alRestoreSkipAgent3Initial); s.syncBytes(flags.unused2, sizeof(flags.unused2)); s.syncAsByte(flags.scoreGotTranslateBioChip); s.syncAsByte(flags.scoreEnteredSpaceStation); s.syncAsByte(flags.scoreDownloadedArthur); s.syncAsByte(flags.scoreFoundSculptureDiagram); s.syncAsByte(flags.scoreEnteredKeep); s.syncAsByte(flags.scoreGotKeyFromSmithy); s.syncAsByte(flags.scoreEnteredTreasureRoom); s.syncAsByte(flags.scoreFoundSwordDiamond); s.syncAsByte(flags.scoreMadeSiegeCycle); s.syncAsByte(flags.scoreEnteredCodexTower); s.syncAsByte(flags.scoreLoggedCodexEvidence); s.syncAsByte(flags.scoreEnteredMainCavern); s.syncAsByte(flags.scoreGotWealthGodPiece); s.syncAsByte(flags.scoreGotRainGodPiece); s.syncAsByte(flags.scoreGotWarGodPiece); s.syncAsByte(flags.scoreCompletedDeathGod); s.syncAsByte(flags.scoreEliminatedAgent3); s.syncAsByte(flags.scoreTransportToKrynn); s.syncAsByte(flags.scoreGotKrynnArtifacts); s.syncAsByte(flags.scoreDefeatedIcarus); s.syncAsByte(flags.scoreResearchINNLouvreReport); s.syncAsByte(flags.scoreResearchINNHighBidder); s.syncAsByte(flags.scoreResearchINNAppeal); s.syncAsByte(flags.scoreResearchINNUpdate); s.syncAsByte(flags.scoreResearchINNJumpsuit); s.syncAsByte(flags.scoreResearchBCJumpsuit); s.syncAsByte(flags.scoreResearchMichelle); s.syncAsByte(flags.scoreResearchMichelleBkg); s.syncAsByte(flags.scoreResearchLensFilter); s.syncAsByte(flags.scoreResearchCastleFootprint); s.syncAsByte(flags.scoreResearchDaVinciFootprint); s.syncAsByte(flags.scoreResearchMorphSculpture); s.syncAsByte(flags.scoreResearchEnvironCart); s.syncAsByte(flags.scoreResearchAgent3Note); s.syncAsByte(flags.scoreResearchAgent3DaVinci); SYNC_FLAG_UINT16(scoreHintsTotal); s.syncBytes(flags.unused3, sizeof(flags.unused3)); s.syncAsByte(flags.genJumpCastleBriefing); s.syncAsByte(flags.genJumpMayanBriefing); s.syncAsByte(flags.genJumpDaVinciBriefing); s.syncAsByte(flags.genJumpStationBriefing); s.syncBytes(flags.unused4, sizeof(flags.unused4)); s.syncAsByte(flags.generalWalkthroughMode); s.syncBytes(flags.unused5, sizeof(flags.unused5)); s.syncBytes(flags.aiData, sizeof(flags.aiData)); return s.bytesSynced() - startBytes == 1024; }
static void syncOverlays2(Common::Serializer &s) { for (int i = 1; i < numOfLoadedOverlay; i++) { if (s.isSaving()) { // Saving code if (!overlayTable[i].alreadyLoaded) continue; ovlDataStruct *ovlData = overlayTable[i].ovlData; // save BSS s.syncAsSint16LE(ovlData->sizeOfData4); if (ovlData->sizeOfData4) s.syncBytes(ovlData->data4Ptr, ovlData->sizeOfData4); // save variables s.syncAsSint16LE(ovlData->size9); for (int j = 0; j < ovlData->size9; j++) { s.syncAsSint16LE(ovlData->arrayObjVar[j].X); s.syncAsSint16LE(ovlData->arrayObjVar[j].Y); s.syncAsSint16LE(ovlData->arrayObjVar[j].Z); s.syncAsSint16LE(ovlData->arrayObjVar[j].frame); s.syncAsSint16LE(ovlData->arrayObjVar[j].scale); s.syncAsSint16LE(ovlData->arrayObjVar[j].state); } } else { // Loading code ovlRestoreData[i]._sBssSize = ovlRestoreData[i]._sNumObj = 0; ovlRestoreData[i]._pBss = NULL; ovlRestoreData[i]._pObj = NULL; if (overlayTable[i].alreadyLoaded) { s.syncAsSint16LE(ovlRestoreData[i]._sBssSize); if (ovlRestoreData[i]._sBssSize) { ovlRestoreData[i]._pBss = (uint8 *) mallocAndZero(ovlRestoreData[i]._sBssSize); ASSERT(ovlRestoreData[i]._pBss); s.syncBytes(ovlRestoreData[i]._pBss, ovlRestoreData[i]._sBssSize); } s.syncAsSint16LE(ovlRestoreData[i]._sNumObj); if (ovlRestoreData[i]._sNumObj) { ovlRestoreData[i]._pObj = (objectParams *) mallocAndZero(ovlRestoreData[i]._sNumObj * sizeof(objectParams)); ASSERT(ovlRestoreData[i]._pObj); for (int j = 0; j < ovlRestoreData[i]._sNumObj; j++) { s.syncAsSint16LE(ovlRestoreData[i]._pObj[j].X); s.syncAsSint16LE(ovlRestoreData[i]._pObj[j].Y); s.syncAsSint16LE(ovlRestoreData[i]._pObj[j].Z); s.syncAsSint16LE(ovlRestoreData[i]._pObj[j].frame); s.syncAsSint16LE(ovlRestoreData[i]._pObj[j].scale); s.syncAsSint16LE(ovlRestoreData[i]._pObj[j].state); } } } } } }
void Sequence::synchronize(Common::Serializer &sz) { sz.syncBytes(_seq, kSeqLength); sz.syncAsByte(_flipToWhere); sz.syncAsByte(_flipToPed); }