[Scummvm-git-logs] scummvm master -> 4daf983b2e7aea5516f2a6bc55bf0ac06742e19e

dreammaster dreammaster at scummvm.org
Thu Mar 9 05:27:35 CET 2017


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:
4daf983b2e TITANIC: Added addStar and other methods


Commit: 4daf983b2e7aea5516f2a6bc55bf0ac06742e19e
    https://github.com/scummvm/scummvm/commit/4daf983b2e7aea5516f2a6bc55bf0ac06742e19e
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2017-03-08T23:27:26-05:00

Commit Message:
TITANIC: Added addStar and other methods

Changed paths:
    engines/titanic/star_control/base_star.h
    engines/titanic/star_control/star_control_sub6.cpp
    engines/titanic/star_control/star_control_sub6.h
    engines/titanic/star_control/star_control_sub7.cpp
    engines/titanic/star_control/star_control_sub7.h


diff --git a/engines/titanic/star_control/base_star.h b/engines/titanic/star_control/base_star.h
index 76795e1..ec27ffa 100644
--- a/engines/titanic/star_control/base_star.h
+++ b/engines/titanic/star_control/base_star.h
@@ -96,7 +96,11 @@ public:
 	virtual bool selectStar(CSurfaceArea *surfaceArea, CStarControlSub12 *sub12,
 		int flags, const Common::Point &pt) { return false; }
 
-	virtual bool proc5(int v1) { return false; }
+	/**
+	 * Adds a new star, or removes one if already present at the given co-ordinates
+	 */
+	virtual bool addStar(const CBaseStarEntry *entry) { return false; }
+
 	virtual bool loadStar() { return false; }
 
 	/**
diff --git a/engines/titanic/star_control/star_control_sub6.cpp b/engines/titanic/star_control/star_control_sub6.cpp
index 925f933..27e2a49 100644
--- a/engines/titanic/star_control/star_control_sub6.cpp
+++ b/engines/titanic/star_control/star_control_sub6.cpp
@@ -108,4 +108,52 @@ void CStarControlSub6::copyFrom(const CStarControlSub6 *src) {
 	_vector = src->_vector;
 }
 
+void CStarControlSub6::setup(CStarControlSub6 *dest, const CStarControlSub6 *s2, const CStarControlSub6 *s3) {
+	CStarControlSub6 &d = *dest;
+
+	d._row1._x = s3->_row1._x * s2->_row1._x
+		+ s2->_row1._z * s3->_row3._x
+		+ s2->_row1._y * s3->_row2._x;
+	d._row1._y = s2->_row1._x * s3->_row1._y
+		+ s3->_row3._y * s2->_row1._z
+		+ s3->_row2._y * s2->_row1._y;
+	d._row1._z = s2->_row1._x * s3->_row1._z
+		+ s3->_row3._z * s2->_row1._z
+		+ s3->_row2._z * s2->_row1._y;
+	d._row2._x = s3->_row1._x * s2->_row2._x
+		+ s2->_row2._y * s3->_row2._x
+		+ s2->_row2._z * s3->_row3._x;
+	d._row2._y = s2->_row2._y * s3->_row2._y
+		+ s2->_row2._z * s3->_row3._y
+		+ s3->_row1._y * s2->_row2._x;
+	d._row2._z = s3->_row1._z * s2->_row2._x
+		+ s2->_row2._y * s3->_row2._z
+		+ s2->_row2._z * s3->_row3._z;
+	d._row3._x = s3->_row1._x * s2->_row3._x
+		+ s2->_row3._y * s3->_row2._x
+		+ s2->_row3._z * s3->_row3._x;
+	d._row3._y = s2->_row3._z * s3->_row3._y
+		+ s2->_row3._y * s3->_row2._y
+		+ s3->_row1._y * s2->_row3._x;
+	d._row3._z = s3->_row3._z * s2->_row3._z
+		+ s3->_row2._z * s2->_row3._y
+		+ s3->_row1._z * s2->_row3._x;
+	d._vector._x = s3->_row1._x * s2->_vector._x
+		+ s2->_vector._y * s3->_row2._x
+		+ s2->_vector._z * s3->_row3._x
+		+ s3->_vector._x;
+	d._vector._y = s2->_vector._z * s3->_row3._y
+		+ s2->_vector._y * s3->_row2._y
+		+ s2->_vector._x * s3->_row1._y
+		+ s3->_vector._y;
+	d._vector._z = s2->_vector._y * s3->_row2._z
+		+ s2->_vector._z * s3->_row3._z
+		+ s2->_vector._x * s3->_row1._z
+		+ s3->_vector._z;
+}
+
+void CStarControlSub6::fn1(CStarControlSub6 *sub6) {
+	// TODO
+}
+
 } // End of namespace Titanic
diff --git a/engines/titanic/star_control/star_control_sub6.h b/engines/titanic/star_control/star_control_sub6.h
index 06d0c2e..16304b8 100644
--- a/engines/titanic/star_control/star_control_sub6.h
+++ b/engines/titanic/star_control/star_control_sub6.h
@@ -46,11 +46,18 @@ public:
 	void clear();
 
 	/**
+	 * Sets up a passed instance from the specified two other ones
+	 */
+	static void setup(CStarControlSub6 *dest, const CStarControlSub6 *s2, const CStarControlSub6 *s3);
+
+	/**
 	 * Sets the default data
 	 */
 	void set(int mode, double val);
 
 	void copyFrom(const CStarControlSub6 *src);
+
+	void fn1(CStarControlSub6 *sub6);
 };
 
 } // End of namespace Titanic
diff --git a/engines/titanic/star_control/star_control_sub7.cpp b/engines/titanic/star_control/star_control_sub7.cpp
index b33f8be..7da2592 100644
--- a/engines/titanic/star_control/star_control_sub7.cpp
+++ b/engines/titanic/star_control/star_control_sub7.cpp
@@ -24,12 +24,28 @@
 
 namespace Titanic {
 
-void CStarControlSub7::proc2(int v1, int v2, int v3) {
+void CStarControlSub7::draw(CSurfaceArea *surfaceArea, CStarControlSub12 *sub12, CStarControlSub5 *sub5) {
 	// TODO
 }
 
-bool CStarControlSub7::proc5(int v1) {
-	// TODO
+bool CStarControlSub7::addStar(const CBaseStarEntry *entry) {
+	// iterate through the existing stars
+	for (uint idx = 0; idx < _data.size(); ++idx) {
+		CBaseStarEntry &star = _data[idx];
+		if (star == *entry) {
+			// Found a matching star at the exact same position, so remove it instead
+			_data.remove_at(idx);
+			return;
+		}
+	}
+
+	// No existing match
+	if (_data.size() == 32)
+		// Out of space, so delete oldest star
+		_data.remove_at(0);
+
+	// Add new star
+	_data.push_back(*entry);
 	return true;
 }
 
diff --git a/engines/titanic/star_control/star_control_sub7.h b/engines/titanic/star_control/star_control_sub7.h
index b73124d..619e779 100644
--- a/engines/titanic/star_control/star_control_sub7.h
+++ b/engines/titanic/star_control/star_control_sub7.h
@@ -30,8 +30,15 @@ class CStarControlSub7 : public CBaseStar {
 public:
 	virtual ~CStarControlSub7() { clear(); }
 
-	virtual void proc2(int v1, int v2, int v3);
-	virtual bool proc5(int v1);
+	/**
+	 * Draw the item
+	 */
+	virtual void draw(CSurfaceArea *surfaceArea, CStarControlSub12 *sub12, CStarControlSub5 *sub5);
+
+	/**
+	 * Adds a new star, or removes one if already present at the given co-ordinates
+	 */
+	virtual bool addStar(const CBaseStarEntry *entry);
 };
 
 } // End of namespace Titanic





More information about the Scummvm-git-logs mailing list