Skip to content

Commit

Permalink
JANITORIAL: Make getters const.
Browse files Browse the repository at this point in the history
  • Loading branch information
chmallon authored and fuzzie committed Mar 13, 2012
1 parent d21cef4 commit 337d5da
Show file tree
Hide file tree
Showing 4 changed files with 101 additions and 113 deletions.
16 changes: 7 additions & 9 deletions engines/lure/hotspots.cpp
Expand Up @@ -430,7 +430,7 @@ bool Hotspot::isActiveAnimation() {
return ((_numFrames != 0) && (_layer != 0));
}

uint16 Hotspot::nameId() {
uint16 Hotspot::nameId() const {
if (_data == NULL)
return 0;
else
Expand Down Expand Up @@ -2286,7 +2286,7 @@ void Hotspot::startTalk(HotspotData *charHotspot, uint16 id) {
charHotspot->hotspotId, id);
}

void Hotspot::saveToStream(Common::WriteStream *stream) {
void Hotspot::saveToStream(Common::WriteStream *stream) const {
if (_data)
_data->npcSchedule.saveToStream(stream);
else
Expand Down Expand Up @@ -4113,7 +4113,7 @@ void HotspotTickHandlers::npcRoomChange(Hotspot &h) {

// This method performs rounding of the number of steps depending on direciton

int WalkingActionEntry::numSteps() {
int WalkingActionEntry::numSteps() const {
switch (_direction) {
case UP:
case DOWN:
Expand Down Expand Up @@ -4496,16 +4496,15 @@ void PathFinder::initVars() {
_countdownCtr -= 700;
}

void PathFinder::saveToStream(Common::WriteStream *stream) {
void PathFinder::saveToStream(Common::WriteStream *stream) const {
stream->writeByte(_inUse);

if (_inUse) {
// Save the path finding plane
stream->write(_layer, sizeof(RoomPathsDecompressedData));

// Save any active step sequence
WalkingActionList::iterator i;
for (i = _list.begin(); i != _list.end(); ++i) {
for (WalkingActionList::const_iterator i = _list.begin(); i != _list.end(); ++i) {
WalkingActionEntry *entry = (*i).get();
stream->writeByte(entry->direction());
stream->writeSint16LE(entry->rawSteps());
Expand Down Expand Up @@ -4683,9 +4682,8 @@ bool Support::isCharacterInList(uint16 *lst, int numEntries, uint16 charId) {
return false;
}

void HotspotList::saveToStream(Common::WriteStream *stream) {
HotspotList::iterator i;
for (i = begin(); i != end(); ++i) {
void HotspotList::saveToStream(Common::WriteStream *stream) const {
for (HotspotList::const_iterator i = begin(); i != end(); ++i) {
Hotspot *hotspot = (*i).get();
debugC(ERROR_INTERMEDIATE, kLureDebugAnimations, "Saving hotspot %xh", hotspot->hotspotId());
bool dynamicObject = hotspot->hotspotId() != hotspot->originalId();
Expand Down
108 changes: 54 additions & 54 deletions engines/lure/hotspots.h
Expand Up @@ -111,9 +111,9 @@ class WalkingActionEntry {
int _numSteps;
public:
WalkingActionEntry(Direction dir, int steps): _direction(dir), _numSteps(steps) {}
Direction direction() { return _direction; }
Direction direction() const { return _direction; }
int &rawSteps() { return _numSteps; }
int numSteps();
int numSteps() const;
};

enum PathFinderResult {PF_UNFINISHED, PF_OK, PF_DEST_OCCUPIED, PF_PART_PATH, PF_NO_WALK};
Expand Down Expand Up @@ -158,11 +158,11 @@ class PathFinder {
Common::String getDebugInfo() const;

void pop() { _list.erase(_list.begin()); }
WalkingActionEntry &top() { return **_list.begin(); }
bool isEmpty() { return _list.empty(); }
WalkingActionEntry &top() const { return **_list.begin(); }
bool isEmpty() const { return _list.empty(); }
int &stepCtr() { return _stepCtr; }

void saveToStream(Common::WriteStream *stream);
void saveToStream(Common::WriteStream *stream) const;
void loadFromStream(Common::ReadStream *stream);
};

Expand Down Expand Up @@ -279,70 +279,70 @@ class Hotspot {
void setAnimation(uint16 newAnimId);
void setAnimationIndex(int animIndex);
void setAnimation(HotspotAnimData *newRecord);
uint16 hotspotId() { return _hotspotId; }
uint16 originalId() { return _originalId; }
Surface &frames() { return *_frames; }
HotspotAnimData &anim() { return *_anim; }
HotspotData *resource() { return _data; }
uint16 numFrames() { return _numFrames; }
uint16 frameNumber() { return _frameNumber; }
uint16 hotspotId() const { return _hotspotId; }
uint16 originalId() const { return _originalId; }
Surface &frames() const { return *_frames; }
HotspotAnimData &anim() const { return *_anim; }
HotspotData *resource() const { return _data; }
uint16 numFrames() const { return _numFrames; }
uint16 frameNumber() const { return _frameNumber; }
void setFrameNumber(uint16 frameNum) {
assert(frameNum < _numFrames);
_frameNumber = frameNum;
}
void incFrameNumber();
Direction direction() { return _direction; }
uint16 frameWidth() { return _width; }
int16 x() { return _startX; }
int16 y() { return _startY; }
int16 destX() { return _destX; }
int16 destY() { return _destY; }
int8 talkX() { return _talkX; }
int8 talkY() { return _talkY; }
uint16 destHotspotId() { return _destHotspotId; }
uint16 blockedOffset() { return _blockedOffset; }
uint8 exitCtr() { return _exitCtr; }
bool walkFlag() { return _walkFlag; }
uint16 startRoomNumber() { return _startRoomNumber; }
uint16 width() { return _width; }
uint16 height() { return _height; }
uint16 widthCopy() { return _widthCopy; }
uint16 heightCopy() { return _heightCopy; }
uint16 yCorrection() { return _yCorrection; }
uint16 charRectY() { return _charRectY; }
uint16 roomNumber() { return _roomNumber; }
uint16 talkScript() {
Direction direction() const { return _direction; }
uint16 frameWidth() const { return _width; }
int16 x() const { return _startX; }
int16 y() const { return _startY; }
int16 destX() const { return _destX; }
int16 destY() const { return _destY; }
int8 talkX() const { return _talkX; }
int8 talkY() const { return _talkY; }
uint16 destHotspotId() const { return _destHotspotId; }
uint16 blockedOffset() const { return _blockedOffset; }
uint8 exitCtr() const { return _exitCtr; }
bool walkFlag() const { return _walkFlag; }
uint16 startRoomNumber() const { return _startRoomNumber; }
uint16 width() const { return _width; }
uint16 height() const { return _height; }
uint16 widthCopy() const { return _widthCopy; }
uint16 heightCopy() const { return _heightCopy; }
uint16 yCorrection() const { return _yCorrection; }
uint16 charRectY() const { return _charRectY; }
uint16 roomNumber() const { return _roomNumber; }
uint16 talkScript() const {
assert(_data);
return _data->talkScriptOffset;
}
uint16 hotspotScript() { return _hotspotScriptOffset; }
uint8 layer() { return _layer; }
bool skipFlag() { return _skipFlag; }
uint16 hotspotScript() const { return _hotspotScriptOffset; }
uint8 layer() const { return _layer; }
bool skipFlag() const { return _skipFlag; }
void setTickProc(uint16 newVal);
bool persistant() { return _persistant; }
bool persistant() const { return _persistant; }
void setPersistant(bool value) { _persistant = value; }
uint8 colorOffset() { return _colorOffset; }
uint8 colorOffset() const { return _colorOffset; }
void setColorOffset(uint8 value) { _colorOffset = value; }
void setRoomNumber(uint16 roomNum) {
_roomNumber = roomNum;
if (_data) _data->roomNumber = roomNum;
}
uint16 nameId();
uint16 nameId() const;
const char *getName();
bool isActiveAnimation();
void setPosition(int16 newX, int16 newY);
void setDestPosition(int16 newX, int16 newY) { _destX = newX; _destY = newY; }
void setDestHotspot(uint16 id) { _destHotspotId = id; }
void setExitCtr(uint8 value) { _exitCtr = value; }
BlockedState blockedState() {
BlockedState blockedState() const {
assert(_data);
return _data->blockedState;
}
void setBlockedState(BlockedState newState) {
assert(_data);
_data->blockedState = newState;
}
bool blockedFlag() {
bool blockedFlag() const {
assert(_data);
return _data->blockedFlag;
}
Expand Down Expand Up @@ -376,55 +376,55 @@ class Hotspot {
}
void setCharRectY(uint16 value) { _charRectY = value; }
void setSkipFlag(bool value) { _skipFlag = value; }
CharacterMode characterMode() {
CharacterMode characterMode() const {
assert(_data != NULL);
return _data->characterMode;
}
void setCharacterMode(CharacterMode value) {
assert(_data != NULL);
_data->characterMode = value;
}
uint16 delayCtr() {
uint16 delayCtr() const {
assert(_data);
return _data->delayCtr;
}
void setDelayCtr(uint16 value) {
assert(_data);
_data->delayCtr = value;
}
uint16 pauseCtr() {
uint16 pauseCtr() const {
assert(_data);
return _data->pauseCtr;
}
void setPauseCtr(uint16 value) {
assert(_data);
_data->pauseCtr = value;
}
VariantBool coveredFlag() {
VariantBool coveredFlag() const {
assert(_data);
return _data->coveredFlag;
}
void setCoveredFlag(VariantBool value) {
assert(_data);
_data->coveredFlag = value;
}
uint16 useHotspotId() {
uint16 useHotspotId() const {
assert(_data);
return _data->useHotspotId;
}
void setUseHotspotId(uint16 value) {
assert(_data);
_data->useHotspotId = value;
}
uint16 talkGate() {
uint16 talkGate() const {
assert(_data);
return _data->talkGate;
}
void setTalkGate(uint16 value) {
assert(_data);
_data->talkGate = value;
}
uint16 supportValue() { return _supportValue; }
uint16 supportValue() const { return _supportValue; }
void setSupportValue(uint16 value) { _supportValue = value; }

void copyTo(Surface *dest);
Expand All @@ -449,24 +449,24 @@ class Hotspot {

void doAction();
void doAction(Action action, HotspotData *hotspot);
CurrentActionStack &currentActions() {
CurrentActionStack &currentActions() const {
assert(_data);
return _data->npcSchedule;
}
PathFinder &pathFinder() { return _pathFinder; }
DestStructure &tempDest() { return _tempDest; }
uint16 frameCtr() { return _frameCtr; }
uint16 frameCtr() const { return _frameCtr; }
void setFrameCtr(uint16 value) { _frameCtr = value; }
void decrFrameCtr() { if (_frameCtr > 0) --_frameCtr; }
uint8 actionCtr() {
uint8 actionCtr() const {
assert(_data);
return _data->actionCtr;
}
void setActionCtr(uint8 v) {
assert(_data);
_data->actionCtr = v;
}
uint8 voiceCtr() { return _voiceCtr; }
uint8 voiceCtr() const { return _voiceCtr; }
void setVoiceCtr(uint8 v) { _voiceCtr = v; }

// Miscellaneous
Expand All @@ -477,13 +477,13 @@ class Hotspot {
void scheduleConverse(uint16 destHotspot, uint16 messageId);
void handleTalkDialog();

void saveToStream(Common::WriteStream *stream);
void saveToStream(Common::WriteStream *stream) const;
void loadFromStream(Common::ReadStream *stream);
};

class HotspotList: public Common::List<Common::SharedPtr<Hotspot> > {
public:
void saveToStream(Common::WriteStream *stream);
void saveToStream(Common::WriteStream *stream) const;
void loadFromStream(Common::ReadStream *stream);
};

Expand Down

0 comments on commit 337d5da

Please sign in to comment.