[Scummvm-git-logs] scummvm master -> 12f6c384326136d3b3cfacdff6cc76de25e570b6

neuromancer noreply at scummvm.org
Mon Nov 14 17:23:39 UTC 2022


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

Summary:
12f6c38432 FREESCAPE: drill rendering improvements in driller


Commit: 12f6c384326136d3b3cfacdff6cc76de25e570b6
    https://github.com/scummvm/scummvm/commit/12f6c384326136d3b3cfacdff6cc76de25e570b6
Author: neuromancer (gustavo.grieco at gmail.com)
Date: 2022-11-14T18:24:39+01:00

Commit Message:
FREESCAPE: drill rendering improvements in driller

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


diff --git a/engines/freescape/freescape.h b/engines/freescape/freescape.h
index b14017f0406..6d2451694bd 100644
--- a/engines/freescape/freescape.h
+++ b/engines/freescape/freescape.h
@@ -337,7 +337,7 @@ private:
 	void loadGlobalObjects(Common::SeekableReadStream *file, int offset);
 	bool drillDeployed(Area *area);
 	Math::Vector3d drillPosition();
-	void addDrill(const Math::Vector3d position);
+	void addDrill(const Math::Vector3d position, bool gasFound);
 	bool checkDrill(const Math::Vector3d position);
 	void removeDrill(Area *area);
 	StateBits _drilledAreas;
diff --git a/engines/freescape/games/driller.cpp b/engines/freescape/games/driller.cpp
index 93b727e534a..c599c1e134f 100644
--- a/engines/freescape/games/driller.cpp
+++ b/engines/freescape/games/driller.cpp
@@ -472,11 +472,10 @@ void DrillerEngine::pressedKey(const int keycode) {
 
 		_gameStateVars[k8bitVariableEnergy] = _gameStateVars[k8bitVariableEnergy] - 5;
 		const Math::Vector3d gasPocket3D(gasPocket.x, drill.y(), gasPocket.y);
-		addDrill(drill);
 		float distanceToPocket = (gasPocket3D - drill).length();
 		float success = 100.0 * (1.0 - distanceToPocket / _currentArea->_gasPocketRadius);
 		insertTemporaryMessage(_messagesList[3], _countdown - 2);
-
+		addDrill(drill, success > 0);
 		if (success <= 0) {
 			insertTemporaryMessage(_messagesList[9], _countdown - 4);
 			return;
@@ -537,7 +536,7 @@ Math::Vector3d DrillerEngine::drillPosition() {
 }
 
 bool DrillerEngine::drillDeployed(Area *area) {
-	return (area->objectWithID(252) != nullptr);
+	return (area->objectWithID(255) != nullptr);
 }
 
 bool DrillerEngine::checkDrill(const Math::Vector3d position) {
@@ -615,7 +614,7 @@ bool DrillerEngine::checkDrill(const Math::Vector3d position) {
 }
 
 
-void DrillerEngine::addDrill(const Math::Vector3d position) {
+void DrillerEngine::addDrill(const Math::Vector3d position, bool gasFound) {
 	// int drillObjectIDs[8] = {255, 254, 253, 252, 251, 250, 248, 247};
 	GeometricObject *obj = nullptr;
 	Math::Vector3d origin = position;
@@ -673,36 +672,41 @@ void DrillerEngine::addDrill(const Math::Vector3d position) {
 	heightLastObject = obj->getSize().y();
 	// origin.setValue(2, origin.z() - obj->getSize().z() / 5);
 
-	id = 252;
-	debugC(1, kFreescapeDebugParser, "Adding object %d to room structure", id);
-	obj = (GeometricObject *)_areaMap[255]->objectWithID(id);
-	assert(obj);
-	obj = (GeometricObject *)obj->duplicate();
-	origin.setValue(0, origin.x() + obj->getSize().x());
-	origin.setValue(1, origin.y() + heightLastObject);
-	origin.setValue(2, origin.z() + obj->getSize().z());
-	obj->setOrigin(origin);
-	assert(obj);
-	obj->makeVisible();
-	_currentArea->addObject(obj);
-
-	heightLastObject = obj->getSize().y();
-
-	id = 251;
-	debugC(1, kFreescapeDebugParser, "Adding object %d to room structure", id);
-	obj = (GeometricObject *)_areaMap[255]->objectWithID(id);
-	assert(obj);
-	obj = (GeometricObject *)obj->duplicate();
-	origin.setValue(1, origin.y() + heightLastObject);
-	obj->setOrigin(origin);
-	assert(obj);
-	obj->makeVisible();
-	_currentArea->addObject(obj);
+	if (gasFound) {
+		id = 252;
+		debugC(1, kFreescapeDebugParser, "Adding object %d to room structure", id);
+		obj = (GeometricObject *)_areaMap[255]->objectWithID(id);
+		assert(obj);
+		obj = (GeometricObject *)obj->duplicate();
+		origin.setValue(0, origin.x() + obj->getSize().x());
+		origin.setValue(1, origin.y() + heightLastObject);
+		origin.setValue(2, origin.z() + obj->getSize().z());
+		obj->setOrigin(origin);
+		assert(obj);
+		obj->makeVisible();
+		_currentArea->addObject(obj);
+		heightLastObject = obj->getSize().y();
+
+		id = 251;
+		debugC(1, kFreescapeDebugParser, "Adding object %d to room structure", id);
+		obj = (GeometricObject *)_areaMap[255]->objectWithID(id);
+		assert(obj);
+		obj = (GeometricObject *)obj->duplicate();
+		origin.setValue(1, origin.y() + heightLastObject);
+		obj->setOrigin(origin);
+		assert(obj);
+		obj->makeVisible();
+		_currentArea->addObject(obj);
+	}
 }
 
 void DrillerEngine::removeDrill(Area *area) {
 	for (int16 id = 251; id < 256; id++) {
-		area->removeObject(id);
+		if (id > 252)
+			assert(area->objectWithID(id));
+
+		if (area->objectWithID(id))
+			area->removeObject(id);
 	}
 }
 




More information about the Scummvm-git-logs mailing list