[Scummvm-git-logs] scummvm master -> c27804b3ce8f1dcca11fbc15a57b40bc920f95c1

neuromancer noreply at scummvm.org
Thu Jul 27 18:33:52 UTC 2023


This automated email contains information about 4 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
4d13c1e3be FREESCAPE: jet related fixes for dark
22a843f128 FREESCAPE: check if player was crushed and end game in dark
1aabe430f2 FREESCAPE: basic handling of ECDs in dark
c27804b3ce FREESCAPE: refactored code that access game state variables in dark


Commit: 4d13c1e3bed7a424ada81e49bb4954f427577872
    https://github.com/scummvm/scummvm/commit/4d13c1e3bed7a424ada81e49bb4954f427577872
Author: neuromancer (gustavo.grieco at gmail.com)
Date: 2023-07-27T18:56:00+02:00

Commit Message:
FREESCAPE: jet related fixes for dark

Changed paths:
    engines/freescape/freescape.h
    engines/freescape/games/dark/dark.cpp
    engines/freescape/language/instruction.cpp
    engines/freescape/movement.cpp


diff --git a/engines/freescape/freescape.h b/engines/freescape/freescape.h
index 5454b8a929f..72d621f8f30 100644
--- a/engines/freescape/freescape.h
+++ b/engines/freescape/freescape.h
@@ -277,10 +277,10 @@ public:
 	Common::Array<Common::String> _conditionSources;
 	Common::Array<FCLInstructionVector> _conditions;
 
-	void runCollisionConditions(Math::Vector3d const lastPosition, Math::Vector3d const newPosition);
+	bool runCollisionConditions(Math::Vector3d const lastPosition, Math::Vector3d const newPosition);
 	Math::Vector3d _objExecutingCodeSize;
 	virtual void executeMovementConditions();
-	void executeObjectConditions(GeometricObject *obj, bool shot, bool collided, bool activated);
+	bool executeObjectConditions(GeometricObject *obj, bool shot, bool collided, bool activated);
 	void executeLocalGlobalConditions(bool shot, bool collided, bool timer);
 	void executeCode(FCLInstructionVector &code, bool shot, bool collided, bool timer, bool activated);
 
diff --git a/engines/freescape/games/dark/dark.cpp b/engines/freescape/games/dark/dark.cpp
index 7873b2c1553..1710064dceb 100644
--- a/engines/freescape/games/dark/dark.cpp
+++ b/engines/freescape/games/dark/dark.cpp
@@ -265,6 +265,7 @@ void DarkEngine::gotoArea(uint16 areaID, int entranceID) {
 void DarkEngine::pressedKey(const int keycode) {
 	if (keycode == Common::KEYCODE_j) {
 		_flyMode = !_flyMode;
+		insertTemporaryMessage(_messagesList[_flyMode ? 11 : 12], _countdown - 2);
 	}
 }
 
diff --git a/engines/freescape/language/instruction.cpp b/engines/freescape/language/instruction.cpp
index 0d20ebe765c..d77d8e47f65 100644
--- a/engines/freescape/language/instruction.cpp
+++ b/engines/freescape/language/instruction.cpp
@@ -89,22 +89,26 @@ Token::Type FCLInstruction::getType() {
 	return _type;
 }
 
-void FreescapeEngine::executeObjectConditions(GeometricObject *obj, bool shot, bool collided, bool activated) {
+bool FreescapeEngine::executeObjectConditions(GeometricObject *obj, bool shot, bool collided, bool activated) {
+	bool executed = false;;
 	assert(obj != nullptr);
 	if (!obj->_conditionSource.empty()) {
 		_firstSound = true;
 		_syncSound = false;
 		_objExecutingCodeSize = collided ? obj->getSize() : Math::Vector3d();
-		if (collided)
+		if (collided) {
+			clearGameBit(31); // We collided with something that has code
 			debugC(1, kFreescapeDebugCode, "Executing with collision flag: %s", obj->_conditionSource.c_str());
-		else if (shot)
+		} else if (shot)
 			debugC(1, kFreescapeDebugCode, "Executing with shot flag: %s", obj->_conditionSource.c_str());
 		else if (activated)
 			debugC(1, kFreescapeDebugCode, "Executing with activated flag: %s", obj->_conditionSource.c_str());
 		else
 			error("Neither shot or collided flag is set!");
 		executeCode(obj->_condition, shot, collided, false, activated); // TODO: check this last parameter
+		executed = true;
 	}
+	return executed;
 }
 
 void FreescapeEngine::executeLocalGlobalConditions(bool shot, bool collided, bool timer) {
diff --git a/engines/freescape/movement.cpp b/engines/freescape/movement.cpp
index ed22451984b..cd3588cbb06 100644
--- a/engines/freescape/movement.cpp
+++ b/engines/freescape/movement.cpp
@@ -247,78 +247,6 @@ void FreescapeEngine::move(CameraMovement direction, uint8 scale, float deltaTim
 	if (!_flyMode)
 		destination.y() = positionY;
 	resolveCollisions(destination);
-	/*
-	// restore y coordinate
-	if (!_flyMode)
-		_position.set(_position.x(), positionY, _position.z());
-
-	checkIfStillInArea();
-	if (_currentArea->getAreaID() != previousAreaID)
-		return;
-
-	bool collided = checkCollisions(false);
-
-	if (!collided) {
-		bool hasFloor = checkFloor(_position);
-		if (!hasFloor && !_flyMode) {
-			int fallen;
-			for (fallen = 1; fallen < 65 + 1; fallen++) {
-				_position.set(_position.x(), positionY - fallen , _position.z());
-				if (tryStepDown(_position))
-					break;
-			}
-			fallen++;
-			fallen++;
-			if (fallen >= 67) {
-				_position = _lastPosition;
-				_hasFallen = !_disableFalling && true;
-				return;
-			}
-			_position.set(_position.x(), positionY - fallen, _position.z());
-			if (!isPlayingSound())
-				playSound(3, false);
-		}
-		debugC(1, kFreescapeDebugCode, "Runing effects:");
-		if (_flyMode)
-			setGameBit(31);
-		checkCollisions(true); // run the effects
-	} else {
-		debugC(1, kFreescapeDebugCode, "Runing effects: at: %f, %f, %f", _position.x(), _position.y(), _position.z());
-		setGameBit(31);
-		checkCollisions(true); // run the effects
-		if (_currentArea->getAreaID() == previousAreaID) {
-			if (_flyMode)
-				_position = _lastPosition;
-			else {
-				bool stepUp = tryStepUp(_position);
-				if (stepUp) {
-					if (!isPlayingSound())
-						playSound(4, false);
-
-					positionY = _position.y();
-					int fallen;
-					for (fallen = 1; fallen < 64; fallen++) {
-						_position.set(_position.x(), positionY - fallen , _position.z());
-						if (tryStepDown(_position))
-							break;
-					}
-					assert(fallen < 64);
-					fallen++;
-					fallen++;
-					_position.set(_position.x(), positionY - fallen, _position.z());
-
-					debugC(1, kFreescapeDebugCode, "Runing effects:");
-					checkCollisions(true); // run the effects (again)
-				} else {
-					if (!isPlayingSound())
-						playSound(2, false);
-					_position = _lastPosition;
-				}
-			}
-		}
-	}
-	*/
-
 	_lastPosition = _position;
 	debugC(1, kFreescapeDebugMove, "new player position: %f, %f, %f", _position.x(), _position.y(), _position.z());
 	//debugC(1, kFreescapeDebugMove, "player height: %f", _position.y() - areaScale * _playerHeight);
@@ -337,7 +265,7 @@ void FreescapeEngine::resolveCollisions(Math::Vector3d const position) {
 	Math::Vector3d lastPosition = _lastPosition;
 
 	int previousAreaID = _currentArea->getAreaID();
-	runCollisionConditions(lastPosition, newPosition);
+	bool executed = runCollisionConditions(lastPosition, newPosition);
 	if (_currentArea->getAreaID() != previousAreaID) {
 		return;
 	}
@@ -345,6 +273,11 @@ void FreescapeEngine::resolveCollisions(Math::Vector3d const position) {
 	newPosition = _currentArea->resolveCollisions(lastPosition, newPosition, _playerHeight);
 
 	if (_flyMode) {
+		if ((lastPosition - newPosition).length() < 1) { // Something is blocking the player
+			if (!executed)
+				setGameBit(31);
+			playSound(4, false);
+		}
 		_position = newPosition;
 		return;
 	}
@@ -361,7 +294,8 @@ void FreescapeEngine::resolveCollisions(Math::Vector3d const position) {
 	}
 
 	if ((lastPosition - newPosition).length() < 1) { // Something is blocking the player
-		setGameBit(31);
+		if (!executed)
+			setGameBit(31);
 		playSound(4, false);
 	}
 
@@ -380,7 +314,8 @@ void FreescapeEngine::resolveCollisions(Math::Vector3d const position) {
 	_position = newPosition;
 }
 
-void FreescapeEngine::runCollisionConditions(Math::Vector3d const lastPosition, Math::Vector3d const newPosition) {
+bool FreescapeEngine::runCollisionConditions(Math::Vector3d const lastPosition, Math::Vector3d const newPosition) {
+	bool executed = false;
 	// We need to make sure the bounding box touches the floor so we will expand it and run the collision checking
 	uint tolerance = isCastle() ? 1 : 3;
 	Math::Vector3d v(newPosition.x() - 1, newPosition.y() - _playerHeight - tolerance, newPosition.z() - 1);
@@ -411,11 +346,12 @@ void FreescapeEngine::runCollisionConditions(Math::Vector3d const lastPosition,
 			largeObjectWasBlocking = true;
 		}
 
-		executeObjectConditions(gobj, false, true, false);
+		executed |= executeObjectConditions(gobj, false, true, false);
 
 		if (areaID != _currentArea->getAreaID())
 			break;
 	}
+	return executed;
 }
 
 } // namespace Freescape


Commit: 22a843f128d43a718f70934ea72c30a26afd7a37
    https://github.com/scummvm/scummvm/commit/22a843f128d43a718f70934ea72c30a26afd7a37
Author: neuromancer (gustavo.grieco at gmail.com)
Date: 2023-07-27T18:56:00+02:00

Commit Message:
FREESCAPE: check if player was crushed and end game in dark

Changed paths:
    engines/freescape/freescape.cpp
    engines/freescape/freescape.h
    engines/freescape/games/dark/dark.cpp
    engines/freescape/games/driller/driller.cpp
    engines/freescape/language/instruction.cpp


diff --git a/engines/freescape/freescape.cpp b/engines/freescape/freescape.cpp
index 94cfc02aa9e..56d30e25e90 100644
--- a/engines/freescape/freescape.cpp
+++ b/engines/freescape/freescape.cpp
@@ -99,6 +99,7 @@ FreescapeEngine::FreescapeEngine(OSystem *syst, const ADGameDescription *gd)
 	_currentDemoMousePosition = _crossairPosition;
 	_flyMode = false;
 	_noClipMode = false;
+	_playerWasCrushed = false;
 	_forceEndGame = false;
 	_syncSound = false;
 	_firstSound = false;
@@ -288,7 +289,8 @@ void FreescapeEngine::drawFrame() {
 	}
 
 	drawBackground();
-	_currentArea->draw(_gfx, _ticks);
+	if (!_playerWasCrushed) // Avoid rendering inside objects
+		_currentArea->draw(_gfx, _ticks);
 
 	if (_underFireFrames > 0) {
 		for (auto &it : _sensors) {
diff --git a/engines/freescape/freescape.h b/engines/freescape/freescape.h
index 72d621f8f30..00ec49e0b06 100644
--- a/engines/freescape/freescape.h
+++ b/engines/freescape/freescape.h
@@ -379,6 +379,7 @@ public:
 	StateBits _gameStateBits;
 	virtual bool checkIfGameEnded();
 	bool _forceEndGame;
+	bool _playerWasCrushed;
 	ObjectArray _sensors;
 	void checkSensors();
 	void drawSensorShoot(Sensor *sensor);
diff --git a/engines/freescape/games/dark/dark.cpp b/engines/freescape/games/dark/dark.cpp
index 1710064dceb..1e3ee55570b 100644
--- a/engines/freescape/games/dark/dark.cpp
+++ b/engines/freescape/games/dark/dark.cpp
@@ -125,6 +125,7 @@ void DarkEngine::addECD(Area *area, const Math::Vector3d position, int index) {
 void DarkEngine::initGameState() {
 	_flyMode = false;
 	_noClipMode = false;
+	_playerWasCrushed = false;
 	_shootingFrames = 0;
 	_underFireFrames = 0;
 	_yaw = 0;
@@ -151,7 +152,16 @@ void DarkEngine::initGameState() {
 }
 
 bool DarkEngine::checkIfGameEnded() {
-	if (_gameStateVars[k8bitVariableShield] == 0) {
+	if (_playerWasCrushed) {
+		insertTemporaryMessage(_messagesList[10], _countdown - 2);
+		_gameStateVars[28] = 1; // ??
+		drawFrame();
+		_gfx->flipBuffer();
+		g_system->updateScreen();
+		g_system->delayMillis(2000);
+		_playerWasCrushed = false;
+		gotoArea(1, 26);
+	} else if (_gameStateVars[k8bitVariableShield] == 0) {
 		insertTemporaryMessage(_messagesList[15], _countdown - 2);
 		_gameStateVars[28] = 1; // ??
 		drawFrame();
@@ -159,18 +169,14 @@ bool DarkEngine::checkIfGameEnded() {
 		g_system->updateScreen();
 		g_system->delayMillis(2000);
 		gotoArea(1, 26);
-	}
-
-	if (_gameStateVars[k8bitVariableEnergy] == 0) {
+	} else if (_gameStateVars[k8bitVariableEnergy] == 0) {
 		insertTemporaryMessage(_messagesList[16], _countdown - 2);
 		drawFrame();
 		_gfx->flipBuffer();
 		g_system->updateScreen();
 		g_system->delayMillis(2000);
 		gotoArea(1, 26);
-	}
-
-	if (_forceEndGame) {
+	} else if (_forceEndGame) {
 		_forceEndGame = false;
 		if (isDemo())
 			return true;
diff --git a/engines/freescape/games/driller/driller.cpp b/engines/freescape/games/driller/driller.cpp
index 767d85c3b57..1fa52e627b4 100644
--- a/engines/freescape/games/driller/driller.cpp
+++ b/engines/freescape/games/driller/driller.cpp
@@ -682,6 +682,7 @@ void DrillerEngine::removeDrill(Area *area) {
 void DrillerEngine::initGameState() {
 	_flyMode = false;
 	_noClipMode = false;
+	_playerWasCrushed = false;
 	_shootingFrames = 0;
 	_underFireFrames = 0;
 	_yaw = 0;
diff --git a/engines/freescape/language/instruction.cpp b/engines/freescape/language/instruction.cpp
index d77d8e47f65..914340d6f09 100644
--- a/engines/freescape/language/instruction.cpp
+++ b/engines/freescape/language/instruction.cpp
@@ -503,6 +503,8 @@ void FreescapeEngine::executeMakeInvisible(FCLInstruction &instruction) {
 
 }
 
+extern Math::AABB createPlayerAABB(Math::Vector3d const position, int playerHeight);
+
 void FreescapeEngine::executeMakeVisible(FCLInstruction &instruction) {
 	uint16 objectID = 0;
 	uint16 areaID = _currentArea->getAreaID();
@@ -519,6 +521,13 @@ void FreescapeEngine::executeMakeVisible(FCLInstruction &instruction) {
 		Object *obj = _areaMap[areaID]->objectWithID(objectID);
 		assert(obj); // We assume an object should be there
 		obj->makeVisible();
+		if (!isDriller()) {
+			Math::AABB boundingBox = createPlayerAABB(_position, _playerHeight);
+			if (obj->_boundingBox.collides(boundingBox)) {
+				_playerWasCrushed = true;
+				_shootingFrames = 0;
+			}
+		}
 	} else {
 		assert(isDOS() && isDemo()); // Should only happen in the DOS demo
 	}
@@ -552,6 +561,15 @@ void FreescapeEngine::executeToggleVisibility(FCLInstruction &instruction) {
 		assert(obj); // We know that an object should be there
 		obj->makeVisible();
 	}
+	if (!obj->isInvisible()) {
+		if (!isDriller()) {
+			Math::AABB boundingBox = createPlayerAABB(_position, _playerHeight);
+			if (obj->_boundingBox.collides(boundingBox)) {
+				_playerWasCrushed = true;
+				_shootingFrames = 0;
+			}
+		}
+	}
 }
 
 void FreescapeEngine::executeGoto(FCLInstruction &instruction) {


Commit: 1aabe430f28aa11a865ab24b5eca8a84c6f4ac24
    https://github.com/scummvm/scummvm/commit/1aabe430f28aa11a865ab24b5eca8a84c6f4ac24
Author: neuromancer (gustavo.grieco at gmail.com)
Date: 2023-07-27T18:56:00+02:00

Commit Message:
FREESCAPE: basic handling of ECDs in dark

Changed paths:
    engines/freescape/freescape.h
    engines/freescape/games/dark/dark.cpp


diff --git a/engines/freescape/freescape.h b/engines/freescape/freescape.h
index 00ec49e0b06..4bdf1713fbd 100644
--- a/engines/freescape/freescape.h
+++ b/engines/freescape/freescape.h
@@ -552,6 +552,8 @@ public:
 private:
 	void addECDs(Area *area);
 	void addECD(Area *area, const Math::Vector3d position, int index);
+	void restoreECD(Area *area, int index);
+	bool checkECD(int index);
 	void addWalls(Area *area);
 	Common::SeekableReadStream *decryptFile(const Common::String filename);
 };
diff --git a/engines/freescape/games/dark/dark.cpp b/engines/freescape/games/dark/dark.cpp
index 1e3ee55570b..f8de1f7b8eb 100644
--- a/engines/freescape/games/dark/dark.cpp
+++ b/engines/freescape/games/dark/dark.cpp
@@ -122,6 +122,18 @@ void DarkEngine::addECD(Area *area, const Math::Vector3d position, int index) {
 	}
 }
 
+void DarkEngine::restoreECD(Area *area, int index) {
+	Object *obj = nullptr;
+	int16 id = 227 + index * 6;
+	for (int i = 0; i < 4; i++) {
+		debugC(1, kFreescapeDebugParser, "Restoring object %d to from ECD %d", id, index);
+		obj = (GeometricObject *)area->objectWithID(id);
+		obj->restore();
+		obj->makeVisible();
+		id--;
+	}
+}
+
 void DarkEngine::initGameState() {
 	_flyMode = false;
 	_noClipMode = false;
@@ -151,7 +163,27 @@ void DarkEngine::initGameState() {
 	_demoEvents.clear();
 }
 
+bool DarkEngine::checkECD(int index) {
+	if (isDemo()) {
+		if (index == 1) {
+			restoreECD(_currentArea, index);
+			return false;
+		}
+		return true;
+	}
+	return true;
+}
+
 bool DarkEngine::checkIfGameEnded() {
+	if (_gameStateVars[29] > 0) {
+		bool destroyed = checkECD(_gameStateVars[29] - 1);
+		if (destroyed)
+			insertTemporaryMessage(_messagesList[2], _countdown - 2);
+		else
+			insertTemporaryMessage(_messagesList[1], _countdown - 2);
+		_gameStateVars[29] = 0;
+	}
+
 	if (_playerWasCrushed) {
 		insertTemporaryMessage(_messagesList[10], _countdown - 2);
 		_gameStateVars[28] = 1; // ??


Commit: c27804b3ce8f1dcca11fbc15a57b40bc920f95c1
    https://github.com/scummvm/scummvm/commit/c27804b3ce8f1dcca11fbc15a57b40bc920f95c1
Author: neuromancer (gustavo.grieco at gmail.com)
Date: 2023-07-27T20:30:32+02:00

Commit Message:
FREESCAPE: refactored code that access game state variables in dark

Changed paths:
    engines/freescape/games/dark/dark.cpp


diff --git a/engines/freescape/games/dark/dark.cpp b/engines/freescape/games/dark/dark.cpp
index f8de1f7b8eb..afd1371194b 100644
--- a/engines/freescape/games/dark/dark.cpp
+++ b/engines/freescape/games/dark/dark.cpp
@@ -28,6 +28,16 @@
 
 namespace Freescape {
 
+enum {
+	kVariableDarkEnding = 28,
+	kVariableDarkECD = 29,
+};
+
+enum {
+	kDarkEndingEvathDestroyed = 1,
+	kDarkEndingECDsDestroyed = 2,
+};
+
 DarkEngine::DarkEngine(OSystem *syst, const ADGameDescription *gd) : FreescapeEngine(syst, gd) {
 	if (isDOS())
 		initDOS();
@@ -175,18 +185,18 @@ bool DarkEngine::checkECD(int index) {
 }
 
 bool DarkEngine::checkIfGameEnded() {
-	if (_gameStateVars[29] > 0) {
-		bool destroyed = checkECD(_gameStateVars[29] - 1);
+	if (_gameStateVars[kVariableDarkECD] > 0) {
+		bool destroyed = checkECD(_gameStateVars[kVariableDarkECD] - 1);
 		if (destroyed)
 			insertTemporaryMessage(_messagesList[2], _countdown - 2);
 		else
 			insertTemporaryMessage(_messagesList[1], _countdown - 2);
-		_gameStateVars[29] = 0;
+		_gameStateVars[kVariableDarkECD] = 0;
 	}
 
 	if (_playerWasCrushed) {
 		insertTemporaryMessage(_messagesList[10], _countdown - 2);
-		_gameStateVars[28] = 1; // ??
+		_gameStateVars[kVariableDarkEnding] = kDarkEndingEvathDestroyed;
 		drawFrame();
 		_gfx->flipBuffer();
 		g_system->updateScreen();
@@ -195,7 +205,7 @@ bool DarkEngine::checkIfGameEnded() {
 		gotoArea(1, 26);
 	} else if (_gameStateVars[k8bitVariableShield] == 0) {
 		insertTemporaryMessage(_messagesList[15], _countdown - 2);
-		_gameStateVars[28] = 1; // ??
+		_gameStateVars[kVariableDarkEnding] = kDarkEndingEvathDestroyed;
 		drawFrame();
 		_gfx->flipBuffer();
 		g_system->updateScreen();
@@ -203,6 +213,7 @@ bool DarkEngine::checkIfGameEnded() {
 		gotoArea(1, 26);
 	} else if (_gameStateVars[k8bitVariableEnergy] == 0) {
 		insertTemporaryMessage(_messagesList[16], _countdown - 2);
+		_gameStateVars[kVariableDarkEnding] = kDarkEndingEvathDestroyed;
 		drawFrame();
 		_gfx->flipBuffer();
 		g_system->updateScreen();
@@ -210,15 +221,12 @@ bool DarkEngine::checkIfGameEnded() {
 		gotoArea(1, 26);
 	} else if (_forceEndGame) {
 		_forceEndGame = false;
-		if (isDemo())
-			return true;
-		else {
-			drawFrame();
-			_gfx->flipBuffer();
-			g_system->updateScreen();
-			g_system->delayMillis(2000);
-			gotoArea(1, 26);
-		}
+		_gameStateVars[kVariableDarkEnding] = kDarkEndingEvathDestroyed;
+		drawFrame();
+		_gfx->flipBuffer();
+		g_system->updateScreen();
+		g_system->delayMillis(2000);
+		gotoArea(1, 26);
 	}
 
 	if (_currentArea->getAreaID() == 1) {




More information about the Scummvm-git-logs mailing list