aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Gilbert2017-06-01 21:19:49 -0400
committerPaul Gilbert2017-06-01 21:19:49 -0400
commit10ada8b23b4b1b5050e94eca5818280ecc506a9a (patch)
treeeda0a84406b1e910b91af5bf87a0cdfa06fa4e65
parent03ba3e41f9d840130d531ffee35735835bf7d9cb (diff)
downloadscummvm-rg350-10ada8b23b4b1b5050e94eca5818280ecc506a9a.tar.gz
scummvm-rg350-10ada8b23b4b1b5050e94eca5818280ecc506a9a.tar.bz2
scummvm-rg350-10ada8b23b4b1b5050e94eca5818280ecc506a9a.zip
TITANIC: Fix some calculation errors when locking markers
-rw-r--r--engines/titanic/star_control/star_control.cpp2
-rw-r--r--engines/titanic/star_control/star_field.cpp8
-rw-r--r--engines/titanic/star_control/star_field.h7
-rw-r--r--engines/titanic/star_control/star_view.cpp10
4 files changed, 17 insertions, 10 deletions
diff --git a/engines/titanic/star_control/star_control.cpp b/engines/titanic/star_control/star_control.cpp
index d9737bc2f6..3a0eeae02b 100644
--- a/engines/titanic/star_control/star_control.cpp
+++ b/engines/titanic/star_control/star_control.cpp
@@ -262,7 +262,7 @@ bool CStarControl::isSolved() const {
void CStarControl::forceSolved() {
while (!_starField.isSolved())
- _starField.fn7();
+ _starField.incMatches();
}
bool CStarControl::canSetStarDestination() const {
diff --git a/engines/titanic/star_control/star_field.cpp b/engines/titanic/star_control/star_field.cpp
index 1cfc57631b..6d8661f246 100644
--- a/engines/titanic/star_control/star_field.cpp
+++ b/engines/titanic/star_control/star_field.cpp
@@ -203,11 +203,13 @@ double CStarField::fn5(CSurfaceArea *surfaceArea, CStarCamera *camera,
double incr = (v1._x - pt._x) * (v1._x - pt._x);
if (incr > 3600.0)
return -1.0;
- if ((v1._y - pt._y) * (v1._y - pt._y) + incr > 3600.0)
+
+ incr += (v1._y - pt._y) * (v1._y - pt._y);
+ if (incr > 3600.0)
return -1.0;
_closeToMarker = true;
- return v1._y - pt._y;
+ return incr;
}
void CStarField::fn6(CVideoSurface *surface, CStarCamera *camera) {
@@ -215,7 +217,7 @@ void CStarField::fn6(CVideoSurface *surface, CStarCamera *camera) {
_crosshairs.fn1(this, &surfaceArea, camera);
}
-void CStarField::fn7() {
+void CStarField::incMatches() {
_crosshairs.incMatches();
setSolved();
}
diff --git a/engines/titanic/star_control/star_field.h b/engines/titanic/star_control/star_field.h
index 12af83a6a8..e367cfe9ba 100644
--- a/engines/titanic/star_control/star_field.h
+++ b/engines/titanic/star_control/star_field.h
@@ -130,7 +130,12 @@ public:
double fn5(CSurfaceArea *surfaceArea, CStarCamera *camera,
FVector &v1, FVector &v2, FVector &v3);
void fn6(CVideoSurface *surface, CStarCamera *camera);
- void fn7();
+
+ /**
+ * Increments the number of matched markers
+ */
+ void incMatches();
+
void fn8(CVideoSurface *surface);
void fn9() { _starCloseup.fn1(); }
diff --git a/engines/titanic/star_control/star_view.cpp b/engines/titanic/star_control/star_view.cpp
index 12945b9b5a..77724698e0 100644
--- a/engines/titanic/star_control/star_view.cpp
+++ b/engines/titanic/star_control/star_view.cpp
@@ -382,26 +382,26 @@ void CStarView::lockStar() {
double val = _starField->fn5(&surfaceArea, &_camera, v1, v2, v3);
if (val > -1.0) {
- v1 += surfaceArea._centroid;
- v3 += surfaceArea._centroid;
+ v1 -= surfaceArea._centroid;
+ v3 -= surfaceArea._centroid;
switch (_starField->getMatchedIndex()) {
case -1:
// First star match
_camera.fn2(v1, v2, v3);
- _starField->fn7();
+ _starField->incMatches();
break;
case 0:
// Second star match
_camera.fn3(&_photoViewport, v2);
- _starField->fn7();
+ _starField->incMatches();
break;
case 1:
// Third star match
_camera.fn1(&_photoViewport, v2);
- _starField->fn7();
+ _starField->incMatches();
break;
default: