Skip to content
Permalink
Browse files

TITANIC: Added addStar and other methods

  • Loading branch information
dreammaster committed Mar 9, 2017
1 parent faaaab9 commit 4daf983b2e7aea5516f2a6bc55bf0ac06742e19e
@@ -96,7 +96,11 @@ class CBaseStar {
virtual bool selectStar(CSurfaceArea *surfaceArea, CStarControlSub12 *sub12,
int flags, const Common::Point &pt) { return false; }

virtual bool proc5(int v1) { return false; }
/**
* Adds a new star, or removes one if already present at the given co-ordinates
*/
virtual bool addStar(const CBaseStarEntry *entry) { return false; }

virtual bool loadStar() { return false; }

/**
@@ -108,4 +108,52 @@ void CStarControlSub6::copyFrom(const CStarControlSub6 *src) {
_vector = src->_vector;
}

void CStarControlSub6::setup(CStarControlSub6 *dest, const CStarControlSub6 *s2, const CStarControlSub6 *s3) {
CStarControlSub6 &d = *dest;

d._row1._x = s3->_row1._x * s2->_row1._x
+ s2->_row1._z * s3->_row3._x
+ s2->_row1._y * s3->_row2._x;
d._row1._y = s2->_row1._x * s3->_row1._y
+ s3->_row3._y * s2->_row1._z
+ s3->_row2._y * s2->_row1._y;
d._row1._z = s2->_row1._x * s3->_row1._z
+ s3->_row3._z * s2->_row1._z
+ s3->_row2._z * s2->_row1._y;
d._row2._x = s3->_row1._x * s2->_row2._x
+ s2->_row2._y * s3->_row2._x
+ s2->_row2._z * s3->_row3._x;
d._row2._y = s2->_row2._y * s3->_row2._y
+ s2->_row2._z * s3->_row3._y
+ s3->_row1._y * s2->_row2._x;
d._row2._z = s3->_row1._z * s2->_row2._x
+ s2->_row2._y * s3->_row2._z
+ s2->_row2._z * s3->_row3._z;
d._row3._x = s3->_row1._x * s2->_row3._x
+ s2->_row3._y * s3->_row2._x
+ s2->_row3._z * s3->_row3._x;
d._row3._y = s2->_row3._z * s3->_row3._y
+ s2->_row3._y * s3->_row2._y
+ s3->_row1._y * s2->_row3._x;
d._row3._z = s3->_row3._z * s2->_row3._z
+ s3->_row2._z * s2->_row3._y
+ s3->_row1._z * s2->_row3._x;
d._vector._x = s3->_row1._x * s2->_vector._x
+ s2->_vector._y * s3->_row2._x
+ s2->_vector._z * s3->_row3._x
+ s3->_vector._x;
d._vector._y = s2->_vector._z * s3->_row3._y
+ s2->_vector._y * s3->_row2._y
+ s2->_vector._x * s3->_row1._y
+ s3->_vector._y;
d._vector._z = s2->_vector._y * s3->_row2._z
+ s2->_vector._z * s3->_row3._z
+ s2->_vector._x * s3->_row1._z
+ s3->_vector._z;
}

void CStarControlSub6::fn1(CStarControlSub6 *sub6) {
// TODO
}

} // End of namespace Titanic
@@ -45,12 +45,19 @@ class CStarControlSub6 : public FMatrix {
*/
void clear();

/**
* Sets up a passed instance from the specified two other ones
*/
static void setup(CStarControlSub6 *dest, const CStarControlSub6 *s2, const CStarControlSub6 *s3);

/**
* Sets the default data
*/
void set(int mode, double val);

void copyFrom(const CStarControlSub6 *src);

void fn1(CStarControlSub6 *sub6);
};

} // End of namespace Titanic
@@ -24,12 +24,28 @@

namespace Titanic {

void CStarControlSub7::proc2(int v1, int v2, int v3) {
void CStarControlSub7::draw(CSurfaceArea *surfaceArea, CStarControlSub12 *sub12, CStarControlSub5 *sub5) {
// TODO
}

bool CStarControlSub7::proc5(int v1) {
// TODO
bool CStarControlSub7::addStar(const CBaseStarEntry *entry) {
// iterate through the existing stars
for (uint idx = 0; idx < _data.size(); ++idx) {
CBaseStarEntry &star = _data[idx];
if (star == *entry) {
// Found a matching star at the exact same position, so remove it instead
_data.remove_at(idx);
return;
}
}

// No existing match
if (_data.size() == 32)
// Out of space, so delete oldest star
_data.remove_at(0);

// Add new star
_data.push_back(*entry);
return true;
}

@@ -30,8 +30,15 @@ class CStarControlSub7 : public CBaseStar {
public:
virtual ~CStarControlSub7() { clear(); }

virtual void proc2(int v1, int v2, int v3);
virtual bool proc5(int v1);
/**
* Draw the item
*/
virtual void draw(CSurfaceArea *surfaceArea, CStarControlSub12 *sub12, CStarControlSub5 *sub5);

/**
* Adds a new star, or removes one if already present at the given co-ordinates
*/
virtual bool addStar(const CBaseStarEntry *entry);
};

} // End of namespace Titanic

0 comments on commit 4daf983

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