本文整理汇总了C++中common::Serializer::isLoading方法的典型用法代码示例。如果您正苦于以下问题:C++ Serializer::isLoading方法的具体用法?C++ Serializer::isLoading怎么用?C++ Serializer::isLoading使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类common::Serializer
的用法示例。
在下文中一共展示了Serializer::isLoading方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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]);
}
}
示例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: 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;
}
}
}
示例4: saveLoadWithSerializer
void Player_AD::saveLoadWithSerializer(Common::Serializer &s) {
Common::StackLock lock(_mutex);
if (s.getVersion() < VER(95)) {
IMuse *dummyImuse = IMuse::create(_vm->_system, NULL, NULL);
dummyImuse->saveLoadIMuse(s, _vm, false);
delete dummyImuse;
return;
}
if (s.getVersion() >= VER(96)) {
int32 res[4] = {
_musicResource, _sfx[0].resource, _sfx[1].resource, _sfx[2].resource
};
// The first thing we save is a list of sound resources being played
// at the moment.
s.syncArray(res, 4, Common::Serializer::Sint32LE);
// If we are loading start the music again at this point.
if (s.isLoading()) {
if (res[0] != -1) {
startSound(res[0]);
}
}
uint32 musicOffset = _curOffset;
s.syncAsSint32LE(_engineMusicTimer, VER(96));
s.syncAsUint32LE(_musicTimer, VER(96));
s.syncAsUint32LE(_internalMusicTimer, VER(96));
s.syncAsUint32LE(_curOffset, VER(96));
s.syncAsUint32LE(_nextEventTimer, VER(96));
// We seek back to the old music position.
if (s.isLoading()) {
SWAP(musicOffset, _curOffset);
musicSeekTo(musicOffset);
}
// Finally start up the SFX. This makes sure that they are not
// accidently stopped while seeking to the old music position.
if (s.isLoading()) {
for (int i = 1; i < ARRAYSIZE(res); ++i) {
if (res[i] != -1) {
startSound(res[i]);
}
}
}
}
}
示例5: synchronize
void Rails::synchronize(Common::Serializer &s) {
s.syncAsSint16LE(_routeLength);
s.syncAsSint16LE(_next);
if (s.isLoading()) {
_routeIndexes.clear();
}
}
示例6: saveLoadWithSerializer
//////////////////////////////////////////////////////////////////////////
// Serializable
//////////////////////////////////////////////////////////////////////////
void SavePoints::saveLoadWithSerializer(Common::Serializer &s) {
// Serialize savepoint data
uint32 dataSize = (s.isLoading() ? _savePointsMaxSize : _data.size());
for (uint i = 0; i < dataSize; i++) {
if (s.isLoading()) {
SavePointData data;
_data.push_back(data);
}
s.syncAsUint32LE(_data[i].entity1);
s.syncAsUint32LE(_data[i].action);
s.syncAsUint32LE(_data[i].entity2);
s.syncAsUint32LE(_data[i].param);
}
// Skip uninitialized data if any
s.skip((_savePointsMaxSize - dataSize) * 16);
// Number of savepoints
uint32 numSavepoints = _savepoints.size();
s.syncAsUint32LE(numSavepoints);
// Savepoints
if (s.isLoading()) {
for (uint i = 0; i < numSavepoints; i++) {
SavePoint point;
s.syncAsUint32LE(point.entity1);
s.syncAsUint32LE(point.action);
s.syncAsUint32LE(point.entity2);
s.syncAsUint32LE(point.param.intValue);
_savepoints.push_back(point);
if (_savepoints.size() >= _savePointsMaxSize)
break;
}
} else {
for (Common::List<SavePoint>::iterator it = _savepoints.begin(); it != _savepoints.end(); ++it) {
s.syncAsUint32LE((*it).entity1);
s.syncAsUint32LE((*it).action);
s.syncAsUint32LE((*it).entity2);
s.syncAsUint32LE((*it).param.intValue);
}
}
}
示例7: 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]);
}
示例8:
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;
}
示例9: 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);
}
}
示例10: 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;
}
示例11: 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);
}
}
示例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);
// 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);
}
}
示例13: 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);
}
}
示例14: 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));
}
}
示例15: 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;
}