Skip to content
Permalink
Browse files

TITANIC: Implemented CStarControlSub12 matrix row handling

  • Loading branch information
dreammaster committed Mar 21, 2017
1 parent 0aaa6c4 commit a0330c1aab4edc2ea20619ad251877419efaf201
@@ -217,7 +217,7 @@ int CBaseStar::baseFn2(CSurfaceArea *surfaceArea, CStarControlSub12 *sub12) {
/*------------------------------------------------------------------------*/

void CStarVector::proc1() {
_owner->setArrayVector(_vector);
_owner->addMatrixRow(_vector);
}

} // End of namespace Titanic
@@ -97,6 +97,15 @@ class FMatrix {
bool operator!=(const FMatrix &src) {
return !operator==(src);
}

/**
* Allows accessing rows as an array
*/
FVector &operator[](int idx) {
assert(idx >= 0 && idx <= 2);
FVector *rows[3] = { &_row1, &_row2, &_row3 };
return *rows[idx];
}
};

} // End of namespace Titanic
@@ -32,12 +32,12 @@ FMatrix *CStarControlSub12::_matrix1;
FMatrix *CStarControlSub12::_matrix2;

CStarControlSub12::CStarControlSub12(const CStar20Data *data) :
_currentIndex(-1), _handlerP(nullptr), _field108(0) {
_matrixRow(-1), _handlerP(nullptr), _field108(0) {
setupHandler(data);
}

CStarControlSub12::CStarControlSub12(CStarControlSub13 *src) :
_currentIndex(-1), _handlerP(nullptr), _field108(0), _sub13(src) {
_matrixRow(-1), _handlerP(nullptr), _field108(0), _sub13(src) {
}

void CStarControlSub12::init() {
@@ -221,13 +221,13 @@ void CStarControlSub12::setViewportPosition(const FPoint &angles) {
if (isLocked())
return;

if (_currentIndex == -1) {
if (_matrixRow == -1) {
CStarControlSub6 subX(X_AXIS, angles._x);
CStarControlSub6 subY(Y_AXIS, angles._y);
CStarControlSub6 sub(&subX, &subY);
subY.copyFrom(&sub);
proc22(subY);
} else if (_currentIndex == 0) {
} else if (_matrixRow == 0) {
FVector row1 = _matrix._row1;
CStarControlSub6 subX(X_AXIS, angles._x);
CStarControlSub6 subY(Y_AXIS, angles._y);
@@ -311,7 +311,7 @@ void CStarControlSub12::setViewportPosition(const FPoint &angles) {
m1.set(tempV4, tempV5, tempV6);
_sub13.setMatrix(m1);
_sub13.setPosition(tempV1);
} else if (_currentIndex == 1) {
} else if (_matrixRow == 1) {
FVector tempV2;
DMatrix m1, m2, sub;
DVector mrow1, mrow2, mrow3;
@@ -390,18 +390,29 @@ void CStarControlSub12::setViewportPosition(const FPoint &angles) {
}
}

bool CStarControlSub12::setArrayVector(const FVector &v) {
if (_currentIndex >= 2)
bool CStarControlSub12::addMatrixRow(const FVector &v) {
if (_matrixRow >= 2)
return false;

error("TODO: CStarControlSub12::setArrayVector");
CStar20Data data;
_handlerP->copyTo(&data);
deleteHandler();

FVector &row = _matrix[++_matrixRow];
row = v;
setupHandler(&data);
}

bool CStarControlSub12::proc35() {
if (_currentIndex == -1)
bool CStarControlSub12::removeMatrixRow() {
if (_matrixRow == -1)
return false;

error("TODO: CStarControlSub12::proc35");
CStar20Data data;
_handlerP->copyTo(&data);
deleteHandler();

--_matrixRow;
setupHandler(&data);
}

void CStarControlSub12::proc36(double *v1, double *v2, double *v3, double *v4) {
@@ -419,7 +430,7 @@ void CStarControlSub12::save(SimpleFile *file, int indent) {
bool CStarControlSub12::setupHandler(const CStar20Data *src) {
CStarControlSub20 *handler = nullptr;

switch (_currentIndex) {
switch (_matrixRow) {
case -1:
handler = new CStarControlSub21(src);
break;
@@ -456,7 +467,7 @@ void CStarControlSub12::fn1(CStarControlSub13 *sub13, const FVector &v) {
}

void CStarControlSub12::fn2(FVector v1, FVector v2, FVector v3) {
if (_currentIndex == -1) {
if (_matrixRow == -1) {
FVector tempV;
tempV._z = _sub13._field10;
v3._z = v1._z;
@@ -38,7 +38,7 @@ class CStarControlSub12 {
static FMatrix *_matrix1;
static FMatrix *_matrix2;
private:
int _currentIndex;
int _matrixRow;
FMatrix _matrix;
CStarControlSub20 *_handlerP;
CStarControlSub13 _sub13;
@@ -102,9 +102,9 @@ class CStarControlSub12 {
*/
virtual void setViewportPosition(const FPoint &angles);

virtual int getCurrentIndex() const { return _currentIndex; }
virtual bool setArrayVector(const FVector &v);
virtual bool proc35();
virtual int getMatrixRow() const { return _matrixRow; }
virtual bool addMatrixRow(const FVector &v);
virtual bool removeMatrixRow();
virtual void proc36(double *v1, double *v2, double *v3, double *v4);

/**
@@ -409,7 +409,7 @@ void CStarView::fn16() {

void CStarView::fn17() {
if (_starField && !_showingPhoto) {
_sub12.proc35();
_sub12.removeMatrixRow();
_starField->fn8(_videoSurface2);
}
}

0 comments on commit a0330c1

Please sign in to comment.
You can’t perform that action at this time.