Skip to content

Commit

Permalink
TITANIC: Fix some calculation errors when locking markers
Browse files Browse the repository at this point in the history
  • Loading branch information
dreammaster committed Jun 2, 2017
1 parent 03ba3e4 commit 10ada8b
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 10 deletions.
2 changes: 1 addition & 1 deletion engines/titanic/star_control/star_control.cpp
Expand Up @@ -262,7 +262,7 @@ bool CStarControl::isSolved() const {

void CStarControl::forceSolved() {
while (!_starField.isSolved())
_starField.fn7();
_starField.incMatches();
}

bool CStarControl::canSetStarDestination() const {
Expand Down
8 changes: 5 additions & 3 deletions engines/titanic/star_control/star_field.cpp
Expand Up @@ -203,19 +203,21 @@ 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) {
CSurfaceArea surfaceArea(surface);
_crosshairs.fn1(this, &surfaceArea, camera);
}

void CStarField::fn7() {
void CStarField::incMatches() {
_crosshairs.incMatches();
setSolved();
}
Expand Down
7 changes: 6 additions & 1 deletion engines/titanic/star_control/star_field.h
Expand Up @@ -130,7 +130,12 @@ class CStarField : public CStarControlSub2 {
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(); }

Expand Down
10 changes: 5 additions & 5 deletions engines/titanic/star_control/star_view.cpp
Expand Up @@ -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:
Expand Down

0 comments on commit 10ada8b

Please sign in to comment.