Пример #1
0
Common::Error SaveManager::loadGame(int slot) {
	Common::SeekableReadStream *saveFile = NULL;

	if (slot >= 0) {
		saveFile = getSlotFile(slot);
	} else {
		saveFile = _engine->getSearchManager()->openFile("r.svr");
		if (!saveFile) {
			Common::File *restoreFile = new Common::File();
			if (!restoreFile->open("r.svr")) {
				delete restoreFile;
				return Common::kPathDoesNotExist;
			}

			saveFile = restoreFile;
		}
	}

	if (!saveFile)
		return Common::kPathDoesNotExist;

	// Read the header
	SaveGameHeader header;
	if (!readSaveGameHeader(saveFile, header)) {
		return Common::kUnknownError;
	}

	ScriptManager *scriptManager = _engine->getScriptManager();
	// Update the state table values
	scriptManager->deserialize(saveFile);

	delete saveFile;
	if (header.thumbnail)
		delete header.thumbnail;

	if (_engine->getGameId() == GID_NEMESIS && scriptManager->getCurrentLocation() == "tv2f") {
		// WORKAROUND for script bug #6793: location tv2f (stairs) has two states:
		// one at the top of the stairs, and one at the bottom. When the player
		// goes to the bottom of the stairs, the screen changes, and hotspot
		// 4652 (exit opposite the stairs) is enabled. However, the variable that
		// controls the state (2408) is reset when the player goes down the stairs.
		// Furthermore, the room's initialization script disables the stair exit
		// control (4652). This leads to an impossible situation, where all the
		// exit controls are disabled, and the player can't more anywhere. Thus,
		// when loading a game in that room, we check for that impossible
		// situation, which only occurs after the player has moved down the stairs,
		// and fix it here by setting the correct background, and enabling the
		// stair exit hotspot.
		if ((scriptManager->getStateFlag(2411) & Puzzle::DISABLED) &&
			(scriptManager->getStateFlag(2408) & Puzzle::DISABLED) &&
			(scriptManager->getStateFlag(4652) & Puzzle::DISABLED)) {
			_engine->getRenderManager()->setBackgroundImage("tv2fb21c.tga");
			scriptManager->unsetStateFlag(4652, Puzzle::DISABLED);
		}
	}

	return Common::kNoError;
}
Пример #2
0
bool PanTrackNode::process(uint32 deltaTimeInMillis) {
	ScriptManager * scriptManager = _engine->getScriptManager();
	ScriptingEffect *fx = scriptManager->getSideFX(_slot);
	if (fx && fx->getType() == SCRIPTING_EFFECT_AUDIO) {
		MusicNodeBASE *mus = (MusicNodeBASE *)fx;

		int curPos = scriptManager->getStateValue(StateKey_ViewPos);
		int16 _width = _engine->getRenderManager()->getBkgSize().x;
		int16 _halfWidth = _width / 2;
		int16 _quarterWidth = _width / 4;

		int tmp = 0;
		if (curPos <= _position)
			tmp = _position - curPos;
		else
			tmp = _position - curPos + _width;

		int balance = 0;

		if (tmp > _halfWidth)
			tmp -= _width;

		if (tmp > _quarterWidth) {
			balance = 1;
			tmp = _halfWidth - tmp;
		} else if (tmp < -_quarterWidth) {
			balance = -1;
			tmp = -_halfWidth - tmp;
		}

		// Originally it's value -90...90 but we use -127...127 and therefore 360 replaced by 508
		mus->setBalance( (508 * tmp) / _width );

		tmp = (360 * tmp) / _width;

		int deltaVol = balance;

		// This value sets how fast volume goes off than sound source back of you
		// By this value we can hack some "bugs" have place in originall game engine like beat sound in ZGI-dc10
		int volumeCorrection = 2;

		if (_engine->getGameId() == GID_GRANDINQUISITOR) {
			if (scriptManager->getCurrentLocation() == "dc10")
				volumeCorrection = 5;
		}

		if (deltaVol != 0)
			deltaVol = (mus->getVolume() * volumeCorrection) * (90 - tmp * balance) / 90;
		if (deltaVol > 255)
			deltaVol = 255;

		mus->setDeltaVolume(deltaVol);
	}
	return false;
}