本文整理汇总了C++中common::Serializer::syncBytes方法的典型用法代码示例。如果您正苦于以下问题:C++ Serializer::syncBytes方法的具体用法?C++ Serializer::syncBytes怎么用?C++ Serializer::syncBytes使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类common::Serializer
的用法示例。
在下文中一共展示了Serializer::syncBytes方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: syncBackgroundTable
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);
}
}
示例2: syncSaveGameHeader
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;
}
示例3: DoSync
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);
}
示例4: syncSavedData
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]);
}
}
示例5: syncScript
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;
}
}
}
示例6: syncSaveGameHeader
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;
}
示例7: syncSongs
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);
}
}
示例8: syncPreloadData
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);
}
}
示例9: syncHeader
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));
}
}
示例10:
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);
}
}
示例11: syncSavegameData
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;
}
}
示例12: syncFilesDatabase
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);
}
}
示例13: syncFilesDatabase
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);
}
}
示例14: synchronize
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;
//.........这里部分代码省略.........
示例15: sync
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
}