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

dreammaster dreammaster at scummvm.org
Sun Aug 20 20:31:54 CEST 2017


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

Summary:
524855d173 TITANIC: Change variable for tracking stars marked into enum
1370b49b6a TITANIC: Simplified dependencies for classes related to star_camera
b200317306 TITANIC: Renamed functions that adds/removes stars/markers
82d0053f8b TITANIC: Add logic to prevent removing locked/marked stars via skymap
24bec379d5 TITANIC: Pull assert out of dvector/fvector normalization
312d63c3c9 TITANIC: Prevent moving for locking stars when onto of star
a32a29a80e Merge pull request #995 from dafioram/star_camera_work


Commit: 524855d173699a6b56dd932a70e2d9a1e4068d8c
    https://github.com/scummvm/scummvm/commit/524855d173699a6b56dd932a70e2d9a1e4068d8c
Author: David Fioramonti (dafioram at gmail.com)
Date: 2017-08-18T04:54:27-07:00

Commit Message:
TITANIC: Change variable for tracking stars marked into enum

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


diff --git a/engines/titanic/star_control/star_camera.cpp b/engines/titanic/star_control/star_camera.cpp
index 9c1c598..76302d2 100644
--- a/engines/titanic/star_control/star_camera.cpp
+++ b/engines/titanic/star_control/star_camera.cpp
@@ -33,12 +33,12 @@ FMatrix *CStarCamera::_priorOrientation;
 FMatrix *CStarCamera::_newOrientation;
 
 CStarCamera::CStarCamera(const CNavigationInfo *data) :
-		_matrixRow(-1), _mover(nullptr), _isMoved(false) {
+		_star_lock_state(ZERO_LOCKED), _mover(nullptr), _isMoved(false) {
 	setupHandler(data);
 }
 
 CStarCamera::CStarCamera(CViewport *src) :
-		_matrixRow(-1), _mover(nullptr), _isMoved(false), _viewport(src) {
+		_star_lock_state(ZERO_LOCKED), _mover(nullptr), _isMoved(false), _viewport(src) {
 }
 
 void CStarCamera::init() {
@@ -226,15 +226,16 @@ void CStarCamera::setViewportAngle(const FPoint &angles) {
 
 	if (isLocked())
 		return;
-
-	if (_matrixRow == -1) {
-		// No locked markers
+       switch(_star_lock_state) {
+	case ZERO_LOCKED: {
 		FPose subX(X_AXIS, angles._y);
 		FPose subY(Y_AXIS, -angles._x); // needs to be negative or looking left will cause the view to go right
 		FPose sub(subX, subY);
 		proc22(sub);
-	} else if (_matrixRow == 0) {
-		// 1 marker is locked in
+       }
+              break;
+
+       case ONE_LOCKED: {
 		FVector row1 = _matrix._row1;
 		FPose poseX(X_AXIS, angles._y);
 		FPose poseY(Y_AXIS, -angles._x); // needs to be negative or looking left will cause the view to go right
@@ -275,8 +276,10 @@ void CStarCamera::setViewportAngle(const FPoint &angles) {
 		m1.set(tempV4, tempV5, tempV6);
 		_viewport.setOrientation(m1);
 		_viewport.setPosition(tempV1);
-	} else if (_matrixRow == 1) {
-		// 2 markers locked in
+       }
+              break;
+
+       case TWO_LOCKED: {
 		FVector tempV2;
 		DAffine m1, m2, sub;
 		DVector mrow1, mrow2, mrow3;
@@ -342,32 +345,38 @@ void CStarCamera::setViewportAngle(const FPoint &angles) {
 		m3.set(mrow1, mrow2, mrow3);
 		_viewport.setOrientation(m3);
 		_viewport.setPosition(tempV16);
-	}
+       }
+              break;
+
+       //TODO: should three stars locked do anything in this function? Error?
+       case THREE_LOCKED:
+              break;
+       }
 }
 
 bool CStarCamera::adDAffineRow(const FVector v) {
-	if (_matrixRow >= 2)
+	if (_star_lock_state == THREE_LOCKED)
 		return false;
 
 	CNavigationInfo data;
 	_mover->copyTo(&data);
 	deleteHandler();
-
-	FVector &row = _matrix[++_matrixRow];
+	FVector &row = _matrix[(int)_star_lock_state];
+       _star_lock_state = StarLockState( (int)_star_lock_state + 1);
 	row = v;
 	setupHandler(&data);
 	return true;
 }
 
 bool CStarCamera::removeMatrixRow() {
-	if (_matrixRow == -1)
+	if (_star_lock_state == ZERO_LOCKED)
 		return false;
 
 	CNavigationInfo data;
 	_mover->copyTo(&data);
 	deleteHandler();
 
-	--_matrixRow;
+	_star_lock_state = StarLockState( (int)_star_lock_state - 1);
 	setupHandler(&data);
 	return true;
 }
@@ -387,14 +396,14 @@ void CStarCamera::save(SimpleFile *file, int indent) {
 bool CStarCamera::setupHandler(const CNavigationInfo *src) {
 	CCameraMover *mover = nullptr;
 
-	switch (_matrixRow) {
-	case -1:
+	switch (_star_lock_state) {
+	case ZERO_LOCKED:
 		mover = new CUnmarkedCameraMover(src);
 		break;
 
-	case 0:
-	case 1:
-	case 2:
+	case ONE_LOCKED:
+	case TWO_LOCKED:
+	case THREE_LOCKED:
 		mover = new CMarkedCameraMover(src);
 		break;
 
@@ -419,7 +428,7 @@ void CStarCamera::deleteHandler() {
 }
 
 void CStarCamera::lockMarker1(FVector v1, FVector v2, FVector v3) {
-	if (_matrixRow != -1)
+	if (_star_lock_state != ZERO_LOCKED)
 		return;
 
 	FVector tempV;
@@ -454,7 +463,7 @@ void CStarCamera::lockMarker1(FVector v1, FVector v2, FVector v3) {
 }
 
 void CStarCamera::lockMarker2(CViewport *viewport, const FVector &v) {
-	if (_matrixRow != 0)
+	if (_star_lock_state != ONE_LOCKED)
 		return;
 
 	DAffine m2(X_AXIS, _matrix._row1);
@@ -545,7 +554,7 @@ void CStarCamera::lockMarker2(CViewport *viewport, const FVector &v) {
 }
 
 void CStarCamera::lockMarker3(CViewport *viewport, const FVector &v) {
-	if (_matrixRow != 1)
+	if (_star_lock_state != TWO_LOCKED)
 		return;
 
 	FMatrix newOr = viewport->getOrientation();
diff --git a/engines/titanic/star_control/star_camera.h b/engines/titanic/star_control/star_camera.h
index fa46eb3..3cdea2a 100644
--- a/engines/titanic/star_control/star_camera.h
+++ b/engines/titanic/star_control/star_camera.h
@@ -33,6 +33,8 @@
 
 namespace Titanic {
 
+enum StarLockState { ZERO_LOCKED=0, ONE_LOCKED=1, TWO_LOCKED=2, THREE_LOCKED=3 };
+
 /**
  * Implements a reference point from which the starmap can be viewed
  */
@@ -41,7 +43,7 @@ private:
 	static FMatrix *_priorOrientation;
 	static FMatrix *_newOrientation;
 private:
-	int _matrixRow;
+	StarLockState _star_lock_state;
 	FMatrix _matrix;
 	CCameraMover *_mover;
 	CViewport _viewport;
@@ -107,7 +109,7 @@ public:
 	virtual void increaseForwardSpeed();
 
 	/**
-	 * Decreases movement speed in backward direction
+	 * Increases movement speed in backward direction
 	 */
 	virtual void increaseBackwardSpeed();
 
@@ -155,7 +157,10 @@ public:
 	 */
 	virtual void setViewportAngle(const FPoint &angles);
 
-	virtual int getMatrixRow() const { return _matrixRow; }
+	/**
+	 * How many stars are currently locked onto
+	 */
+	virtual StarLockState getStarLockState() const { return _star_lock_state; }
 
 	/**
 	 * Adds the row for a locked in marker


Commit: 1370b49b6a88e8ea533da5d62a7f37828bf2fca1
    https://github.com/scummvm/scummvm/commit/1370b49b6a88e8ea533da5d62a7f37828bf2fca1
Author: David Fioramonti (dafioram at gmail.com)
Date: 2017-08-18T17:26:05-07:00

Commit Message:
TITANIC: Simplified dependencies for classes related to star_camera

This involved removing header files and forward declaring when possible.
I also reorded the header include files to be local to gloabal.
E.x., in the class implementation the class header file
would be the first included.

This is a first pass of header reduction for star_control/ files

Changed paths:
    engines/titanic/star_control/base_stars.cpp
    engines/titanic/star_control/base_stars.h
    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/fmatrix.h
    engines/titanic/star_control/marked_auto_mover.cpp
    engines/titanic/star_control/marked_camera_mover.cpp
    engines/titanic/star_control/star_camera.cpp
    engines/titanic/star_control/star_camera.h
    engines/titanic/star_control/star_control.cpp
    engines/titanic/star_control/star_view.cpp
    engines/titanic/star_control/star_view.h
    engines/titanic/star_control/unmarked_auto_mover.cpp
    engines/titanic/star_control/unmarked_camera_mover.cpp


diff --git a/engines/titanic/star_control/base_stars.cpp b/engines/titanic/star_control/base_stars.cpp
index 94208e7..ba48770 100644
--- a/engines/titanic/star_control/base_stars.cpp
+++ b/engines/titanic/star_control/base_stars.cpp
@@ -23,6 +23,7 @@
 #include "titanic/star_control/base_stars.h"
 #include "titanic/star_control/star_camera.h"
 #include "titanic/star_control/star_ref.h"
+#include "titanic/support/simple_file.h"
 #include "titanic/titanic.h"
 
 namespace Titanic {
diff --git a/engines/titanic/star_control/base_stars.h b/engines/titanic/star_control/base_stars.h
index e77b20e..4333e32 100644
--- a/engines/titanic/star_control/base_stars.h
+++ b/engines/titanic/star_control/base_stars.h
@@ -23,7 +23,6 @@
 #ifndef TITANIC_BASE_STARS_H
 #define TITANIC_BASE_STARS_H
 
-#include "titanic/support/simple_file.h"
 #include "titanic/star_control/frange.h"
 #include "titanic/star_control/star_closeup.h"
 #include "titanic/star_control/surface_area.h"
@@ -33,6 +32,7 @@ namespace Titanic {
 enum StarMode { MODE_STARFIELD = 0, MODE_PHOTO = 1 };
 
 class CStarCamera;
+class SimpleFile;
 
 struct CBaseStarEntry {
 	byte _red;
diff --git a/engines/titanic/star_control/camera_auto_mover.cpp b/engines/titanic/star_control/camera_auto_mover.cpp
index 45e5a9e..861248f 100644
--- a/engines/titanic/star_control/camera_auto_mover.cpp
+++ b/engines/titanic/star_control/camera_auto_mover.cpp
@@ -21,8 +21,11 @@
  */
 
 #include "titanic/star_control/camera_auto_mover.h"
+#include "titanic/star_control/fmatrix.h"
+#include "titanic/star_control/error_code.h"
 #include "common/textconsole.h"
 
+
 namespace Titanic {
 
 CCameraAutoMover::CCameraAutoMover() : _srcPos(0.0, 1000000.0, 0.0) {
diff --git a/engines/titanic/star_control/camera_auto_mover.h b/engines/titanic/star_control/camera_auto_mover.h
index 5293828..dc9cf6d 100644
--- a/engines/titanic/star_control/camera_auto_mover.h
+++ b/engines/titanic/star_control/camera_auto_mover.h
@@ -23,13 +23,15 @@
 #ifndef TITANIC_CAMERA_AUTO_MOVER_H
 #define TITANIC_CAMERA_AUTO_MOVER_H
 
-#include "titanic/star_control/error_code.h"
-#include "titanic/star_control/fmatrix.h"
 #include "titanic/star_control/fvector.h"
 #include "titanic/star_control/orientation_changer.h"
+#include "common/array.h"
 
 namespace Titanic {
 
+class CErrorCode;
+class FMatrix;
+
 /**
  * Base class for automatic movement of the starview camera
  */
diff --git a/engines/titanic/star_control/fmatrix.cpp b/engines/titanic/star_control/fmatrix.cpp
index cd59c55..050d89b 100644
--- a/engines/titanic/star_control/fmatrix.cpp
+++ b/engines/titanic/star_control/fmatrix.cpp
@@ -22,6 +22,7 @@
 
 #include "titanic/star_control/fmatrix.h"
 #include "titanic/star_control/daffine.h"
+#include "titanic/support/simple_file.h"
 
 namespace Titanic {
 
@@ -39,7 +40,7 @@ void matProd(const FMatrix &a, const FMatrix &m, FMatrix &C) {
 	C._row3._z = a._row3._x * m._row1._z + a._row3._y * m._row2._z + a._row3._z * m._row3._z;
 }
 
-// member functions
+// Member functions
 
 FMatrix::FMatrix() :
 	_row1(1.0, 0.0, 0.0), _row2(0.0, 1.0, 0.0), _row3(0.0, 0.0, 1.0) {
diff --git a/engines/titanic/star_control/fmatrix.h b/engines/titanic/star_control/fmatrix.h
index 00054ee..6d118a7 100644
--- a/engines/titanic/star_control/fmatrix.h
+++ b/engines/titanic/star_control/fmatrix.h
@@ -23,13 +23,13 @@
 #ifndef TITANIC_FMATRIX_H
 #define TITANIC_FMATRIX_H
 
-#include "titanic/support/simple_file.h"
 #include "titanic/star_control/fvector.h"
 
 namespace Titanic {
 
 class DAffine;
 class DVector;
+class SimpleFile;
 
 /**
  * Floating point matrix class.
diff --git a/engines/titanic/star_control/marked_auto_mover.cpp b/engines/titanic/star_control/marked_auto_mover.cpp
index 828fe03..e3ab2b4 100644
--- a/engines/titanic/star_control/marked_auto_mover.cpp
+++ b/engines/titanic/star_control/marked_auto_mover.cpp
@@ -21,6 +21,8 @@
  */
 
 #include "titanic/star_control/marked_auto_mover.h"
+#include "titanic/star_control/error_code.h"
+#include "common/array.h"
 #include "common/textconsole.h"
 
 namespace Titanic {
diff --git a/engines/titanic/star_control/marked_camera_mover.cpp b/engines/titanic/star_control/marked_camera_mover.cpp
index 2e3fa8f..61b7c05 100644
--- a/engines/titanic/star_control/marked_camera_mover.cpp
+++ b/engines/titanic/star_control/marked_camera_mover.cpp
@@ -21,6 +21,7 @@
  */
 
 #include "titanic/star_control/marked_camera_mover.h"
+#include "common/array.h"
 #include "common/textconsole.h"
 
 namespace Titanic {
diff --git a/engines/titanic/star_control/star_camera.cpp b/engines/titanic/star_control/star_camera.cpp
index 76302d2..37196b2 100644
--- a/engines/titanic/star_control/star_camera.cpp
+++ b/engines/titanic/star_control/star_camera.cpp
@@ -21,10 +21,14 @@
  */
 
 #include "titanic/star_control/star_camera.h"
-#include "titanic/star_control/unmarked_camera_mover.h"
-#include "titanic/star_control/marked_camera_mover.h"
+#include "titanic/star_control/camera_mover.h"
 #include "titanic/star_control/daffine.h"
 #include "titanic/star_control/fmatrix.h"
+#include "titanic/star_control/fpoint.h"
+#include "titanic/star_control/marked_camera_mover.h"
+#include "titanic/star_control/unmarked_camera_mover.h"
+#include "titanic/star_control/error_code.h"
+#include "titanic/support/simple_file.h"
 #include "titanic/titanic.h"
 
 namespace Titanic {
@@ -53,6 +57,10 @@ void CStarCamera::deinit() {
 	_newOrientation = nullptr;
 }
 
+bool CStarCamera::isLocked() { 
+       return _mover->isLocked(); 
+}
+
 CStarCamera::~CStarCamera() {
 	deleteHandler();
 }
diff --git a/engines/titanic/star_control/star_camera.h b/engines/titanic/star_control/star_camera.h
index 3cdea2a..856ef40 100644
--- a/engines/titanic/star_control/star_camera.h
+++ b/engines/titanic/star_control/star_camera.h
@@ -23,16 +23,18 @@
 #ifndef TITANIC_STAR_CAMERA_H
 #define TITANIC_STAR_CAMERA_H
 
-#include "titanic/support/simple_file.h"
 #include "titanic/star_control/fmatrix.h"
-#include "titanic/star_control/fpoint.h"
 #include "titanic/star_control/base_stars.h"
 #include "titanic/star_control/viewport.h"
-#include "titanic/star_control/camera_mover.h"
-#include "titanic/star_control/error_code.h"
 
 namespace Titanic {
 
+class CCameraMover;
+class CErrorCode;
+class CNavigationInfo;
+class FPoint;
+class SimpleFile;
+
 enum StarLockState { ZERO_LOCKED=0, ONE_LOCKED=1, TWO_LOCKED=2, THREE_LOCKED=3 };
 
 /**
@@ -62,7 +64,7 @@ private:
 	/**
 	 * Return whether the handler is locked
 	 */
-	bool isLocked() { return _mover->isLocked(); }
+	bool isLocked();
 public:
 	static void init();
 	static void deinit();
diff --git a/engines/titanic/star_control/star_control.cpp b/engines/titanic/star_control/star_control.cpp
index 92cedc9..743cfd0 100644
--- a/engines/titanic/star_control/star_control.cpp
+++ b/engines/titanic/star_control/star_control.cpp
@@ -20,17 +20,18 @@
  *
  */
 
-#include "titanic/support/screen_manager.h"
-#include "titanic/pet_control/pet_control.h"
 #include "titanic/star_control/star_control.h"
 #include "titanic/star_control/daffine.h"
-#include "titanic/star_control/error_code.h"
 #include "titanic/star_control/fpose.h"
+#include "titanic/star_control/camera_mover.h"
 #include "titanic/star_control/star_camera.h"
-#include "titanic/game_manager.h"
+#include "titanic/star_control/error_code.h"
 #include "titanic/core/dont_save_file_item.h"
 #include "titanic/core/project_item.h"
 #include "titanic/core/view_item.h"
+#include "titanic/pet_control/pet_control.h"
+#include "titanic/support/screen_manager.h"
+#include "titanic/game_manager.h"
 
 namespace Titanic {
 
diff --git a/engines/titanic/star_control/star_view.cpp b/engines/titanic/star_control/star_view.cpp
index 9b27fa4..8e3da44 100644
--- a/engines/titanic/star_control/star_view.cpp
+++ b/engines/titanic/star_control/star_view.cpp
@@ -20,13 +20,16 @@
  *
  */
 
-#include "titanic/support/screen_manager.h"
 #include "titanic/star_control/star_view.h"
+#include "titanic/star_control/camera_mover.h"
+#include "titanic/star_control/fvector.h"
 #include "titanic/star_control/star_control.h"
 #include "titanic/star_control/star_field.h"
+#include "titanic/star_control/error_code.h"
+#include "titanic/support/screen_manager.h"
+#include "titanic/support/simple_file.h"
 #include "titanic/core/game_object.h"
 #include "titanic/messages/pet_messages.h"
-#include "titanic/titanic.h"
 
 namespace Titanic {
 
diff --git a/engines/titanic/star_control/star_view.h b/engines/titanic/star_control/star_view.h
index 204c023..b7d5096 100644
--- a/engines/titanic/star_control/star_view.h
+++ b/engines/titanic/star_control/star_view.h
@@ -23,18 +23,17 @@
 #ifndef TITANIC_STAR_VIEW_H
 #define TITANIC_STAR_VIEW_H
 
-#include "titanic/support/simple_file.h"
-#include "titanic/support/video_surface.h"
 #include "titanic/star_control/star_camera.h"
 #include "titanic/star_control/viewport.h"
 #include "titanic/star_control/surface_fader.h"
-#include "titanic/star_control/error_code.h"
-#include "titanic/star_control/fvector.h"
 
 namespace Titanic {
 
+class CErrorCode;
 class CStarControl;
 class CStarField;
+class CVideoSurface;
+class FVector;
 
 class CStarView {
 private:
diff --git a/engines/titanic/star_control/unmarked_auto_mover.cpp b/engines/titanic/star_control/unmarked_auto_mover.cpp
index 4f38f68..5e74692 100644
--- a/engines/titanic/star_control/unmarked_auto_mover.cpp
+++ b/engines/titanic/star_control/unmarked_auto_mover.cpp
@@ -21,6 +21,8 @@
  */
 
 #include "titanic/star_control/unmarked_auto_mover.h"
+#include "titanic/star_control/error_code.h"
+#include "common/array.h"
 #include "common/textconsole.h"
 
 namespace Titanic {
diff --git a/engines/titanic/star_control/unmarked_camera_mover.cpp b/engines/titanic/star_control/unmarked_camera_mover.cpp
index c92ed2b..ce42b39 100644
--- a/engines/titanic/star_control/unmarked_camera_mover.cpp
+++ b/engines/titanic/star_control/unmarked_camera_mover.cpp
@@ -21,10 +21,11 @@
  */
 
 #include "titanic/star_control/unmarked_camera_mover.h"
-#include "titanic/star_control/daffine.h"
 #include "titanic/star_control/dvector.h"
-#include "titanic/titanic.h"
+#include "titanic/star_control/daffine.h"
+#include "titanic/star_control/error_code.h"
 #include "common/textconsole.h"
+#include "titanic/titanic.h"
 
 namespace Titanic {
 


Commit: b200317306370e25fb9cb0b3fbefbb5c7b538773
    https://github.com/scummvm/scummvm/commit/b200317306370e25fb9cb0b3fbefbb5c7b538773
Author: David Fioramonti (dafioram at gmail.com)
Date: 2017-08-18T18:56:12-07:00

Commit Message:
TITANIC: Renamed functions that adds/removes stars/markers

Before it was add/remove row so the new name is more informative.

Changed paths:
    engines/titanic/star_control/base_stars.cpp
    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/base_stars.cpp b/engines/titanic/star_control/base_stars.cpp
index ba48770..c22260e 100644
--- a/engines/titanic/star_control/base_stars.cpp
+++ b/engines/titanic/star_control/base_stars.cpp
@@ -561,7 +561,7 @@ int CBaseStars::baseFn2(CSurfaceArea *surfaceArea, CStarCamera *camera) {
 /*------------------------------------------------------------------------*/
 
 void CStarVector::apply() {
-	_owner->adDAffineRow(_vector);
+	_owner->addLockedStar(_vector);
 }
 
 } // End of namespace Titanic
diff --git a/engines/titanic/star_control/star_camera.cpp b/engines/titanic/star_control/star_camera.cpp
index 37196b2..c74a1d9 100644
--- a/engines/titanic/star_control/star_camera.cpp
+++ b/engines/titanic/star_control/star_camera.cpp
@@ -362,7 +362,7 @@ void CStarCamera::setViewportAngle(const FPoint &angles) {
        }
 }
 
-bool CStarCamera::adDAffineRow(const FVector v) {
+bool CStarCamera::addLockedStar(const FVector v) {
 	if (_star_lock_state == THREE_LOCKED)
 		return false;
 
@@ -376,7 +376,7 @@ bool CStarCamera::adDAffineRow(const FVector v) {
 	return true;
 }
 
-bool CStarCamera::removeMatrixRow() {
+bool CStarCamera::removeLockedStar() {
 	if (_star_lock_state == ZERO_LOCKED)
 		return false;
 
diff --git a/engines/titanic/star_control/star_camera.h b/engines/titanic/star_control/star_camera.h
index 856ef40..9de7860 100644
--- a/engines/titanic/star_control/star_camera.h
+++ b/engines/titanic/star_control/star_camera.h
@@ -165,13 +165,18 @@ public:
 	virtual StarLockState getStarLockState() const { return _star_lock_state; }
 
 	/**
-	 * Adds the row for a locked in marker
+	 * Adds the row for a locked in marker/star
 	 * @remarks		This can't be a pass-by-reference, since adding
 	 * the vector for the star destroys the calling star vector
 	 */
-	virtual bool adDAffineRow(const FVector v);
+	virtual bool addLockedStar(const FVector v);
 
-	virtual bool removeMatrixRow();
+	/**
+	 * Removes the most recent locked in marker/star
+	 * @remarks		This can't be a pass-by-reference, since adding
+	 * the vector for the star destroys the calling star vector
+	 */
+	virtual bool removeLockedStar();
 	virtual void proc36(double *v1, double *v2, double *v3, double *v4);
 
 	/**
diff --git a/engines/titanic/star_control/star_view.cpp b/engines/titanic/star_control/star_view.cpp
index 8e3da44..578cc00 100644
--- a/engines/titanic/star_control/star_view.cpp
+++ b/engines/titanic/star_control/star_view.cpp
@@ -430,7 +430,7 @@ void CStarView::lockStar() {
 
 void CStarView::unlockStar() {
 	if (_starField && !_showingPhoto) {
-		_camera.removeMatrixRow();
+		_camera.removeLockedStar();
 		_starField->fn8(_photoSurface);
 	}
 }


Commit: 82d0053f8bd472ec598645550825257ddd78d683
    https://github.com/scummvm/scummvm/commit/82d0053f8bd472ec598645550825257ddd78d683
Author: David Fioramonti (dafioram at gmail.com)
Date: 2017-08-18T20:28:16-07:00

Commit Message:
TITANIC: Add logic to prevent removing locked/marked stars via skymap

If you want to remove locked stars you can do so using the D key,
but previously, you could also deselect a currently locked star
via the skymap and it would crash.

It previously crashed if:

1. You had 2 stars locked on and you tried to remove the 1st
2. Had 1 locked and 1 unlocked and you tried to unlock the 1st
3. Had 2 locked and 1 unlocked and you tried to unlock any of
the other two locked stars.

Refactoring would allow quicker comprehension of the logic of
this section of code.

Fixes #10126.

Changed paths:
    engines/titanic/star_control/star_crosshairs.cpp


diff --git a/engines/titanic/star_control/star_crosshairs.cpp b/engines/titanic/star_control/star_crosshairs.cpp
index 7227a18..61d11bf 100644
--- a/engines/titanic/star_control/star_crosshairs.cpp
+++ b/engines/titanic/star_control/star_crosshairs.cpp
@@ -39,9 +39,15 @@ void CStarCrosshairs::selectStar(int index, CVideoSurface *surface,
 			// All the stars selected so far have been matched. Only allow
 			// a selection addition if not all three stars have been found
 			if (!isSolved()) {
-				// Don't allow the most recent match to be re-selected
+				// Don't allow the most recent match or the one before
+                            // it to be re-selected (while they are locked/matched)
 				if (_positions[index] != _entries[_entryIndex]) {
-					surface->lock();
+					if (_entryIndex == 1) {//2 stars are matched
+                                          if (_positions[index] == _entries[_entryIndex-1]) {
+                                                 return;
+                                          }
+                                   }
+                                   surface->lock();
 
 					// Draw crosshairs around the selected star
 					CSurfaceArea surfaceArea(surface);
@@ -63,6 +69,7 @@ void CStarCrosshairs::selectStar(int index, CVideoSurface *surface,
 			// So we allow the user to reselect it to remove the selection, or shift
 			// the selection to some other star
 			if (_positions[index] == _entries[_entryIndex]) {
+                            // Player has selected the most recent star
 				// Remove the crosshairs for the previously selected star
 				surface->lock();
 				CSurfaceArea surfaceArea(surface);
@@ -76,6 +83,16 @@ void CStarCrosshairs::selectStar(int index, CVideoSurface *surface,
 				const CBaseStarEntry *starP = starField->getDataPtr(_positions[index]._index1);
 				markers->addStar(starP);
 			} else {
+                            // Player has selected some other star other than the most recent
+                            // Remove/Add it if it is not one of the other star(s) already matched
+
+                            // Check that it is not a previously star and don't remove it if it is
+                            for (int i=0;i<_entryIndex;i++) {
+                                   if (_positions[index] == _entries[i]) {
+                                          return;
+                                   }
+                            }
+                            
 				// Erase the prior selection and draw the new one
 				surface->lock();
 				CSurfaceArea surfaceArea(surface);


Commit: 24bec379d5f1d59dfac2ff304b8ccbc64f5ae5b2
    https://github.com/scummvm/scummvm/commit/24bec379d5f1d59dfac2ff304b8ccbc64f5ae5b2
Author: David Fioramonti (dafioram at gmail.com)
Date: 2017-08-19T08:36:02-07:00

Commit Message:
TITANIC: Pull assert out of dvector/fvector normalization

Before the normalization function was asserting if it couldn't
normalize now the caller can determine what to do with a failed
normalization.

Changed paths:
    engines/titanic/star_control/camera_auto_mover.cpp
    engines/titanic/star_control/dvector.cpp
    engines/titanic/star_control/dvector.h
    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/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 861248f..bcb94d2 100644
--- a/engines/titanic/star_control/camera_auto_mover.cpp
+++ b/engines/titanic/star_control/camera_auto_mover.cpp
@@ -49,8 +49,12 @@ void CCameraAutoMover::proc2(const FVector &oldPos, const FVector &newPos,
 	_srcPos = oldPos;
 	_destPos = newPos;
 	_posDelta = _destPos - _srcPos;
-	_distance = _posDelta.normalize();
-
+       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);
+       }
+       _distance = temp;
 	_active = false;
 	_field34 = false;
 	_transitionPercent = 1.0;
@@ -73,8 +77,12 @@ void CCameraAutoMover::setPath(const FVector &srcV, const FVector &destV, const
 	_srcPos = srcV;
 	_destPos = destV;
 	_posDelta = _destPos - _srcPos;
-	_distance = _posDelta.normalize();
-
+       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);
+       }
+       _distance = temp;
 	_active = false;
 	_field34 = false;
 	_field40 = -1;
diff --git a/engines/titanic/star_control/dvector.cpp b/engines/titanic/star_control/dvector.cpp
index c7481a2..405af4a 100644
--- a/engines/titanic/star_control/dvector.cpp
+++ b/engines/titanic/star_control/dvector.cpp
@@ -26,14 +26,16 @@
 
 namespace Titanic {
 
-double DVector::normalize() {
-	double hyp = sqrt(_x * _x + _y * _y + _z * _z);
-	assert(hyp);
+bool DVector::normalize(double & hyp) {
+	hyp = sqrt(_x * _x + _y * _y + _z * _z);
+	if (hyp==0) {
+              return false;
+       }
 
 	_x *= 1.0 / hyp;
 	_y *= 1.0 / hyp;
 	_z *= 1.0 / hyp;
-	return hyp;
+	return true;
 }
 
 double DVector::getDistance(const DVector &src) {
@@ -73,7 +75,11 @@ void DVector::rotVectAxisY(double angleDeg) {
 DVector DVector::getAnglesAsVect() const {
 	DVector vector = *this;
 	DVector dest;
-	dest._x = vector.normalize(); // scale that makes this vector have magnitude=1, also does the scaling
+
+       if (!vector.normalize(dest._x)) {  // Makes this vector have magnitude=1, put the scale amount in dest._x,
+                                          // but if it is unsuccessful, crash
+              assert(dest._x);
+       }
 	dest._y = acos(vector._y);    // radian distance/angle that this vector's y component is from the +y axis,
                                       // result is restricted to [0,pi]
 	dest._z = atan2(vector._x,vector._z); // result is restricted to [-pi,pi]
diff --git a/engines/titanic/star_control/dvector.h b/engines/titanic/star_control/dvector.h
index bff271d..f115abd 100644
--- a/engines/titanic/star_control/dvector.h
+++ b/engines/titanic/star_control/dvector.h
@@ -44,7 +44,16 @@ public:
 	DVector(double x, double y, double z) : _x(x), _y(y), _z(z) {}
 	DVector(const FVector &v) : _x(v._x), _y(v._y), _z(v._z) {}
 
-	double normalize();
+	/**
+	 * Attempts to normalizes the vector so the length from origin equals 1.0
+        * Return value is whether or not it was successful in normalizing
+        * First argument is scale value that normalizes the vector
+        * TODO: split this function into 2. One that calculates the normalization
+        * and another that does the normalization. The 2nd would assert if a 
+        * normalization of one was requested. This is cleaner than the current 
+        * implementation.
+	 */
+	bool normalize(double &);
 
 	/**
 	 * Returns the distance between this vector and the passed one
diff --git a/engines/titanic/star_control/fmatrix.cpp b/engines/titanic/star_control/fmatrix.cpp
index 050d89b..470569c 100644
--- a/engines/titanic/star_control/fmatrix.cpp
+++ b/engines/titanic/star_control/fmatrix.cpp
@@ -127,10 +127,18 @@ void FMatrix::set(const FVector &v) {
 	_row2 = _row3.fn1();
 
 	_row1 = _row3.crossProduct(_row2);
-	_row1.normalize();
+
+       float unused_scale=0.0;
+       if (!_row1.normalize(unused_scale)) {  // Do the normalization, put the scale amount in unused_scale,
+                                              // but if it is unsuccessful, crash
+              assert(unused_scale);
+       }
 
 	_row2 = _row3.crossProduct(_row1);
-	_row2.normalize();
+       if (!_row2.normalize(unused_scale)) {  // Do the normalization, put the scale amount in unused_scale,
+                                              // but if it is unsuccessful, crash
+              assert(unused_scale);
+       }
 }
 
 void FMatrix::matRProd(const FMatrix &m) {
diff --git a/engines/titanic/star_control/fvector.cpp b/engines/titanic/star_control/fvector.cpp
index a107ad1..75d3074 100644
--- a/engines/titanic/star_control/fvector.cpp
+++ b/engines/titanic/star_control/fvector.cpp
@@ -48,20 +48,25 @@ FVector FVector::crossProduct(const FVector &src) const {
 	);
 }
 
-float FVector::normalize() {
-	float hyp = sqrt(_x * _x + _y * _y + _z * _z);
-	assert(hyp);
+bool FVector::normalize(float & hyp) {
+	hyp = sqrt(_x * _x + _y * _y + _z * _z);
+	if (hyp==0) {
+              return false;
+       }
 
 	_x *= 1.0 / hyp;
 	_y *= 1.0 / hyp;
 	_z *= 1.0 / hyp;
-	return hyp;
+	return true;
 }
 
 FVector FVector::addAndNormalize(const FVector &v) const {
 	FVector tempV(_x + v._x, _y + v._y, _z + v._z);
-	tempV.normalize();
-
+       float unused_scale=0.0;
+       if (!tempV.normalize(unused_scale)) {  // Do the normalization, put the scale amount in unused_scale,
+                                              // but if it is unsuccessful, crash
+              assert(unused_scale);
+       }
 	return tempV;
 }
 
diff --git a/engines/titanic/star_control/fvector.h b/engines/titanic/star_control/fvector.h
index fa24fe5..f93ac60 100644
--- a/engines/titanic/star_control/fvector.h
+++ b/engines/titanic/star_control/fvector.h
@@ -59,9 +59,15 @@ public:
 	FVector crossProduct(const FVector &src) const;
 
 	/**
-	 * Normalizes the vector so the length from origin equals 1.0
+	 * Attempts to normalizes the vector so the length from origin equals 1.0
+        * Return value is whether or not it was successful in normalizing
+        * First argument is scale value that normalizes the vector
+        * TODO: split this function into 2. One that calculates the normalization
+        * and another that does the normalization. The 2nd would assert if a 
+        * normalization of one was requested. This is cleaner than the current 
+        * implementation.
 	 */
-	float normalize();
+	bool normalize(float &);
 
 	/**
 	 * Adds the current vector and a passed one together, normalizes them,
diff --git a/engines/titanic/star_control/star_camera.cpp b/engines/titanic/star_control/star_camera.cpp
index c74a1d9..1d543b3 100644
--- a/engines/titanic/star_control/star_camera.cpp
+++ b/engines/titanic/star_control/star_camera.cpp
@@ -276,9 +276,14 @@ void CStarCamera::setViewportAngle(const FPoint &angles) {
 		tempV4 -= tempV1;
 		tempV5 -= tempV1;
 		tempV6 -= tempV1;
-		tempV4.normalize();
-		tempV5.normalize();
-		tempV6.normalize();
+
+              float unused_scale=0.0;
+              if (!tempV4.normalize(unused_scale) ||
+                  !tempV5.normalize(unused_scale) ||
+                  !tempV6.normalize(unused_scale)) {  // Do the normalization, put the scale amount in unused_scale,
+                                                      // but if it is unsuccessful, crash
+                     assert(unused_scale);
+              }
 
 		tempV1 += row1;
 		m1.set(tempV4, tempV5, tempV6);
@@ -345,9 +350,15 @@ void CStarCamera::setViewportAngle(const FPoint &angles) {
 		mrow1 -= tempV3;
 		mrow2 -= tempV3;
 		mrow3 -= tempV3;
-		mrow1.normalize();
-		mrow2.normalize();
-		mrow3.normalize();
+
+              double unused_scale=0.0;
+              if (!mrow1.normalize(unused_scale) ||
+                  !mrow2.normalize(unused_scale) ||
+                  !mrow3.normalize(unused_scale)) {  // Do the normalization, put the scale amount in unused_scale,
+                                                     // but if it is unsuccessful, crash
+                     assert(unused_scale);
+              }
+
 		tempV16 = tempV3;
 
 		m3.set(mrow1, mrow2, mrow3);
@@ -459,8 +470,12 @@ void CStarCamera::lockMarker1(FVector v1, FVector v2, FVector v3) {
 	tempV._x = val9 - _viewport._valArray[2];
 	tempV._y = val8;
 
-	v3.normalize();
-	tempV.normalize();
+       float unused_scale=0.0;
+       if (!v3.normalize(unused_scale) ||
+        !tempV.normalize(unused_scale)) {  // Do the normalization, put the scale amount in unused_scale,
+                                           // but if it is unsuccessful, crash
+              assert(unused_scale);
+       }
 
 	FMatrix matrix = _viewport.getOrientation();
 	const FVector &pos = _viewport._position;
@@ -548,9 +563,15 @@ void CStarCamera::lockMarker2(CViewport *viewport, const FVector &v) {
 	m4._col2 -= m4._col1;
 	m4._col4 -= m4._col1;
 
-	m4._col3.normalize();
-	m4._col2.normalize();
-	m4._col4.normalize();
+       double unused_scale=0.0;
+       if (!m4._col2.normalize(unused_scale) ||
+           !m4._col3.normalize(unused_scale) ||
+           !m4._col4.normalize(unused_scale) ) {  // Do the normalizations, put the scale amount in unused_scale,
+                                                  // but if any of the normalizations are unsuccessful,
+                                                  // crash
+              assert(unused_scale);
+       }
+       
 	m5.set(m4._col3, m4._col2, m4._col4);
 
 	FVector newPos = m4._col1;
diff --git a/engines/titanic/star_control/unmarked_auto_mover.cpp b/engines/titanic/star_control/unmarked_auto_mover.cpp
index 5e74692..71063fa 100644
--- a/engines/titanic/star_control/unmarked_auto_mover.cpp
+++ b/engines/titanic/star_control/unmarked_auto_mover.cpp
@@ -98,7 +98,12 @@ int CUnmarkedAutoMover::proc5(CErrorCode &errorCode, FVector &pos, FMatrix &orie
 
 	v2 = orientation._row3;
 	v3 = _destPos - pos;
-	v3.normalize();
+
+       float unused_scale=0.0;
+       if (!v3.normalize(unused_scale)) {  // Do the normalization, put the scale amount in unused_scale,
+                                           // but if it is unsuccessful, crash
+              assert(unused_scale);
+       }
 
 	double val = orientation._row3._x * v3._x + orientation._row3._y * v3._y + orientation._row3._z * v3._z;
 	bool flag = false;


Commit: 312d63c3c951ed3781c4f7a1577b62cb862042b3
    https://github.com/scummvm/scummvm/commit/312d63c3c951ed3781c4f7a1577b62cb862042b3
Author: David Fioramonti (dafioram at gmail.com)
Date: 2017-08-19T08:36:02-07:00

Commit Message:
TITANIC: Prevent moving for locking stars when onto of star

Originally, if you unlocked a star when you had 2 or 3 stars
locked and then relocked without changing views then the game
crashed.

This was because it was trying to transition a distance of zero
and this failed an assert (to normalize the length to be the distance).
The transition is no longer done so the crash does not happen.

Fixes #10147.

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


diff --git a/engines/titanic/star_control/star_camera.cpp b/engines/titanic/star_control/star_camera.cpp
index 1d543b3..924ffaf 100644
--- a/engines/titanic/star_control/star_camera.cpp
+++ b/engines/titanic/star_control/star_camera.cpp
@@ -563,21 +563,24 @@ void CStarCamera::lockMarker2(CViewport *viewport, const FVector &v) {
 	m4._col2 -= m4._col1;
 	m4._col4 -= m4._col1;
 
+       FMatrix m6 = _viewport.getOrientation();
+
        double unused_scale=0.0;
        if (!m4._col2.normalize(unused_scale) ||
            !m4._col3.normalize(unused_scale) ||
            !m4._col4.normalize(unused_scale) ) {  // Do the normalizations, put the scale amount in unused_scale,
-                                                  // but if any of the normalizations are unsuccessful,
-                                                  // crash
+                                                  // but if any of the normalizations are unsuccessful, crash
               assert(unused_scale);
        }
        
 	m5.set(m4._col3, m4._col2, m4._col4);
 
 	FVector newPos = m4._col1;
-	FMatrix m6 = _viewport.getOrientation();
-	_mover->proc8(_viewport._position, newPos, m6, m5);
-
+	
+       if (_viewport._position != newPos) {
+              // Only change view if positions are different
+	       _mover->proc8(_viewport._position, newPos, m6, m5);
+       }
 	CStarVector *sv = new CStarVector(this, v);
 	_mover->setVector(sv);
 }
@@ -591,7 +594,11 @@ void CStarCamera::lockMarker3(CViewport *viewport, const FVector &v) {
 	FVector newPos = viewport->_position;
 	FVector oldPos = _viewport._position;
 
-	_mover->proc8(oldPos, newPos, oldOr, newOr);
+       if (oldPos != newPos) {
+              // Only change view if positions are different
+	       _mover->proc8(oldPos, newPos, oldOr, newOr);
+       }
+
 	CStarVector *sv = new CStarVector(this, v);
 	_mover->setVector(sv);
 }


Commit: a32a29a80e8dfc44c5da8a2f872914710a4009ae
    https://github.com/scummvm/scummvm/commit/a32a29a80e8dfc44c5da8a2f872914710a4009ae
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2017-08-20T14:31:47-04:00

Commit Message:
Merge pull request #995 from dafioram/star_camera_work

TITANIC: CStarCamera Refactoring and CStarCrosshairs logic fix

Changed paths:
    engines/titanic/star_control/base_stars.cpp
    engines/titanic/star_control/base_stars.h
    engines/titanic/star_control/camera_auto_mover.cpp
    engines/titanic/star_control/camera_auto_mover.h
    engines/titanic/star_control/dvector.cpp
    engines/titanic/star_control/dvector.h
    engines/titanic/star_control/fmatrix.cpp
    engines/titanic/star_control/fmatrix.h
    engines/titanic/star_control/fvector.cpp
    engines/titanic/star_control/fvector.h
    engines/titanic/star_control/marked_auto_mover.cpp
    engines/titanic/star_control/marked_camera_mover.cpp
    engines/titanic/star_control/star_camera.cpp
    engines/titanic/star_control/star_camera.h
    engines/titanic/star_control/star_control.cpp
    engines/titanic/star_control/star_crosshairs.cpp
    engines/titanic/star_control/star_view.cpp
    engines/titanic/star_control/star_view.h
    engines/titanic/star_control/unmarked_auto_mover.cpp
    engines/titanic/star_control/unmarked_camera_mover.cpp







More information about the Scummvm-git-logs mailing list