本文整理汇总了C++中common::Serializer::isSaving方法的典型用法代码示例。如果您正苦于以下问题:C++ Serializer::isSaving方法的具体用法?C++ Serializer::isSaving怎么用?C++ Serializer::isSaving使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类common::Serializer
的用法示例。
在下文中一共展示了Serializer::isSaving方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: syncCell
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;
}
}
}
示例2: DoSync
static bool DoSync(Common::Serializer &s, int numInterp) {
int sg = 0;
if (TinselV2) {
if (s.isSaving())
g_restoreCD = GetCurrentCD();
s.syncAsSint16LE(g_restoreCD);
}
if (TinselV2 && s.isLoading())
HoldItem(INV_NOICON);
syncSavedData(s, *g_srsd, numInterp);
syncGlobInfo(s); // Glitter globals
syncInvInfo(s); // Inventory data
// Held object
if (s.isSaving())
sg = WhichItemHeld();
s.syncAsSint32LE(sg);
if (s.isLoading()) {
if (sg != -1 && !GetIsInvObject(sg))
// Not a valid inventory object, so return false
return false;
if (TinselV2)
g_thingHeld = sg;
else
HoldItem(sg);
}
syncTimerInfo(s); // Timer data
if (!TinselV2)
syncPolyInfo(s); // Dead polygon data
syncSCdata(s); // Hook Scene and delayed scene
s.syncAsSint32LE(*g_SaveSceneSsCount);
if (*g_SaveSceneSsCount != 0) {
SAVED_DATA *sdPtr = g_SaveSceneSsData;
for (int i = 0; i < *g_SaveSceneSsCount; ++i, ++sdPtr)
syncSavedData(s, *sdPtr, numInterp);
// Flag that there is a saved scene to return to. Note that in this context 'saved scene'
// is a stored scene to return to from another scene, such as from the Summoning Book close-up
// in Discworld 1 to whatever scene Rincewind was in prior to that
g_ASceneIsSaved = true;
}
if (!TinselV2)
syncAllActorsAlive(s);
return true;
}
示例3: syncActors
static void syncActors(Common::Serializer &s) {
int numEntries = 0;
actorStruct *ptr;
uint16 dummyLong = 0;
if (s.isSaving()) {
ptr = actorHead.next;
while (ptr) {
++numEntries;
ptr = ptr->next;
}
}
s.syncAsSint16LE(numEntries);
ptr = s.isSaving() ? actorHead.next : &actorHead;
for (int i = 0; i < numEntries; ++i) {
actorStruct *p = s.isSaving() ? ptr : (actorStruct *)mallocAndZero(sizeof(actorStruct));
s.syncAsUint32LE(dummyLong);
s.syncAsSint16LE(p->idx);
s.syncAsSint16LE(p->type);
s.syncAsSint16LE(p->overlayNumber);
s.syncAsSint16LE(p->x_dest);
s.syncAsSint16LE(p->y_dest);
s.syncAsSint16LE(p->x);
s.syncAsSint16LE(p->y);
s.syncAsSint16LE(p->startDirection);
s.syncAsSint16LE(p->nextDirection);
s.syncAsSint16LE(p->endDirection);
s.syncAsSint16LE(p->stepX);
s.syncAsSint16LE(p->stepY);
s.syncAsSint16LE(p->pathId);
s.syncAsSint16LE(p->phase);
s.syncAsSint16LE(p->counter);
s.syncAsSint16LE(p->poly);
s.syncAsSint16LE(p->flag);
s.syncAsSint16LE(p->start);
s.syncAsSint16LE(p->freeze);
if (s.isSaving())
ptr = ptr->next;
else {
p->next = NULL;
ptr->next = p;
p->prev = actorHead.prev;
actorHead.prev = p;
ptr = p->next;
}
}
}
示例4: 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]);
}
}
示例5: 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);
}
}
示例6:
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;
}
示例7: syncBitFlags
void SavesManager::syncBitFlags(Common::Serializer &s, bool *startP, bool *endP) {
byte data = 0;
int bitCounter = 0;
for (bool *p = startP; p <= endP; ++p, bitCounter = (bitCounter + 1) % 8) {
if (p == endP || bitCounter == 0) {
if (p != endP || s.isSaving())
s.syncAsByte(data);
if (p == endP)
break;
if (s.isSaving())
data = 0;
}
if (s.isLoading())
*p = (data >> bitCounter) != 0;
else if (*p)
data |= 1 << bitCounter;
}
示例8: 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;
}
}
}
示例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:
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));
}
}
示例11: 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);
}
}
示例12: saveLoadWithSerializer
//////////////////////////////////////////////////////////////////////////
// Savegame
//////////////////////////////////////////////////////////////////////////
void SoundQueue::saveLoadWithSerializer(Common::Serializer &s) {
s.syncAsUint32LE(_ambientState);
s.syncAsUint32LE(_currentTag);
// Save or load each entry data
if (s.isSaving()) {
// Compute the number of entries to save
uint32 numEntries = count();
s.syncAsUint32LE(numEntries);
for (Common::List<SoundEntry *>::iterator i = _soundList.begin(); i != _soundList.end(); ++i)
if ((*i)->needSaving())
(*i)->saveLoadWithSerializer(s);
} else {
uint32 numEntries;
s.syncAsUint32LE(numEntries);
for (uint32 i = 0; i < numEntries; i++) {
SoundEntry* entry = new SoundEntry(_engine);
entry->saveLoadWithSerializer(s);
addToQueue(entry);
}
}
}
示例13: syncIncrust
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;
}
}
}
示例14: mallocAndZero
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);
}
}
}
}
}
}
示例15: 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;
//.........这里部分代码省略.........