示例#1
0
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;
}
示例#2
0
static void syncSavedMover(Common::Serializer &s, SAVED_MOVER &sm) {
	int i, j;

	s.syncAsUint32LE(sm.bActive);
	s.syncAsSint32LE(sm.actorID);
	s.syncAsSint32LE(sm.objX);
	s.syncAsSint32LE(sm.objY);
	s.syncAsUint32LE(sm.hLastfilm);

	// Sync walk reels
	for (i = 0; i < TOTAL_SCALES; ++i)
		for (j = 0; j < 4; ++j)
			s.syncAsUint32LE(sm.walkReels[i][j]);

	// Sync stand reels
	for (i = 0; i < TOTAL_SCALES; ++i)
		for (j = 0; j < 4; ++j)
			s.syncAsUint32LE(sm.standReels[i][j]);

	// Sync talk reels
	for (i = 0; i < TOTAL_SCALES; ++i)
		for (j = 0; j < 4; ++j)
			s.syncAsUint32LE(sm.talkReels[i][j]);


	if (TinselV2) {
		s.syncAsByte(sm.bHidden);

		s.syncAsSint32LE(sm.brightness);
		s.syncAsSint32LE(sm.startColor);
		s.syncAsSint32LE(sm.paletteLength);
	}
}
示例#3
0
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);
}
示例#4
0
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
0
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;
}
示例#6
0
文件: saveload.cpp 项目: 33d/scummvm
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);
	}
}
示例#7
0
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);
	}
}
示例#8
0
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();
	// Perform sanity check
	if (tmp < 0 || hdr.id != SAVEGAME_ID || hdr.ver > CURRENT_VER || hdr.size > 1024)
		return false;
	// Skip over any extra bytes
	s.skip(tmp);
	return true;
}
示例#9
0
文件: queue.cpp 项目: singron/scummvm
//////////////////////////////////////////////////////////////////////////
// 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);
	}
}
示例#10
0
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;
}
示例#11
0
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);
}
示例#12
0
文件: saveload.cpp 项目: 33d/scummvm
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);
	}
}
示例#13
0
文件: saveload.cpp 项目: 33d/scummvm
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;
		}
	}
}
示例#14
0
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);
	}
}
示例#15
0
//////////////////////////////////////////////////////////////////////////
// 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);
		}
	}
}
示例#16
0
文件: saveload.cpp 项目: 33d/scummvm
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;
		}
	}
}
示例#17
0
/**
 * (Un)serialize an interpreter context for save/restore game.
 */
void INT_CONTEXT::syncWithSerializer(Common::Serializer &s) {
	if (s.isLoading()) {
		// Null out the pointer fields
		pProc = NULL;
		code = NULL;
		pinvo = NULL;
	}
	// Write out used fields
	s.syncAsUint32LE(GSort);
	s.syncAsUint32LE(hCode);
	s.syncAsUint32LE(event);
	s.syncAsSint32LE(hPoly);
	s.syncAsSint32LE(idActor);

	for (int i = 0; i < PCODE_STACK_SIZE; ++i)
		s.syncAsSint32LE(stack[i]);

	s.syncAsSint32LE(sp);
	s.syncAsSint32LE(bp);
	s.syncAsSint32LE(ip);
	s.syncAsUint32LE(bHalt);
	s.syncAsUint32LE(escOn);
	s.syncAsSint32LE(myEscape);
}
示例#18
0
static void syncSavedMover(Common::Serializer &s, SAVED_MOVER &sm) {
	SCNHANDLE *pList[3] = { (SCNHANDLE *)&sm.walkReels,
		(SCNHANDLE *)&sm.standReels, (SCNHANDLE *)&sm.talkReels };

	s.syncAsUint32LE(sm.bActive);
	s.syncAsSint32LE(sm.actorID);
	s.syncAsSint32LE(sm.objX);
	s.syncAsSint32LE(sm.objY);
	s.syncAsUint32LE(sm.hLastfilm);

	for (int pIndex = 0; pIndex < 3; ++pIndex) {
		SCNHANDLE *p = pList[pIndex];
		for (int i = 0; i < TOTAL_SCALES * 4; ++i)
			s.syncAsUint32LE(*p++);
	}

	if (TinselV2) {
		s.syncAsByte(sm.bHidden);

		s.syncAsSint32LE(sm.brightness);
		s.syncAsSint32LE(sm.startColor);
		s.syncAsSint32LE(sm.paletteLength);
	}
}
示例#19
0
文件: saveload.cpp 项目: 33d/scummvm
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);
	}
}
示例#20
0
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]);
	}
}
示例#21
0
static void syncSoundReel(Common::Serializer &s, SOUNDREELS &sr) {
	s.syncAsUint32LE(sr.hFilm);
	s.syncAsSint32LE(sr.column);
	s.syncAsSint32LE(sr.actorCol);
}
示例#22
0
//////////////////////////////////////////////////////////////////////////
// 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);
		}
	}
}
示例#23
0
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());
}
示例#24
0
文件: player.cpp 项目: Cruel/scummvm
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);
}
示例#25
0
文件: saveload.cpp 项目: 33d/scummvm
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;
		}
	}
}