From 9a7cd6b367e08b2926cdbf9f42c4b457897520ea Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Thu, 23 Mar 2017 21:09:30 -0400 Subject: TITANIC: Finished CStarControlSub27 class --- .../titanic/star_control/star_control_sub27.cpp | 54 +++++++++++++++++++++- engines/titanic/star_control/star_control_sub27.h | 4 +- 2 files changed, 55 insertions(+), 3 deletions(-) (limited to 'engines') diff --git a/engines/titanic/star_control/star_control_sub27.cpp b/engines/titanic/star_control/star_control_sub27.cpp index e9559b250b..98c237c7fd 100644 --- a/engines/titanic/star_control/star_control_sub27.cpp +++ b/engines/titanic/star_control/star_control_sub27.cpp @@ -50,8 +50,58 @@ void CStarControlSub27::proc2(FVector &v1, FVector &v2, FMatrix &m1, FMatrix &m2 } int CStarControlSub27::proc5(CErrorCode &errorCode, FVector &v, FMatrix &m) { - // TODO - return 0; + if (!_field8) + return 0; + + _field58 += _field60; + _field58 = _field58; + _sub25.fn2(_field58, m); + errorCode.set(); + + if (_field40 >= 0) { + double powVal = _powers[_field40]; + v += _row3 * powVal; + fn1(v); + + --_field40; + errorCode.set(); + return 1; + } else if (_field44 > 0) { + v += _row3 * _field38; + fn1(v); + + --_field44; + errorCode.set(); + return 1; + } else if (_field48 >= 0) { + double powVal = _powers[31 - _field48]; + v += _row3 * powVal; + fn1(v); + + --_field48; + errorCode.set(); + return 1; + } else { + _field8 = 0; + return 2; + } +} + +void CStarControlSub27::fn1(FVector &v) const { + double distance = _row1.getDistance(v); + distance /= _field24; + + if (distance <= 0.0) { + v = _row1; + } else if (distance >= 1.0) { + v = _row2; + } else { + v = FVector( + (_row2._x - _row1._x) * distance + _row1._x, + (_row2._y - _row1._y) * distance + _row1._y, + (_row2._z - _row1._z) * distance + _row1._z + ); + } } } // End of namespace Titanic diff --git a/engines/titanic/star_control/star_control_sub27.h b/engines/titanic/star_control/star_control_sub27.h index f8aa3d6ce7..ff4136c1c5 100644 --- a/engines/titanic/star_control/star_control_sub27.h +++ b/engines/titanic/star_control/star_control_sub27.h @@ -28,7 +28,9 @@ namespace Titanic { class CStarControlSub27 : public CStarControlSub23 { -public: +private: + void fn1(FVector &v) const; +public: virtual ~CStarControlSub27() {} virtual void proc2(FVector &v1, FVector &v2, FMatrix &m1, FMatrix &m2); -- cgit v1.2.3