static void syncCell(Common::Serializer &s) { int chunkCount = 0; cellStruct *t, *p; uint16 dummyWord = 0; if (s.isSaving()) { // Figure out the number of chunks to save t = cellHead.next; while (t) { ++chunkCount; t = t->next; } } else { cellHead.next = NULL; // Not in ASM code, but I guess the variable is defaulted in the EXE } s.syncAsSint16LE(chunkCount); t = s.isSaving() ? cellHead.next : &cellHead; for (int i = 0; i < chunkCount; ++i) { p = s.isSaving() ? t : (cellStruct *)mallocAndZero(sizeof(cellStruct)); s.syncAsUint16LE(dummyWord); s.syncAsUint16LE(dummyWord); s.syncAsSint16LE(p->idx); s.syncAsSint16LE(p->type); s.syncAsSint16LE(p->overlay); s.syncAsSint16LE(p->x); s.syncAsSint16LE(p->field_C); s.syncAsSint16LE(p->spriteIdx); s.syncAsSint16LE(p->color); s.syncAsSint16LE(p->backgroundPlane); s.syncAsSint16LE(p->freeze); s.syncAsSint16LE(p->parent); s.syncAsSint16LE(p->parentOverlay); s.syncAsSint16LE(p->parentType); s.syncAsSint16LE(p->followObjectOverlayIdx); s.syncAsSint16LE(p->followObjectIdx); s.syncAsSint16LE(p->animStart); s.syncAsSint16LE(p->animEnd); s.syncAsSint16LE(p->animWait); s.syncAsSint16LE(p->animStep); s.syncAsSint16LE(p->animChange); s.syncAsSint16LE(p->animType); s.syncAsSint16LE(p->animSignal); s.syncAsSint16LE(p->animCounter); s.syncAsSint16LE(p->animLoop); s.syncAsUint16LE(dummyWord); if (s.isSaving()) t = t->next; else { p->next = NULL; t->next = p; p->prev = cellHead.prev; cellHead.prev = p; t = p; } } }
static void syncSavedActor(Common::Serializer &s, SAVED_ACTOR &sa) { s.syncAsUint16LE(sa.actorID); s.syncAsUint16LE(sa.zFactor); s.syncAsUint16LE(sa.bAlive); s.syncAsUint16LE(sa.bHidden); s.syncAsUint32LE(sa.presFilm); s.syncAsUint16LE(sa.presRnum); s.syncAsUint16LE(sa.presPlayX); s.syncAsUint16LE(sa.presPlayY); }
void Scene::synchronize(Common::Serializer &s) { _action.synchronize(s); _rails.synchronize(s); _userInterface.synchronize(s); s.syncAsByte(_reloadSceneFlag); s.syncAsByte(_roomChanged); s.syncAsUint16LE(_nextSceneId); s.syncAsUint16LE(_priorSceneId); _dynamicHotspots.synchronize(s); }
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 void syncTime(Common::Serializer &s, TimeDate &t) { s.syncAsUint16LE(t.tm_year); s.syncAsByte(t.tm_mon); s.syncAsByte(t.tm_mday); s.syncAsByte(t.tm_hour); s.syncAsByte(t.tm_min); s.syncAsByte(t.tm_sec); }
static void syncSoundList(Common::Serializer &s) { for (int i = 0; i < 4; ++i) { SoundEntry &se = soundList[i]; s.syncAsSint16LE(se.frameNum); s.syncAsUint16LE(se.frequency); s.syncAsSint16LE(se.volume); } }
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)); } }
void Game::synchronize(Common::Serializer &s, bool phase1) { if (phase1) { s.syncAsSint16LE(_fx); s.syncAsSint16LE(_trigger); s.syncAsUint16LE(_triggerSetupMode); s.syncAsUint16LE(_triggerMode); s.syncString(_aaName); s.syncAsSint16LE(_lastSave); _scene.synchronize(s); _objects.synchronize(s); _visitedScenes.synchronize(s, _scene._nextSceneId); _player.synchronize(s); _screenObjects.synchronize(s); } else { // Load scene specific data for the loaded scene _scene._sceneLogic->synchronize(s); } }
void CGE2Engine::syncHeader(Common::Serializer &s) { s.syncAsUint16LE(_now); s.syncAsUint16LE(_sex); s.syncAsUint16LE(_vga->_rot._len); s.syncAsUint16LE(_waitSeq); s.syncAsUint16LE(_waitRef); 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 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 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 syncBasicInfo(Common::Serializer &s) { s.syncAsSint16LE(activeMouse); s.syncAsSint16LE(userEnabled); s.syncAsSint16LE(dialogueEnabled); s.syncAsSint16LE(dialogueOvl); s.syncAsSint16LE(dialogueObj); s.syncAsSint16LE(userDelay); s.syncAsSint16LE(sysKey); s.syncAsSint16LE(sysX); s.syncAsSint16LE(sysY); s.syncAsSint16LE(automoveInc); s.syncAsSint16LE(automoveMax); s.syncAsSint16LE(displayOn); s.syncAsSint16LE(isMessage); s.syncAsSint16LE(fadeFlag); s.syncAsSint16LE(automaticMode); s.syncAsSint16LE(titleColor); s.syncAsSint16LE(itemColor); s.syncAsSint16LE(selectColor); s.syncAsSint16LE(subColor); s.syncAsSint16LE(narratorOvl); s.syncAsSint16LE(narratorIdx); s.syncAsSint16LE(aniX); s.syncAsSint16LE(aniY); s.syncAsUint16LE(animationStart); s.syncAsSint16LE(masterScreen); s.syncAsSint16LE(switchPal); s.syncAsSint16LE(scroll); s.syncAsSint16LE(fadeFlag); s.syncAsSint16LE(doFade); s.syncAsSint16LE(numOfLoadedOverlay); s.syncAsSint16LE(stateID); s.syncAsSint16LE(fontFileIndex); s.syncAsSint16LE(currentActiveMenu); s.syncAsSint16LE(userWait); s.syncAsSint16LE(autoOvl); s.syncAsSint16LE(autoMsg); s.syncAsSint16LE(autoTrack); s.syncAsSint16LE(var39); s.syncAsSint16LE(var42); s.syncAsSint16LE(var45); s.syncAsSint16LE(var46); s.syncAsSint16LE(var47); s.syncAsSint16LE(var48); s.syncAsSint16LE(flagCt); s.syncAsSint16LE(var41); s.syncAsSint16LE(playerMenuEnabled); s.syncAsSint16LE(protectionCode); }
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 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 StopWalkers::synchronize(Common::Serializer &s) { StopWalkerEntry rec; int count = size(); s.syncAsUint16LE(count); if (s.isLoading()) { clear(); for (int idx = 0; idx < count; ++idx) { rec.synchronize(s); push(rec); } } else { for (int idx = 0; idx < count; ++idx) (*this)[idx].synchronize(s); } }
void EntityData::EntityCallData::saveLoadWithSerializer(Common::Serializer &s) { for (uint i = 0; i < ARRAYSIZE(callbacks); i++) s.syncAsByte(callbacks[i]); s.syncAsByte(currentCall); s.syncAsUint16LE(entityPosition); s.syncAsUint16LE(location); s.syncAsUint16LE(car); s.syncAsByte(field_497); s.syncAsByte(entity); s.syncAsByte(inventoryItem); s.syncAsByte(direction); s.syncAsUint16LE(field_49B); s.syncAsUint16LE(currentFrame); s.syncAsUint16LE(currentFrame2); s.syncAsUint16LE(field_4A1); s.syncAsUint16LE(field_4A3); s.syncAsByte(clothes); s.syncAsByte(position); s.syncAsByte(car2); s.syncAsByte(doProcessEntity); s.syncAsByte(field_4A9); s.syncAsByte(field_4AA); s.syncAsByte(directionSwitch); // Sync strings #define SYNC_STRING(varName, count) { \ char seqName[13]; \ memset(&seqName, 0, count); \ if (s.isSaving()) strcpy((char *)&seqName, varName.c_str()); \ s.syncBytes((byte *)&seqName, count); \ if (s.isLoading()) varName = seqName; \ } SYNC_STRING(sequenceName, 13); SYNC_STRING(sequenceName2, 13); SYNC_STRING(sequenceNamePrefix, 7); SYNC_STRING(sequenceNameCopy, 13); #undef SYNC_STRING // Skip pointers to frame & sequences s.skip(5 * 4); }
void Sprite::saveLoadWithSerializer(Common::Serializer &ser) { ser.syncAsSint16LE(pos.x); ser.syncAsSint16LE(pos.y); ser.syncAsUint16LE(drawPriority); ser.syncAsUint16LE(drawPriority2); ser.syncString(field8); // Note: bitmap must be reloaded ser.syncAsUint16LE(drawMode); ser.syncAsUint16LE(textColor); ser.syncAsUint16LE(bitmapChanged); ser.syncAsUint16LE(rect2Valid); ser.syncAsUint16LE(isOnScreen); ser.syncAsUint16LE(field16); serializeRect(lastDrawRect, ser); serializeRect(drawRect, ser); serializeRect(rectangle2, ser); ser.syncAsSint16LE(drawX); ser.syncAsSint16LE(drawY); }
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 ActionDetails::synchronize(Common::Serializer &s) { s.syncAsUint16LE(_verbId); s.syncAsUint16LE(_objectNameId); s.syncAsUint16LE(_indirectObjectId); }
static void syncPalScreen(Common::Serializer &s) { for (int i = 0; i < NBSCREENS; ++i) { for (int j = 0; j < NBCOLORS; ++j) s.syncAsUint16LE(palScreen[i][j]); } }
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; } } }
void MystGameState::syncGameState(Common::Serializer &s, bool isME) { // Globals first s.syncAsUint16LE(_globals.u0); s.syncAsUint16LE(_globals.currentAge); s.syncAsUint16LE(_globals.heldPage); s.syncAsUint16LE(_globals.u1); s.syncAsUint16LE(_globals.transitions); s.syncAsUint16LE(_globals.zipMode); s.syncAsUint16LE(_globals.redPagesInBook); s.syncAsUint16LE(_globals.bluePagesInBook); // Onto Myst if (isME) { s.syncAsUint32LE(_myst.cabinMarkerSwitch); s.syncAsUint32LE(_myst.clockTowerMarkerSwitch); s.syncAsUint32LE(_myst.dockMarkerSwitch); s.syncAsUint32LE(_myst.poolMarkerSwitch); s.syncAsUint32LE(_myst.gearsMarkerSwitch); s.syncAsUint32LE(_myst.generatorMarkerSwitch); s.syncAsUint32LE(_myst.observatoryMarkerSwitch); s.syncAsUint32LE(_myst.rocketshipMarkerSwitch); } else { s.syncAsByte(_myst.cabinMarkerSwitch); s.syncAsByte(_myst.clockTowerMarkerSwitch); s.syncAsByte(_myst.dockMarkerSwitch); s.syncAsByte(_myst.poolMarkerSwitch); s.syncAsByte(_myst.gearsMarkerSwitch); s.syncAsByte(_myst.generatorMarkerSwitch); s.syncAsByte(_myst.observatoryMarkerSwitch); s.syncAsByte(_myst.rocketshipMarkerSwitch); } s.syncAsUint16LE(_myst.greenBookOpenedBefore); s.syncAsUint16LE(_myst.shipFloating); s.syncAsUint16LE(_myst.cabinValvePosition); s.syncAsUint16LE(_myst.clockTowerHourPosition); s.syncAsUint16LE(_myst.clockTowerMinutePosition); s.syncAsUint16LE(_myst.gearsOpen); s.syncAsUint16LE(_myst.clockTowerBridgeOpen); s.syncAsUint16LE(_myst.generatorBreakers); s.syncAsUint16LE(_myst.generatorButtons); s.syncAsUint16LE(_myst.generatorVoltage); s.syncAsUint16LE(_myst.libraryBookcaseDoor); s.syncAsUint16LE(_myst.imagerSelection); s.syncAsUint16LE(_myst.imagerActive); s.syncAsUint16LE(_myst.imagerWaterErased); s.syncAsUint16LE(_myst.imagerMountainErased); s.syncAsUint16LE(_myst.imagerAtrusErased); s.syncAsUint16LE(_myst.imagerMarkerErased); s.syncAsUint16LE(_myst.towerRotationAngle); s.syncAsUint16LE(_myst.courtyardImageBoxes); s.syncAsUint16LE(_myst.cabinPilotLightLit); s.syncAsUint16LE(_myst.observatoryDaySetting); s.syncAsUint16LE(_myst.observatoryLights); s.syncAsUint16LE(_myst.observatoryMonthSetting); s.syncAsUint16LE(_myst.observatoryTimeSetting); s.syncAsUint16LE(_myst.observatoryYearSetting); s.syncAsUint16LE(_myst.observatoryDayTarget); s.syncAsUint16LE(_myst.observatoryMonthTarget); s.syncAsUint16LE(_myst.observatoryTimeTarget); s.syncAsUint16LE(_myst.observatoryYearTarget); s.syncAsUint16LE(_myst.cabinSafeCombination); s.syncAsUint16LE(_myst.treePosition); s.syncAsUint32LE(_myst.treeLastMoveTime); for (int i = 0; i < 5; i++) s.syncAsUint16LE(_myst.rocketSliderPosition[i]); s.syncAsUint16LE(_myst.observatoryDaySlider); s.syncAsUint16LE(_myst.observatoryMonthSlider); s.syncAsUint16LE(_myst.observatoryYearSlider); s.syncAsUint16LE(_myst.observatoryTimeSlider); // Channelwood if (isME) { s.syncAsUint32LE(_channelwood.waterPumpBridgeState); s.syncAsUint32LE(_channelwood.elevatorState); s.syncAsUint32LE(_channelwood.stairsLowerDoorState); s.syncAsUint32LE(_channelwood.pipeState); } else { s.syncAsByte(_channelwood.waterPumpBridgeState); s.syncAsByte(_channelwood.elevatorState); s.syncAsByte(_channelwood.stairsLowerDoorState); s.syncAsByte(_channelwood.pipeState); } s.syncAsUint16LE(_channelwood.waterValveStates); s.syncAsUint16LE(_channelwood.holoprojectorSelection); s.syncAsUint16LE(_channelwood.stairsUpperDoorState); if (isME) s.skip(4); else s.skip(1); // Mechanical s.syncAsUint16LE(_mechanical.achenarPanelState); s.syncAsUint16LE(_mechanical.sirrusPanelState); s.syncAsUint16LE(_mechanical.staircaseState); s.syncAsUint16LE(_mechanical.elevatorRotation); for (int i = 0; i < 4; i++) s.syncAsUint16LE(_mechanical.codeShape[i]); // Selenitic if (isME) { s.syncAsUint32LE(_selenitic.emitterEnabledWater); s.syncAsUint32LE(_selenitic.emitterEnabledVolcano); s.syncAsUint32LE(_selenitic.emitterEnabledClock); s.syncAsUint32LE(_selenitic.emitterEnabledCrystal); s.syncAsUint32LE(_selenitic.emitterEnabledWind); s.syncAsUint32LE(_selenitic.soundReceiverOpened); s.syncAsUint32LE(_selenitic.tunnelLightsSwitchedOn); } else { s.syncAsByte(_selenitic.emitterEnabledWater); s.syncAsByte(_selenitic.emitterEnabledVolcano); s.syncAsByte(_selenitic.emitterEnabledClock); s.syncAsByte(_selenitic.emitterEnabledCrystal); s.syncAsByte(_selenitic.emitterEnabledWind); s.syncAsByte(_selenitic.soundReceiverOpened); s.syncAsByte(_selenitic.tunnelLightsSwitchedOn); } s.syncAsUint16LE(_selenitic.soundReceiverCurrentSource); for (byte i = 0; i < 5; i++) s.syncAsUint16LE(_selenitic.soundReceiverPositions[i]); for (byte i = 0; i < 5; i++) s.syncAsUint16LE(_selenitic.soundLockSliderPositions[i]); // Stoneship if (isME) { s.syncAsUint32LE(_stoneship.lightState); } else { s.syncAsByte(_stoneship.lightState); } s.syncAsUint16LE(_stoneship.sideDoorOpened); s.syncAsUint16LE(_stoneship.pumpState); s.syncAsUint16LE(_stoneship.trapdoorState); s.syncAsUint16LE(_stoneship.chestWaterState); s.syncAsUint16LE(_stoneship.chestValveState); s.syncAsUint16LE(_stoneship.chestOpenState); s.syncAsUint16LE(_stoneship.trapdoorKeyState); s.syncAsUint32LE(_stoneship.generatorDuration); s.syncAsUint16LE(_stoneship.generatorPowerAvailable); s.syncAsUint32LE(_stoneship.generatorDepletionTime); // D'ni s.syncAsUint16LE(_globals.ending); // Already visited zip destinations for (byte i = 0; i < 41; i++) s.syncAsUint16LE(_mystReachableZipDests[i]); for (byte i = 0; i < 41; i++) s.syncAsUint16LE(_channelwoodReachableZipDests[i]); for (byte i = 0; i < 41; i++) s.syncAsUint16LE(_mechReachableZipDests[i]); for (byte i = 0; i < 41; i++) s.syncAsUint16LE(_seleniticReachableZipDests[i]); for (byte i = 0; i < 41; i++) s.syncAsUint16LE(_stoneshipReachableZipDests[i]); if ((isME && s.bytesSynced() != 664) || (!isME && s.bytesSynced() != 601)) warning("Unexpected File Position 0x%03X At End of Save/Load", s.bytesSynced()); }
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 }
void Player::synchronize(Common::Serializer &s) { s.syncAsByte(_moving); s.syncAsSint16LE(_playerPos.x); s.syncAsSint16LE(_playerPos.y); s.syncAsSint16LE(_targetPos.x); s.syncAsSint16LE(_targetPos.y); s.syncAsSint16LE(_xDirection); s.syncAsSint16LE(_yDirection); s.syncAsSint16LE(_posDiff.x); s.syncAsSint16LE(_posDiff.y); s.syncAsSint16LE(_posChange.x); s.syncAsSint16LE(_posChange.y); s.syncAsUint16LE(_targetFacing); s.syncAsSint16LE(_special); s.syncAsByte(_forceRefresh); s.syncAsSint16LE(_ticksAmount); s.syncAsByte(_walkAnywhere); s.syncAsUint16LE(_walkOffScreenSceneId); s.syncAsByte(_walkOffScreen); s.syncAsByte(_needToWalk); s.syncAsByte(_readyToWalk); s.syncAsUint16LE(_prepareWalkFacing); s.syncAsSint16LE(_prepareWalkPos.x); s.syncAsSint16LE(_prepareWalkPos.y); s.syncAsByte(_stepEnabled); s.syncAsByte(_visible); s.syncAsByte(_priorVisible); for (int i = 0; i < 8; ++i) s.syncAsByte(_spriteSetsPresent[i]); s.syncAsByte(_facing); s.syncAsByte(_turnToFacing); s.syncAsSint16LE(_spritesIdx); s.syncAsSint16LE(_frameNumber); s.syncAsSint16LE(_currentDepth); s.syncAsSint16LE(_currentScale); s.syncAsSint16LE(_frameListIndex); _stopWalkers.synchronize(s); _walkTriggerAction.synchronize(s); s.syncAsUint16LE(_walkTriggerDest); s.syncAsSint16LE(_upcomingTrigger); s.syncAsSint16LE(_trigger); s.syncAsSint16LE(_scalingVelocity); s.syncAsSint16LE(_pixelAccum); s.syncAsSint16LE(_distAccum); s.syncAsSint16LE(_deltaDistance); s.syncAsSint16LE(_totalDistance); s.syncAsSint16LE(_velocity); s.syncAsUint16LE(_frameCount); s.syncString(_spritesPrefix); s.syncAsUint32LE(_priorTimer); s.syncAsByte(_loadsFirst); s.syncAsByte(_loadedFirst); s.syncAsByte(_spritesLoaded); s.syncAsByte(_spritesChanged); s.syncAsByte(_beenVisible); s.syncAsSint16LE(_centerOfGravity); s.syncAsByte(_mirror); }