[Scummvm-git-logs] scummvm master -> 68d43a431a56045cd69c6f07705269c4938ea589

dreammaster dreammaster at scummvm.org
Wed Aug 23 01:20:32 CEST 2017


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

Summary:
ffbfdac87e TITANIC: Change ship view and position even if not moved
2a96a6fc72 TITANIC: Prevent 2 star locking for large distances
04598dd5ad TITANIC: Named some functions in fvector
09a7a139f4 TITANIC: Camera Auto Mover class cleanup
c06055e1a4 TITANIC: Made variable for magic number used in auto camera mover
68d43a431a Merge pull request #997 from dafioram/star_fix10148


Commit: ffbfdac87ed43535091f5273eea3dd9e8ec6d979
    https://github.com/scummvm/scummvm/commit/ffbfdac87ed43535091f5273eea3dd9e8ec6d979
Author: David Fioramonti (dafioram at gmail.com)
Date: 2017-08-20T13:24:37-07:00

Commit Message:
TITANIC: Change ship view and position even if not moved

The code was preventing the position and view from changing
when the distance between the current and new position for
a marked auto mover was zero. This happens if you lock the
2nd or 3rd star and then unlock and relock again.

It was prevented this with asserts and if statement checks
and I removed them all.

This section of code isn't doing any inverses based on the
reciprocal of the distance so theres no issue with allowing
transition speeds/distances of zero.

Fixes #10148.

Changed paths:
    engines/titanic/star_control/camera_auto_mover.cpp
    engines/titanic/star_control/marked_auto_mover.cpp
    engines/titanic/star_control/star_camera.cpp


diff --git a/engines/titanic/star_control/camera_auto_mover.cpp b/engines/titanic/star_control/camera_auto_mover.cpp
index bcb94d2..60a1cbd 100644
--- a/engines/titanic/star_control/camera_auto_mover.cpp
+++ b/engines/titanic/star_control/camera_auto_mover.cpp
@@ -50,10 +50,8 @@ void CCameraAutoMover::proc2(const FVector &oldPos, const FVector &newPos,
 	_destPos = newPos;
 	_posDelta = _destPos - _srcPos;
        float temp = 0.0;
-	if (!_posDelta.normalize(temp)) { // Do the normalization, put the scale amount in temp,
-                                         // but if it is unsuccessful, crash
-              assert(temp);
-       }
+	bool unused_status = _posDelta.normalize(temp); // Do the normalization, put the scale amount in temp
+
        _distance = temp;
 	_active = false;
 	_field34 = false;
diff --git a/engines/titanic/star_control/marked_auto_mover.cpp b/engines/titanic/star_control/marked_auto_mover.cpp
index e3ab2b4..0a2da6d 100644
--- a/engines/titanic/star_control/marked_auto_mover.cpp
+++ b/engines/titanic/star_control/marked_auto_mover.cpp
@@ -32,24 +32,22 @@ void CMarkedAutoMover::proc2(const FVector &oldPos, const FVector &newPos,
 	CCameraAutoMover::proc2(oldPos, newPos, oldOrientation, newOrientation);
 
 	double distance = _distance;
-	if (distance > 0.0) {
+	_active = true;
+	_field34 = true;
+	proc6(120, 4, distance);
+
+
+	_orientationChanger.load(oldOrientation, newOrientation);
+	_transitionPercent = 0.0;
+
+	if (_field4C == 0) {
+		_transitionPercentInc = 0.1;
+		_active = true;
+	} else {
+		_transitionPercentInc = 1.0 / _field4C;
 		_active = true;
-		_field34 = true;
-		proc6(120, 4, distance);
 	}
 
-	if (newPos != oldPos) {
-		_orientationChanger.load(oldOrientation, newOrientation);
-		_transitionPercent = 0.0;
-
-		if (_field4C == 0) {
-			_transitionPercentInc = 0.1;
-			_active = true;
-		} else {
-			_transitionPercentInc = 1.0 / _field4C;
-			_active = true;
-		}
-	}
 }
 
 int CMarkedAutoMover::proc5(CErrorCode &errorCode, FVector &pos, FMatrix &orientation) {
diff --git a/engines/titanic/star_control/star_camera.cpp b/engines/titanic/star_control/star_camera.cpp
index f1bf24b..fa19b95 100644
--- a/engines/titanic/star_control/star_camera.cpp
+++ b/engines/titanic/star_control/star_camera.cpp
@@ -582,10 +582,7 @@ void CStarCamera::lockMarker2(CViewport *viewport, const FVector &v) {
 
 	FVector newPos = m4._col1;
 	
-	if (_viewport._position != newPos) {
-		// Only change view if positions are different
-		_mover->proc8(_viewport._position, newPos, m6, m5);
-	}
+	_mover->proc8(_viewport._position, newPos, m6, m5);
 
 	CStarVector *sv = new CStarVector(this, v);
 	_mover->setVector(sv);
@@ -600,10 +597,7 @@ void CStarCamera::lockMarker3(CViewport *viewport, const FVector &v) {
 	FVector newPos = viewport->_position;
 	FVector oldPos = _viewport._position;
 
-	if (oldPos != newPos) {
-		// Only change view if positions are different
-		_mover->proc8(oldPos, newPos, oldOr, newOr);
-	}
+	_mover->proc8(oldPos, newPos, oldOr, newOr);
 
 	CStarVector *sv = new CStarVector(this, v);
 	_mover->setVector(sv);


Commit: 2a96a6fc7288a33a3726191338308af3581c9883
    https://github.com/scummvm/scummvm/commit/2a96a6fc7288a33a3726191338308af3581c9883
Author: David Fioramonti (dafioram at gmail.com)
Date: 2017-08-20T20:25:31-07:00

Commit Message:
TITANIC: Prevent 2 star locking for large distances

I have added a conditional to the code so that if the player
tries to lock onto the 2nd star and they are very far away, >1e8,
then the game will not allow the star to be locked.

This is a temporary workaround since if a distance of farther
then this is attempted then the view will be throw way off
and the stars will not be shown locking onto correctly.

I've also made the locking functions return booleans so I can
determine the success of the lockings.

This is a partial fix for #9961.

Changed paths:
    engines/titanic/star_control/star_camera.cpp
    engines/titanic/star_control/star_camera.h
    engines/titanic/star_control/star_view.cpp


diff --git a/engines/titanic/star_control/star_camera.cpp b/engines/titanic/star_control/star_camera.cpp
index fa19b95..af671eb 100644
--- a/engines/titanic/star_control/star_camera.cpp
+++ b/engines/titanic/star_control/star_camera.cpp
@@ -450,9 +450,9 @@ void CStarCamera::deleteHandler() {
 	}
 }
 
-void CStarCamera::lockMarker1(FVector v1, FVector v2, FVector v3) {
+bool CStarCamera::lockMarker1(FVector v1, FVector v2, FVector v3) {
 	if (_starLockState != ZERO_LOCKED)
-		return;
+		return true;
 
 	FVector tempV;
 	double val1, val2, val3, val4, val5;
@@ -487,11 +487,12 @@ void CStarCamera::lockMarker1(FVector v1, FVector v2, FVector v3) {
 
 	CStarVector *sv = new CStarVector(this, v2);
 	_mover->setVector(sv);
+	return	true;
 }
 
-void CStarCamera::lockMarker2(CViewport *viewport, const FVector &v) {
+bool CStarCamera::lockMarker2(CViewport *viewport, const FVector &v) {
 	if (_starLockState != ONE_LOCKED)
-		return;
+		return true;
 
 	DAffine m2(X_AXIS, _matrix._row1);
 	DVector tempV1 = v - _matrix._row1;
@@ -567,7 +568,7 @@ void CStarCamera::lockMarker2(CViewport *viewport, const FVector &v) {
 	m4._col2 -= m4._col1;
 	m4._col4 -= m4._col1;
 
-	FMatrix m6 = _viewport.getOrientation();
+
 
 	double unusedScale=0.0;
 	if (!m4._col2.normalize(unusedScale) ||
@@ -581,16 +582,28 @@ void CStarCamera::lockMarker2(CViewport *viewport, const FVector &v) {
 	m5.set(m4._col3, m4._col2, m4._col4);
 
 	FVector newPos = m4._col1;
-	
-	_mover->proc8(_viewport._position, newPos, m6, m5);
+	FMatrix m6 = _viewport.getOrientation();
 
-	CStarVector *sv = new CStarVector(this, v);
-	_mover->setVector(sv);
+	if (minDistance > 1.0e8) {
+		// The transition will do poorly in this case.
+		//removeLockedStar(); // undo locking 2nd star
+		_mover->proc8(_viewport._position, _viewport._position, m6, m6);
+		//CStarVector *sv = new CStarVector(this, v);
+		//_mover->setVector(sv);
+		return	false;
+	}	
+	else {
+		_mover->proc8(_viewport._position, newPos, m6, m5);
+		CStarVector *sv = new CStarVector(this, v);
+		_mover->setVector(sv);
+		
+	}
+	return	true;
 }
 
-void CStarCamera::lockMarker3(CViewport *viewport, const FVector &v) {
+bool CStarCamera::lockMarker3(CViewport *viewport, const FVector &v) {
 	if (_starLockState != TWO_LOCKED)
-		return;
+		return true;
 
 	FMatrix newOr = viewport->getOrientation();
 	FMatrix oldOr = _viewport.getOrientation();
@@ -601,6 +614,7 @@ void CStarCamera::lockMarker3(CViewport *viewport, const FVector &v) {
 
 	CStarVector *sv = new CStarVector(this, v);
 	_mover->setVector(sv);
+	return true;
 }
 
 } // End of namespace Titanic
diff --git a/engines/titanic/star_control/star_camera.h b/engines/titanic/star_control/star_camera.h
index 2d4ce57..572995f 100644
--- a/engines/titanic/star_control/star_camera.h
+++ b/engines/titanic/star_control/star_camera.h
@@ -207,17 +207,17 @@ public:
 	/**
 	 * Lock in the first matched star marker
 	 */
-	void lockMarker1(FVector v1, FVector v2, FVector v3);
+	bool lockMarker1(FVector v1, FVector v2, FVector v3);
 	
 	/**
 	 * Lock in the second matched star marker
 	 */
-	void lockMarker2(CViewport *viewport, const FVector &v);
+	bool lockMarker2(CViewport *viewport, const FVector &v);
 
 	/**
 	 * Lock in the third and final matched star marker
 	 */
-	void lockMarker3(CViewport *viewport, const FVector &v);
+	bool lockMarker3(CViewport *viewport, const FVector &v);
 };
 
 } // End of namespace Titanic
diff --git a/engines/titanic/star_control/star_view.cpp b/engines/titanic/star_control/star_view.cpp
index 578cc00..ec972d1 100644
--- a/engines/titanic/star_control/star_view.cpp
+++ b/engines/titanic/star_control/star_view.cpp
@@ -397,6 +397,7 @@ void CStarView::lockStar() {
 		CSurfaceArea surfaceArea(_videoSurface);
 		FVector v1, v2, v3;
 		double val = _starField->fn5(&surfaceArea, &_camera, v1, v2, v3);
+		bool lockSuccess = false;
 
 		if (val > -1.0) {
 			v1 -= surfaceArea._centroid;
@@ -405,19 +406,22 @@ void CStarView::lockStar() {
 			switch (_starField->getMatchedIndex()) {
 			case -1:
 				// First star match
-				_camera.lockMarker1(v1, v2, v3);
+				lockSuccess = _camera.lockMarker1(v1, v2, v3);
+				assert(lockSuccess); // lockMarker1 should always succeed
 				_starField->incMatches();
 				break;
 
 			case 0:
 				// Second star match
-				_camera.lockMarker2(&_photoViewport, v2);
-				_starField->incMatches();
+				lockSuccess = _camera.lockMarker2(&_photoViewport, v2);
+				if (lockSuccess) // lockMarker2 may have issues
+					_starField->incMatches();
 				break;
 
 			case 1:
 				// Third star match
-				_camera.lockMarker3(&_photoViewport, v2);
+				lockSuccess = _camera.lockMarker3(&_photoViewport, v2);
+				assert(lockSuccess); // lockMarker3 should always succeed
 				_starField->incMatches();
 				break;
 


Commit: 04598dd5adbafcc6821dfc9f2927457fc20a3c7c
    https://github.com/scummvm/scummvm/commit/04598dd5adbafcc6821dfc9f2927457fc20a3c7c
Author: David Fioramonti (dafioram at gmail.com)
Date: 2017-08-21T15:42:50-07:00

Commit Message:
TITANIC: Named some functions in fvector

Changed paths:
    engines/titanic/star_control/fmatrix.cpp
    engines/titanic/star_control/fvector.cpp
    engines/titanic/star_control/fvector.h
    engines/titanic/star_control/star_camera.cpp
    engines/titanic/star_control/viewport.cpp


diff --git a/engines/titanic/star_control/fmatrix.cpp b/engines/titanic/star_control/fmatrix.cpp
index 470569c..e633db5 100644
--- a/engines/titanic/star_control/fmatrix.cpp
+++ b/engines/titanic/star_control/fmatrix.cpp
@@ -124,7 +124,7 @@ void FMatrix::set(const DVector &row1, const DVector &row2, const DVector &row3)
 
 void FMatrix::set(const FVector &v) {
 	_row3 = v;
-	_row2 = _row3.fn1();
+	_row2 = _row3.swapComponents();
 
 	_row1 = _row3.crossProduct(_row2);
 
diff --git a/engines/titanic/star_control/fvector.cpp b/engines/titanic/star_control/fvector.cpp
index 75d3074..142d9ea 100644
--- a/engines/titanic/star_control/fvector.cpp
+++ b/engines/titanic/star_control/fvector.cpp
@@ -31,7 +31,7 @@ namespace Titanic {
 FVector::FVector(const DVector &src) : _x(src._x), _y(src._y), _z(src._z) {
 }
 
-FVector FVector::fn1() const {
+FVector FVector::swapComponents() const {
 	return FVector(
 		(ABS(_x - _y) < 0.00001 && ABS(_y - _z) < 0.00001 &&
 			ABS(_x - _z) < 0.00001) ? -_y : _y,
@@ -78,7 +78,7 @@ float FVector::getDistance(const FVector &src) const {
 	return sqrt(xd * xd + yd * yd + zd * zd);
 }
 
-FVector FVector::fn5(const FPose &pose) const {
+FVector FVector::MatProdRowVect(const FPose &pose) const {
 	FVector v;
 	v._x = pose._row2._x * _y + pose._row3._x * _z + pose._row1._x * _x + pose._vector._x;
 	v._y = pose._row2._y * _y + pose._row3._y * _z + pose._row1._y * _x + pose._vector._y;
diff --git a/engines/titanic/star_control/fvector.h b/engines/titanic/star_control/fvector.h
index f93ac60..ed5789a 100644
--- a/engines/titanic/star_control/fvector.h
+++ b/engines/titanic/star_control/fvector.h
@@ -51,7 +51,12 @@ public:
 		_x = _y = _z = 0.0;
 	}
 
-	FVector fn1() const;
+	/**
+	 * Returns a vector with all components of this vector circularlly rotated up 1.
+	 * this x being _y, this y being _z, and this z being _x. A sign change may also
+	 * be done on x/_y based on some conditions.
+	 */
+	FVector swapComponents() const;
 
 	/**
 	 * Calculates the cross-product between this matrix and a passed one
@@ -80,7 +85,11 @@ public:
 	 */
 	float getDistance(const FVector &src) const;
 
-	FVector fn5(const FPose &pose) const;
+	/**
+	 * Returns a vector that is this vector on the left as a row vector
+	 * times the 3x4 affine matrix on the right.
+	 */
+	FVector MatProdRowVect(const FPose &pose) const;
 
 	/**
 	 * Returns true if the passed vector equals this one
diff --git a/engines/titanic/star_control/star_camera.cpp b/engines/titanic/star_control/star_camera.cpp
index af671eb..68427a3 100644
--- a/engines/titanic/star_control/star_camera.cpp
+++ b/engines/titanic/star_control/star_camera.cpp
@@ -269,10 +269,10 @@ void CStarCamera::setViewportAngle(const FPoint &angles) {
 		tempV5 -= row1;
 		tempV6 -= row1;
 
-		tempV1 = tempV1.fn5(pose);
-		tempV4 = tempV4.fn5(pose);
-		tempV5 = tempV5.fn5(pose);
-		tempV6 = tempV6.fn5(pose);
+		tempV1 = tempV1.MatProdRowVect(pose);
+		tempV4 = tempV4.MatProdRowVect(pose);
+		tempV5 = tempV5.MatProdRowVect(pose);
+		tempV6 = tempV6.MatProdRowVect(pose);
 
 		tempV4 -= tempV1;
 		tempV5 -= tempV1;
diff --git a/engines/titanic/star_control/viewport.cpp b/engines/titanic/star_control/viewport.cpp
index 130d59d..529b4be 100644
--- a/engines/titanic/star_control/viewport.cpp
+++ b/engines/titanic/star_control/viewport.cpp
@@ -107,7 +107,7 @@ void CViewport::setPosition(const FVector &v) {
 }
 
 void CViewport::setPosition(const FPose &pose) {
-	_position = _position.fn5(pose);
+	_position = _position.MatProdRowVect(pose);
 	_flag = false;
 }
 
@@ -215,7 +215,7 @@ FVector CViewport::fn16(int index, const FVector &src) {
 FVector CViewport::fn17(int index, const FVector &src) {
 	FVector dest;
 	FPose pose = getPose();
-	FVector tv = src.fn5(pose);
+	FVector tv = src.MatProdRowVect(pose);
 
 	dest._x = (_valArray[index] + tv._x)
 		* _centerVector._x / (_centerVector._y * tv._z);
@@ -227,7 +227,7 @@ FVector CViewport::fn17(int index, const FVector &src) {
 FVector CViewport::fn18(int index, const FVector &src) {
 	FVector dest;
 	FPose pose = getRawPose();
-	FVector tv = src.fn5(pose);
+	FVector tv = src.MatProdRowVect(pose);
 
 	dest._x = (_valArray[index] + tv._x)
 		* _centerVector._x / (_centerVector._y * tv._z);


Commit: 09a7a139f41a94162e00aa32fa4e37e0ce412d6c
    https://github.com/scummvm/scummvm/commit/09a7a139f41a94162e00aa32fa4e37e0ce412d6c
Author: David Fioramonti (dafioram at gmail.com)
Date: 2017-08-21T15:57:53-07:00

Commit Message:
TITANIC: Camera Auto Mover class cleanup

Named some functions, made _speeds be an array instead of
a dynamic one.

Changed paths:
    engines/titanic/star_control/camera_auto_mover.cpp
    engines/titanic/star_control/camera_auto_mover.h
    engines/titanic/star_control/marked_auto_mover.cpp
    engines/titanic/star_control/unmarked_auto_mover.cpp


diff --git a/engines/titanic/star_control/camera_auto_mover.cpp b/engines/titanic/star_control/camera_auto_mover.cpp
index 60a1cbd..b94c4d6 100644
--- a/engines/titanic/star_control/camera_auto_mover.cpp
+++ b/engines/titanic/star_control/camera_auto_mover.cpp
@@ -50,8 +50,7 @@ void CCameraAutoMover::proc2(const FVector &oldPos, const FVector &newPos,
 	_destPos = newPos;
 	_posDelta = _destPos - _srcPos;
        float temp = 0.0;
-	bool unused_status = _posDelta.normalize(temp); // Do the normalization, put the scale amount in temp
-
+	_posDelta.normalize(temp); // Do the normalization, put the scale amount in temp
        _distance = temp;
 	_active = false;
 	_field34 = false;
@@ -90,17 +89,16 @@ void CCameraAutoMover::setPath(const FVector &srcV, const FVector &destV, const
 	_transitionPercent = 1.0;
 }
 
-void CCameraAutoMover::proc6(int val1, int val2, float val) {
+void CCameraAutoMover::calcSpeeds(int val1, int val2, float distance) {
 	_field44 = val1;
 	_field4C = val1 + 62;
-	_field38 = val / (double)(val1 + val2 * 2);
+	_field38 = distance / (double)(val1 + val2 * 2);
 	_field40 = 31;
 	_field48 = 31;
 	_field3C = (double)val2 * _field38;
 	
 	// Calculate the speeds for a graduated movement between stars
 	double base = 0.0, total = 0.0;
-	_speeds.resize(32);
 	for (int idx = 31; idx >= 0; --idx) {
 		_speeds[idx] = pow(base, 4.0);
 		total += _speeds[idx];
diff --git a/engines/titanic/star_control/camera_auto_mover.h b/engines/titanic/star_control/camera_auto_mover.h
index dc9cf6d..7b2e44f 100644
--- a/engines/titanic/star_control/camera_auto_mover.h
+++ b/engines/titanic/star_control/camera_auto_mover.h
@@ -49,7 +49,7 @@ protected:
 	int _field44;
 	int _field48;
 	int _field4C;
-	Common::Array<double> _speeds;
+	double _speeds[32];
 	int _field54;
 	double _transitionPercent;
 	double _transitionPercentInc;
@@ -63,7 +63,11 @@ public:
 	virtual void proc3(const FMatrix &srcOrient, const FMatrix &destOrient);
 	virtual void setPath(const FVector &srcV, const FVector &destV, const FMatrix &orientation);
 	virtual int proc5(CErrorCode &errorCode, FVector &pos, FMatrix &orientation) { return 2; }
-	virtual void proc6(int val1, int val2, float val);
+	/**
+	 * Given a distance to cover, determines a bunch of speeds for a gradual transition
+	 * from one position to another (the mover). The speeds go from fast to slow
+	 */
+	virtual void calcSpeeds(int val1, int val2, float distance);
 
 	bool isActive() const { return _active; }
 };
diff --git a/engines/titanic/star_control/marked_auto_mover.cpp b/engines/titanic/star_control/marked_auto_mover.cpp
index 0a2da6d..22eb695 100644
--- a/engines/titanic/star_control/marked_auto_mover.cpp
+++ b/engines/titanic/star_control/marked_auto_mover.cpp
@@ -34,7 +34,7 @@ void CMarkedAutoMover::proc2(const FVector &oldPos, const FVector &newPos,
 	double distance = _distance;
 	_active = true;
 	_field34 = true;
-	proc6(120, 4, distance);
+	calcSpeeds(120, 4, distance);
 
 
 	_orientationChanger.load(oldOrientation, newOrientation);
diff --git a/engines/titanic/star_control/unmarked_auto_mover.cpp b/engines/titanic/star_control/unmarked_auto_mover.cpp
index 71063fa..1461132 100644
--- a/engines/titanic/star_control/unmarked_auto_mover.cpp
+++ b/engines/titanic/star_control/unmarked_auto_mover.cpp
@@ -42,7 +42,7 @@ void CUnmarkedAutoMover::setPath(const FVector &srcV, const FVector &destV, cons
 	if (_distance > 8000.0) {
 		_active = true;
 		_field34 = 1;
-		proc6(120, 4, _distance - 8000.0);
+		calcSpeeds(120, 4, _distance - 8000.0);
 	}
 
 	FVector row3 = orientation._row3;


Commit: c06055e1a4433792ed517d8ae3034e113424b85a
    https://github.com/scummvm/scummvm/commit/c06055e1a4433792ed517d8ae3034e113424b85a
Author: David Fioramonti (dafioram at gmail.com)
Date: 2017-08-21T16:55:25-07:00

Commit Message:
TITANIC: Made variable for magic number used in auto camera mover

This variable controls the number of transitions the game goes
through when the mover is changing position. This reduces
several 31/32s from the code.

Changed paths:
    engines/titanic/star_control/camera_auto_mover.cpp
    engines/titanic/star_control/camera_auto_mover.h
    engines/titanic/star_control/marked_auto_mover.cpp
    engines/titanic/star_control/unmarked_auto_mover.cpp


diff --git a/engines/titanic/star_control/camera_auto_mover.cpp b/engines/titanic/star_control/camera_auto_mover.cpp
index b94c4d6..aa29fa0 100644
--- a/engines/titanic/star_control/camera_auto_mover.cpp
+++ b/engines/titanic/star_control/camera_auto_mover.cpp
@@ -90,22 +90,24 @@ void CCameraAutoMover::setPath(const FVector &srcV, const FVector &destV, const
 }
 
 void CCameraAutoMover::calcSpeeds(int val1, int val2, float distance) {
+	// Usually val1 and val2 are small where as distance can be large
 	_field44 = val1;
-	_field4C = val1 + 62;
+	_field4C = val1 + 2 * nMoverTransitions; // For _nMoverTransitions = 32 this second value was 64, 
+				 		     // should it always be x2 _nMoverTransitions?
 	_field38 = distance / (double)(val1 + val2 * 2);
-	_field40 = 31;
-	_field48 = 31;
+	_field40 = nMoverTransitions-1;
+	_field48 = nMoverTransitions-1;
 	_field3C = (double)val2 * _field38;
 	
 	// Calculate the speeds for a graduated movement between stars
-	double base = 0.0, total = 0.0;
-	for (int idx = 31; idx >= 0; --idx) {
-		_speeds[idx] = pow(base, 4.0);
+	double base = 0.0, total = 0.0, power = 4.0, baseInc = 0.03125;
+	for (int idx = nMoverTransitions - 1; idx >= 0; --idx) {
+		_speeds[idx] = pow(base, power);
 		total += _speeds[idx];
-		base += 0.03125;
+		base += baseInc;
 	}
 	
-	for (int idx = 0; idx < 32; ++idx) {
+	for (int idx = 0; idx < nMoverTransitions; ++idx) {
 		_speeds[idx] = _speeds[idx] * _field3C / total;
 	}
 }
diff --git a/engines/titanic/star_control/camera_auto_mover.h b/engines/titanic/star_control/camera_auto_mover.h
index 7b2e44f..210bd74 100644
--- a/engines/titanic/star_control/camera_auto_mover.h
+++ b/engines/titanic/star_control/camera_auto_mover.h
@@ -31,6 +31,7 @@ namespace Titanic {
 
 class CErrorCode;
 class FMatrix;
+const int nMoverTransitions = 32; // The number of vector transitions when doing a mover change is fixed
 
 /**
  * Base class for automatic movement of the starview camera
@@ -49,7 +50,7 @@ protected:
 	int _field44;
 	int _field48;
 	int _field4C;
-	double _speeds[32];
+	double _speeds[nMoverTransitions];
 	int _field54;
 	double _transitionPercent;
 	double _transitionPercentInc;
diff --git a/engines/titanic/star_control/marked_auto_mover.cpp b/engines/titanic/star_control/marked_auto_mover.cpp
index 22eb695..0a1a7e4 100644
--- a/engines/titanic/star_control/marked_auto_mover.cpp
+++ b/engines/titanic/star_control/marked_auto_mover.cpp
@@ -74,7 +74,7 @@ int CMarkedAutoMover::proc5(CErrorCode &errorCode, FVector &pos, FMatrix &orient
 		errorCode.set();
 		return 1;
 	} else if (_field48 >= 0) {
-		double speedVal = _speeds[31 - _field48];
+		double speedVal = _speeds[nMoverTransitions - 1 - _field48];
 		pos += _posDelta * speedVal;
 		getVectorOnPath(pos);
 
diff --git a/engines/titanic/star_control/unmarked_auto_mover.cpp b/engines/titanic/star_control/unmarked_auto_mover.cpp
index 1461132..424e143 100644
--- a/engines/titanic/star_control/unmarked_auto_mover.cpp
+++ b/engines/titanic/star_control/unmarked_auto_mover.cpp
@@ -148,7 +148,7 @@ int CUnmarkedAutoMover::proc5(CErrorCode &errorCode, FVector &pos, FMatrix &orie
 	}
 
 	if (_field48 >= 0) {
-		double speedVal = _speeds[31 - _field48];
+		double speedVal = _speeds[nMoverTransitions - 1 - _field48];
 		v1._y = v2._y * speedVal;
 		v1._z = v2._z * speedVal;
 		v1._x = v2._x * speedVal;


Commit: 68d43a431a56045cd69c6f07705269c4938ea589
    https://github.com/scummvm/scummvm/commit/68d43a431a56045cd69c6f07705269c4938ea589
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2017-08-22T19:20:25-04:00

Commit Message:
Merge pull request #997 from dafioram/star_fix10148

TITANIC: Change ship view and position even if not moved

Changed paths:
    engines/titanic/star_control/camera_auto_mover.cpp
    engines/titanic/star_control/camera_auto_mover.h
    engines/titanic/star_control/fmatrix.cpp
    engines/titanic/star_control/fvector.cpp
    engines/titanic/star_control/fvector.h
    engines/titanic/star_control/marked_auto_mover.cpp
    engines/titanic/star_control/star_camera.cpp
    engines/titanic/star_control/star_camera.h
    engines/titanic/star_control/star_view.cpp
    engines/titanic/star_control/unmarked_auto_mover.cpp
    engines/titanic/star_control/viewport.cpp







More information about the Scummvm-git-logs mailing list