Skip to content

Commit

Permalink
TITANIC: star camera better handler function naming
Browse files Browse the repository at this point in the history
The functions that dealt with the mover handling only
had handler in the name so I added mover and type to the
name to reflect that it involves the mover handler.
  • Loading branch information
dafioram committed Sep 7, 2017
1 parent d3a0a48 commit 93d9ac9
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 14 deletions.
18 changes: 9 additions & 9 deletions engines/titanic/star_control/star_camera.cpp
Expand Up @@ -41,7 +41,7 @@ FMatrix *CStarCamera::_newOrientation;

CStarCamera::CStarCamera(const CNavigationInfo *data) :
_starLockState(ZERO_LOCKED), _mover(nullptr), _isMoved(false), _isInLockingProcess(false) {
setupHandler(data);
setMoverType(data);
}

CStarCamera::CStarCamera(CViewport *src) :
Expand Down Expand Up @@ -69,7 +69,7 @@ bool CStarCamera::isNotInLockingProcess() {
}

CStarCamera::~CStarCamera() {
deleteHandler();
removeMover();
}

void CStarCamera::proc2(const CViewport *src) {
Expand Down Expand Up @@ -404,12 +404,12 @@ bool CStarCamera::addLockedStar(const FVector v) {

CNavigationInfo data;
_mover->copyTo(&data);
deleteHandler();
removeMover();

FVector &row = _lockedStarsPos[(int)_starLockState];
_starLockState = StarLockState((int)_starLockState + 1);
row = v;
setupHandler(&data);
setMoverType(&data);
return true;
}

Expand All @@ -419,10 +419,10 @@ bool CStarCamera::removeLockedStar() {

CNavigationInfo data;
_mover->copyTo(&data);
deleteHandler();
removeMover();

_starLockState = StarLockState((int)_starLockState - 1);
setupHandler(&data);
setMoverType(&data);
return true;
}

Expand All @@ -438,7 +438,7 @@ void CStarCamera::save(SimpleFile *file, int indent) {
_viewport.save(file, indent);
}

bool CStarCamera::setupHandler(const CNavigationInfo *src) {
bool CStarCamera::setMoverType(const CNavigationInfo *src) {
CCameraMover *mover = nullptr;

switch (_starLockState) {
Expand All @@ -457,15 +457,15 @@ bool CStarCamera::setupHandler(const CNavigationInfo *src) {
}

if (mover) {
assert(!_mover);
assert(!_mover); // removeMover() is usually called before this function so _mover is null
_mover = mover;
return true;
} else {
return false;
}
}

void CStarCamera::deleteHandler() {
void CStarCamera::removeMover() {
if (_mover) {
delete _mover;
_mover = nullptr;
Expand Down
12 changes: 7 additions & 5 deletions engines/titanic/star_control/star_camera.h
Expand Up @@ -47,20 +47,22 @@ class CStarCamera {
private:
StarLockState _starLockState;
FMatrix _lockedStarsPos; // Each row represents the location of a locked star
CCameraMover *_mover;
CCameraMover *_mover; // A marked or unmarked camera mover, contains an automover
CViewport _viewport;
bool _isMoved; // Used in CPetStarfield to determine if a star destination can be set
bool _isInLockingProcess; // The mover/view is homing in on a new star
private:
/**
* Set up a handler
* Set Mover type to be unmarked or marked camera mover based on
* the number of stars currently locked (_starLockState)
* The CNavigationInfo data is used to initialize the mover
*/
bool setupHandler(const CNavigationInfo *src);
bool setMoverType(const CNavigationInfo *src);

/**
* Deletes any previous handler
* Deletes the previous mover handle
*/
void deleteHandler();
void removeMover();

/**
* Return whether the handler is locked
Expand Down

0 comments on commit 93d9ac9

Please sign in to comment.