Exemplo n.º 1
0
void CGEEngine::syncGame(Common::SeekableReadStream *readStream, Common::WriteStream *writeStream, bool tiny) {
	Common::Serializer s(readStream, writeStream);

	if (s.isSaving()) {
		for (int i = 0; i < kPocketNX; i++) {
			register Sprite *pocSpr = _pocket[i];
			_pocref[i] = (pocSpr) ? pocSpr->_ref : -1;
		}

		// Skip Digital and Midi volumes, useless under ScummVM
		_volume[0] = 0;
		_volume[1] = 0;
	}

	// Synchronise header data
	syncHeader(s);

	if (s.isSaving()) {
		// Loop through saving the sprite data
		for (Sprite *spr = _vga->_spareQ->first(); spr; spr = spr->_next) {
			if (!s.err())
				spr->sync(s);
		}
	} else {
		// Loading game
		if (_soundOk == 1 && _mode == 0) {
			// Skip Digital and Midi volumes, useless under ScummVM
			sndSetVolume();
		}

		if (!tiny) { // load sprites & pocket
			while (readStream->pos() < readStream->size()) {
				Sprite S(this, NULL);
				S.sync(s);

				S._prev = S._next = NULL;
				Sprite *spr = (scumm_stricmp(S._file + 2, "MUCHA") == 0) ? new Fly(this, NULL)
					  : new Sprite(this, NULL);
				assert(spr != NULL);
				*spr = S;
				_vga->_spareQ->append(spr);
			}

			for (int i = 0; i < kPocketNX; i++) {
				register int r = _pocref[i];
				_pocket[i] = (r < 0) ? NULL : _vga->_spareQ->locate(r);
			}
		}
	}
}
Exemplo n.º 2
0
void CGE2Engine::syncGame(Common::SeekableReadStream *readStream, Common::WriteStream *writeStream) {
	Common::Serializer s(readStream, writeStream);

	// Synchronise header data
	syncHeader(s);

	// Synchronise _spare
	_spare->sync(s);

	if (s.isSaving()) {
		// Save the references of the items in the heroes pockets:
		for (int i = 0; i < 2; i++) {
			for (int j = 0; j < kPocketMax; j++) {
				int ref = _heroTab[i]->_downPocketId[j];
				s.syncAsSint16LE(ref);
			}
		}
	} else {
		// Load items to the pockets
		for (int i = 0; i < 2; i++) {
			for (int j = 0; j < kPocketMax; j++) {
				int ref = 0;
				s.syncAsSint16LE(ref);
				_heroTab[i]->_downPocketId[j] = ref;
			}
		}
	}

	// Heroes' _posTabs
	for (int i = 0; i < 2; i++) {
		for (int j = 0; j < kSceneMax; j++) {
			s.syncAsSint16LE(_heroTab[i]->_posTab[j]->x);
			s.syncAsSint16LE(_heroTab[i]->_posTab[j]->y);
		}
	}
}