Skip to content

Commit

Permalink
TITANIC: Implemented CStarControlSub2 class
Browse files Browse the repository at this point in the history
  • Loading branch information
dreammaster committed Mar 14, 2017
1 parent 9ba330c commit 2edbc73
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 20 deletions.
9 changes: 6 additions & 3 deletions engines/titanic/star_control/base_star.cpp
Expand Up @@ -201,14 +201,17 @@ void CBaseStar::draw4(CSurfaceArea *surfaceArea, CStarControlSub12 *sub12, CStar
// TODO
}

void CBaseStar::baseFn1(CSurfaceArea *surfaceArea, CStarControlSub12 *sub12,
int CBaseStar::baseFn1(CSurfaceArea *surfaceArea, CStarControlSub12 *sub12,
const Common::Point &pt) {
CStarRef1 ref(this, pt);
ref.process(surfaceArea, sub12);
return ref._index;
}

int CBaseStar::baseFn2(CSurfaceArea *surfaceArea, CStarControlSub12 *sub12) {
// TODO
return 0;
CStarRef3 ref(this);
ref.process(surfaceArea, sub12);
return ref._index;
}

} // End of namespace Titanic
4 changes: 2 additions & 2 deletions engines/titanic/star_control/base_star.h
Expand Up @@ -104,7 +104,7 @@ class CBaseStar {
* Selects a star
*/
virtual bool selectStar(CSurfaceArea *surfaceArea, CStarControlSub12 *sub12,
const Common::Point &pt, int flags = 0) { return false; }
const Common::Point &pt, void *handler = nullptr) { return false; }

/**
* Adds a new star, or removes one if already present at the given co-ordinates
Expand Down Expand Up @@ -137,7 +137,7 @@ class CBaseStar {
*/
const CBaseStarEntry *getDataPtr(int index) const;

void baseFn1(CSurfaceArea *surfaceArea, CStarControlSub12 *sub12,
int baseFn1(CSurfaceArea *surfaceArea, CStarControlSub12 *sub12,
const Common::Point &pt);

int baseFn2(CSurfaceArea *surfaceArea, CStarControlSub12 *sub12);
Expand Down
27 changes: 17 additions & 10 deletions engines/titanic/star_control/star_control_sub2.cpp
Expand Up @@ -21,29 +21,36 @@
*/

#include "titanic/star_control/star_control_sub2.h"
#include "titanic/star_control/star_control_sub12.h"

namespace Titanic {

bool CStarControlSub2::setup() {
loadData("STARFIELD/132");
return true;
}

bool CStarControlSub2::loadYale(int v1) {
clear();
error("Original loadYale not supported");
return true;
}

bool CStarControlSub2::selectStar(CSurfaceArea *surfaceArea,
CStarControlSub12 *sub12, const Common::Point &pt, int flags) {
// TODO
return true;
CStarControlSub12 *sub12, const Common::Point &pt, void *handler) {
int index = baseFn1(surfaceArea, sub12, pt);
if (index == -1) {
return false;
} else if (!handler) {
sub12->proc14(_data[index]._position);
return true;
} else {
error("no handler ever passed in original");
}
}

bool CStarControlSub2::loadStar() {
// TODO
return true;
}

bool CStarControlSub2::setup() {
// TODO
return true;
error("loadStar not supported");
}

} // End of namespace Titanic
2 changes: 1 addition & 1 deletion engines/titanic/star_control/star_control_sub2.h
Expand Up @@ -37,7 +37,7 @@ class CStarControlSub2: public CBaseStar {
* Selects a star
*/
virtual bool selectStar(CSurfaceArea *surfaceArea, CStarControlSub12 *sub12,
const Common::Point &pt, int flags = 0);
const Common::Point &pt, void *handler = nullptr);

virtual bool loadStar();

Expand Down
2 changes: 1 addition & 1 deletion engines/titanic/star_control/star_ref.cpp
Expand Up @@ -55,7 +55,7 @@ bool CStarRef2::check(const Common::Point &pt, int index) {
/*------------------------------------------------------------------------*/

bool CStarRef3::check(const Common::Point &pt, int index) {
++_counter;
++_index;
return true;
}

Expand Down
8 changes: 5 additions & 3 deletions engines/titanic/star_control/star_ref.h
Expand Up @@ -46,6 +46,7 @@ class CBaseStarRef {
class CStarRef1 : public CBaseStarRef {
private:
Common::Point _position;
public:
int _index;
public:
CStarRef1(CBaseStar *star, const Common::Point &pt) :
Expand All @@ -58,6 +59,7 @@ class CStarRef1 : public CBaseStarRef {
class CStarRef2 : public CBaseStarRef {
private:
Common::Array<CStarPosition> *_positions;
public:
int _index;
public:
CStarRef2(CBaseStar *star, Common::Array<CStarPosition> *positions) :
Expand All @@ -68,10 +70,10 @@ class CStarRef2 : public CBaseStarRef {
};

class CStarRef3 : public CBaseStarRef {
private:
int _counter;
public:
CStarRef3(CBaseStar *star) :CBaseStarRef(star), _counter(0) {}
int _index;
public:
CStarRef3(CBaseStar *star) :CBaseStarRef(star), _index(0) {}
virtual ~CStarRef3() {}

virtual bool check(const Common::Point &pt, int index);
Expand Down

0 comments on commit 2edbc73

Please sign in to comment.