本文整理汇总了C++中common::Serializer类的典型用法代码示例。如果您正苦于以下问题:C++ Serializer类的具体用法?C++ Serializer怎么用?C++ Serializer使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Serializer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: syncTime
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);
}
示例2: syncSoundList
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);
}
}
示例3: syncAllActorsAlive
void syncAllActorsAlive(Common::Serializer &s) {
for (int i = 0; i < MAX_SAVED_ALIVES; i++) {
s.syncAsByte(actorInfo[i].bAlive);
s.syncAsByte(actorInfo[i].tagged);
s.syncAsByte(actorInfo[i].tType);
s.syncAsUint32LE(actorInfo[i].hTag);
}
}
示例4: syncSCdata
void syncSCdata(Common::Serializer &s) {
s.syncAsUint32LE(HookScene.scene);
s.syncAsSint32LE(HookScene.entry);
s.syncAsSint32LE(HookScene.trans);
s.syncAsUint32LE(DelayedScene.scene);
s.syncAsSint32LE(DelayedScene.entry);
s.syncAsSint32LE(DelayedScene.trans);
}
示例5: syncTimerInfo
/**
* (Un)serialize the timer data for save/restore game.
*/
void syncTimerInfo(Common::Serializer &s) {
for (int i = 0; i < MAX_TIMERS; i++) {
s.syncAsSint32LE(timers[i].tno);
s.syncAsSint32LE(timers[i].ticks);
s.syncAsSint32LE(timers[i].secs);
s.syncAsSint32LE(timers[i].delta);
s.syncAsSint32LE(timers[i].frame);
}
}
示例6: 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);
}
}
示例7: synchronize
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);
}
示例8: synchronize
void UserInterface::synchronize(Common::Serializer &s) {
InventoryObjects &invObjects = _vm->_game->_objects;
if (s.isLoading()) {
_selectedInvIndex = invObjects._inventoryList.empty() ? -1 : 0;
}
for (int i = 0; i < 8; ++i)
s.syncAsSint16LE(_categoryIndexes[i]);
}
示例9:
void SaveLoad::sync<ScriptRegister::Script>(Common::Serializer &serializer, ScriptRegister::Script &var) {
if (serializer.isSaving())
if (var.chunk)
var.line = var.chunk->getCurLine();
serializer.syncAsUint32LE(var.line);
if (serializer.isLoading())
var.chunk = 0;
}
示例10: syncCT
static void syncCT(Common::Serializer &s) {
int v = (_vm->_polyStruct) ? 1 : 0;
s.syncAsSint32LE(v);
if (s.isLoading())
_vm->_polyStruct = (v != 0) ? &_vm->_polyStructNorm : NULL;
if (v == 0)
// There is no further data to load or save
return;
s.syncAsSint16LE(numberOfWalkboxes);
if (numberOfWalkboxes) {
for (int i = 0; i < numberOfWalkboxes; ++i)
s.syncAsSint16LE(walkboxColor[i]);
for (int i = 0; i < numberOfWalkboxes; ++i)
s.syncAsSint16LE(walkboxState[i]);
}
for (int i = 0; i < 10; i++) {
v = 0;
if (s.isSaving()) v = (persoTable[i]) ? 1 : 0;
s.syncAsSint32LE(v);
if (s.isLoading())
// Set up the pointer for the next structure
persoTable[i] = (v == 0) ? NULL : (persoStruct *)mallocAndZero(sizeof(persoStruct));
if (v != 0)
syncPerso(s, *persoTable[i]);
}
}
示例11: 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;
}
示例12: synchronize
void ActionSavedFields::synchronize(Common::Serializer &s) {
s.syncAsByte(_commandError);
s.syncAsSint16LE(_commandSource);
s.syncAsSint16LE(_command);
s.syncAsSint16LE(_mainObject);
s.syncAsSint16LE(_secondObject);
s.syncAsSint16LE(_mainObjectSource);
s.syncAsSint16LE(_secondObjectSource);
s.syncAsSint16LE(_articleNumber);
s.syncAsSint16LE(_lookFlag);
}
示例13: 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);
}
}
示例14: synchronize
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);
}
}
示例15: saveLoadWithSerializer
//////////////////////////////////////////////////////////////////////////
// Savegame
//////////////////////////////////////////////////////////////////////////
void SoundQueue::saveLoadWithSerializer(Common::Serializer &s) {
Common::StackLock locker(_mutex);
s.syncAsUint32LE(_state);
s.syncAsUint32LE(_currentType);
// Compute the number of entries to save
uint32 numEntries = count();
s.syncAsUint32LE(numEntries);
// Save or load each entry data
if (s.isSaving()) {
for (Common::List<SoundEntry *>::iterator i = _soundList.begin(); i != _soundList.end(); ++i)
(*i)->saveLoadWithSerializer(s);
} else {
warning("[Sound::saveLoadWithSerializer] Loading not implemented");
s.skip(numEntries * 64);
}
}