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

neuromancer noreply at scummvm.org
Mon Nov 7 22:58:07 UTC 2022


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

Summary:
bb7e29b538 FREESCAPE: Entrance is now a header-only class
a5a4b3b78c FREESCAPE: Fixed duplicated if condition. PVS-Studio V517
6c60d761f9 FREESCAPE: Fixed duplicated statement. PVS-Studio V519
7661c36f24 FREESCAPE: Avoid explicit cast to float. PVS-Studio V636
d7c6cbcc80 FREESCAPE: Check driller position before actually bring it


Commit: bb7e29b53814bb09afa65ccf0a25eab2ca419900
    https://github.com/scummvm/scummvm/commit/bb7e29b53814bb09afa65ccf0a25eab2ca419900
Author: neuromancer (gustavo.grieco at gmail.com)
Date: 2022-11-07T23:59:04+01:00

Commit Message:
FREESCAPE: Entrance is now a header-only class

Changed paths:
  R engines/freescape/objects/entrance.cpp
    engines/freescape/module.mk
    engines/freescape/objects/entrance.h


diff --git a/engines/freescape/module.mk b/engines/freescape/module.mk
index c1a46efc174..e9ef9e42f02 100644
--- a/engines/freescape/module.mk
+++ b/engines/freescape/module.mk
@@ -16,7 +16,6 @@ MODULE_OBJS := \
 	metaengine.o \
 	movement.o \
 	neo.o \
-	objects/entrance.o \
 	objects/geometricobject.o \
 	sound.o
 
diff --git a/engines/freescape/objects/entrance.cpp b/engines/freescape/objects/entrance.cpp
deleted file mode 100644
index 3e97a5fddc2..00000000000
--- a/engines/freescape/objects/entrance.cpp
+++ /dev/null
@@ -1,44 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-// Based on Phantasma code by Thomas Harte (2013),
-// available at https://github.com/TomHarte/Phantasma/ (MIT)
-
-#include "freescape/objects/entrance.h"
-
-namespace Freescape {
-
-Entrance::Entrance(
-	uint16 objectID_,
-	const Math::Vector3d &origin_,
-	const Math::Vector3d &rotation_) {
-	_objectID = objectID_;
-	_origin = origin_;
-	_rotation = rotation_;
-	_flags = 0;
-}
-
-Entrance::~Entrance() {}
-
-bool Entrance::isDrawable() { return false; }
-bool Entrance::isPlanar() { return true; }
-
-} // End of namespace Freescape
diff --git a/engines/freescape/objects/entrance.h b/engines/freescape/objects/entrance.h
index fd1c482add2..be2e9e19849 100644
--- a/engines/freescape/objects/entrance.h
+++ b/engines/freescape/objects/entrance.h
@@ -32,13 +32,18 @@ namespace Freescape {
 class Entrance : public Object {
 public:
 	Entrance(
-		uint16 objectID,
-		const Math::Vector3d &origin,
-		const Math::Vector3d &rotation);
-	virtual ~Entrance();
-
-	bool isDrawable() override;
-	bool isPlanar() override;
+		uint16 objectID_,
+		const Math::Vector3d &origin_,
+		const Math::Vector3d &rotation_) {
+		_objectID = objectID_;
+		_origin = origin_;
+		_rotation = rotation_;
+		_flags = 0;
+	}
+	virtual ~Entrance() {}
+
+	bool isDrawable() { return false; }
+	bool isPlanar() { return true; }
 	ObjectType getType() override { return ObjectType::kEntranceType; };
 	Math::Vector3d getRotation() { return _rotation; }
 


Commit: a5a4b3b78c09c04fab8e932944c8d32f1b72a4aa
    https://github.com/scummvm/scummvm/commit/a5a4b3b78c09c04fab8e932944c8d32f1b72a4aa
Author: neuromancer (gustavo.grieco at gmail.com)
Date: 2022-11-07T23:59:04+01:00

Commit Message:
FREESCAPE: Fixed duplicated if condition. PVS-Studio V517

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


diff --git a/engines/freescape/games/driller.cpp b/engines/freescape/games/driller.cpp
index a4c711e57c0..ce638258b89 100644
--- a/engines/freescape/games/driller.cpp
+++ b/engines/freescape/games/driller.cpp
@@ -321,7 +321,7 @@ void DrillerEngine::loadAssetsFullGame() {
 		loadFonts(&file, 0x99dd);
 		loadGlobalObjects(&file, 0x3b42);
 		load8bitBinary(&file, 0x9b40, 16);
-	} else if (_renderMode == Common::kRenderEGA) {
+	} else if (_renderMode == Common::kRenderCGA) {
 		loadBundledImages();
 		_title = _border;
 		file.open("DRILLC.EXE");


Commit: 6c60d761f90d2d85ce4ae84a5da93b96dc9a207f
    https://github.com/scummvm/scummvm/commit/6c60d761f90d2d85ce4ae84a5da93b96dc9a207f
Author: neuromancer (gustavo.grieco at gmail.com)
Date: 2022-11-07T23:59:04+01:00

Commit Message:
FREESCAPE: Fixed duplicated statement. PVS-Studio V519

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


diff --git a/engines/freescape/games/dark.cpp b/engines/freescape/games/dark.cpp
index ba96ff1a691..9bcd3603524 100644
--- a/engines/freescape/games/dark.cpp
+++ b/engines/freescape/games/dark.cpp
@@ -33,7 +33,6 @@ DarkEngine::DarkEngine(OSystem *syst, const ADGameDescription *gd) : FreescapeEn
 	_playerHeights.push_back(48);
 
 	_playerHeight = _playerHeights[_playerHeightNumber];
-	_playerHeight = 64;
 	_playerWidth = 12;
 	_playerDepth = 32;
 }


Commit: 7661c36f240392255c6927b4a7746f44e46de3a9
    https://github.com/scummvm/scummvm/commit/7661c36f240392255c6927b4a7746f44e46de3a9
Author: neuromancer (gustavo.grieco at gmail.com)
Date: 2022-11-07T23:59:04+01:00

Commit Message:
FREESCAPE: Avoid explicit cast to float. PVS-Studio V636

Changed paths:
    engines/freescape/movement.cpp


diff --git a/engines/freescape/movement.cpp b/engines/freescape/movement.cpp
index fe238dd0358..c216a729317 100644
--- a/engines/freescape/movement.cpp
+++ b/engines/freescape/movement.cpp
@@ -53,8 +53,8 @@ void FreescapeEngine::shoot() {
 	_mixer->stopHandle(_soundFxHandle);
 	_gfx->renderShoot(0, _crossairPosition);
 
-	float xoffset = _crossairPosition.x - _screenW / 2;
-	float yoffset = _crossairPosition.y - _screenH / 2;
+	float xoffset = _crossairPosition.x - float(_screenW) / 2;
+	float yoffset = _crossairPosition.y - float(_screenH) / 2;
 
 	Math::Vector3d direction = directionToVector(_pitch + yoffset, _yaw - xoffset);
 	Math::Ray ray(_position, direction);


Commit: d7c6cbcc80eba2bc22276572f5a570ef171f0bf6
    https://github.com/scummvm/scummvm/commit/d7c6cbcc80eba2bc22276572f5a570ef171f0bf6
Author: neuromancer (gustavo.grieco at gmail.com)
Date: 2022-11-07T23:59:04+01:00

Commit Message:
FREESCAPE: Check driller position before actually bring it

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


diff --git a/engines/freescape/freescape.h b/engines/freescape/freescape.h
index 5faea821da6..608bb111d0c 100644
--- a/engines/freescape/freescape.h
+++ b/engines/freescape/freescape.h
@@ -313,6 +313,7 @@ private:
 	void loadGlobalObjects(Common::SeekableReadStream *file, int offset);
 	bool drillDeployed();
 	void addDrill(const Math::Vector3d position);
+	bool checkDrill(const Math::Vector3d position);
 	void removeDrill();
 
 	void loadAssetsDemo();
diff --git a/engines/freescape/games/driller.cpp b/engines/freescape/games/driller.cpp
index ce638258b89..8899b3bd607 100644
--- a/engines/freescape/games/driller.cpp
+++ b/engines/freescape/games/driller.cpp
@@ -412,12 +412,15 @@ void DrillerEngine::pressedKey(const int keycode) {
 			return;
 		}
 
-		_gameStateVars[k8bitVariableEnergy] = _gameStateVars[k8bitVariableEnergy] - 5;
-		_gameStateVars[32]++;
-		// TODO: check if there is space for the drill
 		Math::Vector3d drillPosition = _cameraFront;
 		drillPosition = _position + 256 * drillPosition;
+		if (!checkDrill(drillPosition)) {
+			_currentAreaMessages[0] = _messagesList[4];
+			return;
+		}
 
+		_gameStateVars[k8bitVariableEnergy] = _gameStateVars[k8bitVariableEnergy] - 5;
+		_gameStateVars[32]++;
 		debugC(1, kFreescapeDebugMove, "Current position at %f %f %f", _position.x(), _position.y(), _position.z());
 		drillPosition.setValue(1, _position.y() - _playerHeight * _currentArea->getScale());
 		debugC(1, kFreescapeDebugMove, "Trying to adding drill at %f %f %f", drillPosition.x(), drillPosition.y(), drillPosition.z());
@@ -460,6 +463,81 @@ bool DrillerEngine::drillDeployed() {
 	return (_currentArea->objectWithID(252) != nullptr);
 }
 
+bool DrillerEngine::checkDrill(const Math::Vector3d position) {
+	GeometricObject *obj = nullptr;
+	Math::Vector3d origin = position;
+
+	int16 id;
+	int heightLastObject;
+
+	id = 255;
+	obj = (GeometricObject *)_areaMap[255]->objectWithID(id);
+	assert(obj);
+	obj = obj->duplicate();
+	obj->setOrigin(origin);
+	if (!_currentArea->checkCollisions(obj->_boundingBox))
+		return false;
+
+	heightLastObject = obj->getSize().y();
+	delete obj;
+
+	id = 254;
+	debugC(1, kFreescapeDebugParser, "Adding object %d to room structure", id);
+	obj = (GeometricObject *)_areaMap[255]->objectWithID(id);
+	assert(obj);
+	// Set position for object
+	origin.setValue(0, origin.x() - obj->getSize().x() / 5);
+	origin.setValue(1, origin.y() + heightLastObject);
+	origin.setValue(2, origin.z() - obj->getSize().z() / 5);
+
+	obj = obj->duplicate();
+	obj->setOrigin(origin);
+	if (_currentArea->checkCollisions(obj->_boundingBox))
+		return false;
+
+	// Undo offset
+	origin.setValue(0, origin.x() + obj->getSize().x() / 5);
+	heightLastObject = obj->getSize().y();
+	origin.setValue(2, origin.z() + obj->getSize().z() / 5);
+	delete obj;
+
+	id = 253;
+	debugC(1, kFreescapeDebugParser, "Adding object %d to room structure", id);
+	obj = (GeometricObject *)_areaMap[255]->objectWithID(id);
+	assert(obj);
+	obj = obj->duplicate();
+
+	origin.setValue(0, origin.x() + obj->getSize().x() / 5);
+	origin.setValue(1, origin.y() + heightLastObject);
+	origin.setValue(2, origin.z() + obj->getSize().z() / 5);
+
+	obj->setOrigin(origin);
+	if (_currentArea->checkCollisions(obj->_boundingBox))
+		return false;
+
+	// Undo offset
+	// origin.setValue(0, origin.x() - obj->getSize().x() / 5);
+	heightLastObject = obj->getSize().y();
+	// origin.setValue(2, origin.z() - obj->getSize().z() / 5);
+	delete obj;
+
+	id = 252;
+	debugC(1, kFreescapeDebugParser, "Adding object %d to room structure", id);
+	obj = (GeometricObject *)_areaMap[255]->objectWithID(id);
+	assert(obj);
+	obj = obj->duplicate();
+	origin.setValue(1, origin.y() + heightLastObject);
+	obj->setOrigin(origin);
+	assert(obj);
+
+	if (_currentArea->checkCollisions(obj->_boundingBox))
+		return false;
+
+	delete obj;
+	return true;
+}
+
+
 void DrillerEngine::addDrill(const Math::Vector3d position) {
 	// int drillObjectIDs[8] = {255, 254, 253, 252, 251, 250, 248, 247};
 	GeometricObject *obj = nullptr;
diff --git a/engines/freescape/objects/geometricobject.cpp b/engines/freescape/objects/geometricobject.cpp
index addd80e1fad..9c8f76120ce 100644
--- a/engines/freescape/objects/geometricobject.cpp
+++ b/engines/freescape/objects/geometricobject.cpp
@@ -169,14 +169,23 @@ void GeometricObject::setOrigin(Math::Vector3d origin_) {
 };
 
 GeometricObject *GeometricObject::duplicate() {
+	Common::Array<uint8> *colours_copy = nullptr;
+	Common::Array<uint16> *ordinates_copy = nullptr;
+
+	if (_colours)
+		colours_copy = new Common::Array<uint8>(*_colours);
+
+	if (_ordinates)
+		ordinates_copy = new Common::Array<uint16>(*_ordinates);
+
 	return new GeometricObject(
 		_type,
 		_objectID,
 		_flags,
 		_origin,
 		_size,
-		_colours,
-		_ordinates,
+		colours_copy,
+		ordinates_copy,
 		_condition,
 		_conditionSource);
 }




More information about the Scummvm-git-logs mailing list