Skip to content

Commit

Permalink
TITANIC: Camera Auto Mover class cleanup
Browse files Browse the repository at this point in the history
Named some functions, made _speeds be an array instead of
a dynamic one.
  • Loading branch information
dafioram committed Aug 21, 2017
1 parent 04598dd commit 09a7a13
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 9 deletions.
8 changes: 3 additions & 5 deletions engines/titanic/star_control/camera_auto_mover.cpp
Expand Up @@ -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;
Expand Down Expand Up @@ -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];
Expand Down
8 changes: 6 additions & 2 deletions engines/titanic/star_control/camera_auto_mover.h
Expand Up @@ -49,7 +49,7 @@ class CCameraAutoMover {
int _field44;
int _field48;
int _field4C;
Common::Array<double> _speeds;
double _speeds[32];
int _field54;
double _transitionPercent;
double _transitionPercentInc;
Expand All @@ -63,7 +63,11 @@ class CCameraAutoMover {
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; }
};
Expand Down
2 changes: 1 addition & 1 deletion engines/titanic/star_control/marked_auto_mover.cpp
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion engines/titanic/star_control/unmarked_auto_mover.cpp
Expand Up @@ -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;
Expand Down

0 comments on commit 09a7a13

Please sign in to comment.