Exemple #1
0
static void syncWithSerializer(Common::Serializer &s, Track &t) {
	s.syncAsSByte(t.pan, VER(31));
	s.syncAsSint32LE(t.vol, VER(31));
	s.syncAsSint32LE(t.volFadeDest, VER(31));
	s.syncAsSint32LE(t.volFadeStep, VER(31));
	s.syncAsSint32LE(t.volFadeDelay, VER(31));
	s.syncAsByte(t.volFadeUsed, VER(31));
	s.syncAsSint32LE(t.soundId, VER(31));
	s.syncArray(t.soundName, 15, Common::Serializer::SByte, VER(31));
	s.syncAsByte(t.used, VER(31));
	s.syncAsByte(t.toBeRemoved, VER(31));
	s.syncAsByte(t.souStreamUsed, VER(31));
	s.skip(1, VER(31), VER(76)); // mixerStreamRunning
	s.syncAsSint32LE(t.soundPriority, VER(31));
	s.syncAsSint32LE(t.regionOffset, VER(31));
	s.skip(4, VER(31), VER(31)); // trackOffset
	s.syncAsSint32LE(t.dataOffset, VER(31));
	s.syncAsSint32LE(t.curRegion, VER(31));
	s.syncAsSint32LE(t.curHookId, VER(31));
	s.syncAsSint32LE(t.volGroupId, VER(31));
	s.syncAsSint32LE(t.soundType, VER(31));
	s.syncAsSint32LE(t.feedSize, VER(31));
	s.syncAsSint32LE(t.dataMod12Bit, VER(31));
	s.syncAsSint32LE(t.mixerFlags, VER(31));
	s.skip(4, VER(31), VER(42)); // mixerVol
	s.skip(4, VER(31), VER(42)); // mixerPan
	s.syncAsByte(t.sndDataExtComp, VER(45));
}
Exemple #2
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;
}
Exemple #3
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;
}
Exemple #4
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);
		}
	}
}
Exemple #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();
	// 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;
}
Exemple #6
0
void EntityData::EntityCallData::saveLoadWithSerializer(Common::Serializer &s) {
	for (uint i = 0; i < ARRAYSIZE(callbacks); i++)
		s.syncAsByte(callbacks[i]);

	s.syncAsByte(currentCall);
	s.syncAsUint16LE(entityPosition);
	s.syncAsUint16LE(location);
	s.syncAsUint16LE(car);
	s.syncAsByte(field_497);
	s.syncAsByte(entity);
	s.syncAsByte(inventoryItem);
	s.syncAsByte(direction);
	s.syncAsUint16LE(field_49B);
	s.syncAsUint16LE(currentFrame);
	s.syncAsUint16LE(currentFrame2);
	s.syncAsUint16LE(field_4A1);
	s.syncAsUint16LE(field_4A3);
	s.syncAsByte(clothes);
	s.syncAsByte(position);
	s.syncAsByte(car2);
	s.syncAsByte(doProcessEntity);
	s.syncAsByte(field_4A9);
	s.syncAsByte(field_4AA);
	s.syncAsByte(directionSwitch);

	// Sync strings
#define SYNC_STRING(varName, count) { \
	char seqName[13]; \
	memset(&seqName, 0, count); \
	if (s.isSaving()) strcpy((char *)&seqName, varName.c_str()); \
	s.syncBytes((byte *)&seqName, count); \
	if (s.isLoading()) varName = seqName; \
}

	SYNC_STRING(sequenceName, 13);
	SYNC_STRING(sequenceName2, 13);
	SYNC_STRING(sequenceNamePrefix, 7);
	SYNC_STRING(sequenceNameCopy, 13);

#undef SYNC_STRING

	// Skip pointers to frame & sequences
	s.skip(5 * 4);
}
Exemple #7
0
//////////////////////////////////////////////////////////////////////////
// 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);
	}
}
Exemple #8
0
void SaveLoadManager::syncSavegameData(Common::Serializer &s, int version) {
	// The brief version 3 had the highscores embedded. They're in a separate file now, so skip
	if (version == 3 && s.isLoading())
		s.skip(100);

	s.syncBytes(&_vm->_globals->_saveData->_data[0], 2050);
	syncCharacterLocation(s, _vm->_globals->_saveData->_cloneHopkins);
	syncCharacterLocation(s, _vm->_globals->_saveData->_realHopkins);
	syncCharacterLocation(s, _vm->_globals->_saveData->_samantha);

	for (int i = 0; i < 35; ++i)
		s.syncAsSint16LE(_vm->_globals->_saveData->_inventory[i]);

	if (version > 1) {
		s.syncAsSint16LE(_vm->_globals->_saveData->_mapCarPosX);
		s.syncAsSint16LE(_vm->_globals->_saveData->_mapCarPosY);
	} else {
		_vm->_globals->_saveData->_mapCarPosX = _vm->_globals->_saveData->_mapCarPosY = 0;
	}

}
Exemple #9
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());
}
Exemple #10
0
void IMuseDigital::saveLoadEarly(Common::Serializer &s) {
	Common::StackLock lock(_mutex, "IMuseDigital::saveLoadEarly()");

	s.skip(4, VER(31), VER(42)); // _volVoice
	s.skip(4, VER(31), VER(42)); // _volSfx
	s.skip(4, VER(31), VER(42)); // _volMusic
	s.syncAsSint32LE(_curMusicState, VER(31));
	s.syncAsSint32LE(_curMusicSeq, VER(31));
	s.syncAsSint32LE(_curMusicCue, VER(31));
	s.syncAsSint32LE(_nextSeqToPlay, VER(31));
	s.syncAsByte(_radioChatterSFX, VER(76));
	s.syncArray(_attributes, 188, Common::Serializer::Sint32LE, VER(31));

	for (int l = 0; l < MAX_DIGITAL_TRACKS + MAX_DIGITAL_FADETRACKS; l++) {
		Track *track = _track[l];
		if (s.isLoading()) {
			memset(track, 0, sizeof(Track));
		}
		syncWithSerializer(s, *track);
		if (s.isLoading()) {
			_track[l]->trackId = l;
			if (!track->used)
				continue;
			if ((track->toBeRemoved) || (track->souStreamUsed) || (track->curRegion == -1)) {
				track->used = false;
				continue;
			}

			// TODO: The code below has a lot in common with that in IMuseDigital::startSound.
			// Try to refactor them to reduce the code duplication.

			track->soundDesc = _sound->openSound(track->soundId, track->soundName, track->soundType, track->volGroupId, -1);
			if (!track->soundDesc)
				track->soundDesc = _sound->openSound(track->soundId, track->soundName, track->soundType, track->volGroupId, 1);
			if (!track->soundDesc)
				track->soundDesc = _sound->openSound(track->soundId, track->soundName, track->soundType, track->volGroupId, 2);

			if (!track->soundDesc) {
				warning("IMuseDigital::saveOrLoad: Can't open sound so will not be resumed");
				track->used = false;
				continue;
			}

			track->sndDataExtComp = _sound->isSndDataExtComp(track->soundDesc);
			track->dataOffset = _sound->getRegionOffset(track->soundDesc, track->curRegion);
			int bits = _sound->getBits(track->soundDesc);
			int channels = _sound->getChannels(track->soundDesc);
			int freq = _sound->getFreq(track->soundDesc);
			track->feedSize = freq * channels;
			track->mixerFlags = 0;
			if (channels == 2)
				track->mixerFlags = kFlagStereo;

			if ((bits == 12) || (bits == 16)) {
				track->mixerFlags |= kFlag16Bits;
				track->feedSize *= 2;
			} else if (bits == 8) {
				track->mixerFlags |= kFlagUnsigned;
			} else
				error("IMuseDigital::saveOrLoad(): Can't handle %d bit samples", bits);

			track->stream = Audio::makeQueuingAudioStream(freq, (track->mixerFlags & kFlagStereo) != 0);

			_mixer->playStream(track->getType(), &track->mixChanHandle, track->stream, -1, track->getVol(), track->getPan());
			_mixer->pauseHandle(track->mixChanHandle, true);
		}
	}
}