diff options
-rw-r--r-- | engines/lure/hotspots.cpp | 16 | ||||
-rw-r--r-- | engines/lure/hotspots.h | 108 | ||||
-rw-r--r-- | engines/lure/res_struct.cpp | 52 | ||||
-rw-r--r-- | engines/lure/res_struct.h | 38 |
4 files changed, 101 insertions, 113 deletions
diff --git a/engines/lure/hotspots.cpp b/engines/lure/hotspots.cpp index c7e7e81900..698df8715e 100644 --- a/engines/lure/hotspots.cpp +++ b/engines/lure/hotspots.cpp @@ -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 @@ -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 @@ -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: @@ -4496,7 +4496,7 @@ void PathFinder::initVars() { _countdownCtr -= 700; } -void PathFinder::saveToStream(Common::WriteStream *stream) { +void PathFinder::saveToStream(Common::WriteStream *stream) const { stream->writeByte(_inUse); if (_inUse) { @@ -4504,8 +4504,7 @@ void PathFinder::saveToStream(Common::WriteStream *stream) { 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()); @@ -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(); diff --git a/engines/lure/hotspots.h b/engines/lure/hotspots.h index a58a34456e..85d36dc138 100644 --- a/engines/lure/hotspots.h +++ b/engines/lure/hotspots.h @@ -111,9 +111,9 @@ private: 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}; @@ -158,11 +158,11 @@ public: 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); }; @@ -279,62 +279,62 @@ public: 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; } @@ -342,7 +342,7 @@ public: assert(_data); _data->blockedState = newState; } - bool blockedFlag() { + bool blockedFlag() const { assert(_data); return _data->blockedFlag; } @@ -376,7 +376,7 @@ public: } void setCharRectY(uint16 value) { _charRectY = value; } void setSkipFlag(bool value) { _skipFlag = value; } - CharacterMode characterMode() { + CharacterMode characterMode() const { assert(_data != NULL); return _data->characterMode; } @@ -384,7 +384,7 @@ public: assert(_data != NULL); _data->characterMode = value; } - uint16 delayCtr() { + uint16 delayCtr() const { assert(_data); return _data->delayCtr; } @@ -392,7 +392,7 @@ public: assert(_data); _data->delayCtr = value; } - uint16 pauseCtr() { + uint16 pauseCtr() const { assert(_data); return _data->pauseCtr; } @@ -400,7 +400,7 @@ public: assert(_data); _data->pauseCtr = value; } - VariantBool coveredFlag() { + VariantBool coveredFlag() const { assert(_data); return _data->coveredFlag; } @@ -408,7 +408,7 @@ public: assert(_data); _data->coveredFlag = value; } - uint16 useHotspotId() { + uint16 useHotspotId() const { assert(_data); return _data->useHotspotId; } @@ -416,7 +416,7 @@ public: assert(_data); _data->useHotspotId = value; } - uint16 talkGate() { + uint16 talkGate() const { assert(_data); return _data->talkGate; } @@ -424,7 +424,7 @@ public: assert(_data); _data->talkGate = value; } - uint16 supportValue() { return _supportValue; } + uint16 supportValue() const { return _supportValue; } void setSupportValue(uint16 value) { _supportValue = value; } void copyTo(Surface *dest); @@ -449,16 +449,16 @@ public: void doAction(); void doAction(Action action, HotspotData *hotspot); - CurrentActionStack ¤tActions() { + CurrentActionStack ¤tActions() 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; } @@ -466,7 +466,7 @@ public: assert(_data); _data->actionCtr = v; } - uint8 voiceCtr() { return _voiceCtr; } + uint8 voiceCtr() const { return _voiceCtr; } void setVoiceCtr(uint8 v) { _voiceCtr = v; } // Miscellaneous @@ -477,13 +477,13 @@ public: 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); }; diff --git a/engines/lure/res_struct.cpp b/engines/lure/res_struct.cpp index 222f55b5dc..ded6b5e6fc 100644 --- a/engines/lure/res_struct.cpp +++ b/engines/lure/res_struct.cpp @@ -278,10 +278,8 @@ void RoomPathsData::decompress(RoomPathsDecompressedData &dataOut, int character // Room data class -void RoomDataList::saveToStream(Common::WriteStream *stream) { - RoomDataList::iterator i; - - for (i = begin(); i != end(); ++i) { +void RoomDataList::saveToStream(Common::WriteStream *stream) const { + for (RoomDataList::const_iterator i = begin(); i != end(); ++i) { RoomData *rec = (*i).get(); stream->writeByte(rec->flags); const byte *pathData = rec->paths.data(); @@ -317,8 +315,8 @@ RoomExitJoinData::RoomExitJoinData(RoomExitJoinResource *rec) { blocked = rec->blocked; } -void RoomExitJoinList::saveToStream(Common::WriteStream *stream) { - for (RoomExitJoinList::iterator i = begin(); i != end(); ++i) { +void RoomExitJoinList::saveToStream(Common::WriteStream *stream) const { + for (RoomExitJoinList::const_iterator i = begin(); i != end(); ++i) { RoomExitJoinData *rec = (*i).get(); stream->writeUint16LE(rec->hotspots[0].hotspotId); @@ -435,7 +433,7 @@ HotspotData::HotspotData(HotspotResource *rec) { npcScheduleId = READ_LE_UINT16(&rec->npcSchedule); } -void HotspotData::saveToStream(Common::WriteStream *stream) { +void HotspotData::saveToStream(Common::WriteStream *stream) const { // Write out the basic fields stream->writeUint16LE(nameId); stream->writeUint16LE(descId); @@ -534,9 +532,8 @@ void HotspotData::loadFromStream(Common::ReadStream *stream) { // Hotspot data list -void HotspotDataList::saveToStream(Common::WriteStream *stream) { - iterator i; - for (i = begin(); i != end(); ++i) { +void HotspotDataList::saveToStream(Common::WriteStream *stream) const { + for (const_iterator i = begin(); i != end(); ++i) { HotspotData *hotspot = (*i).get(); stream->writeUint16LE(hotspot->hotspotId); hotspot->saveToStream(stream); @@ -699,13 +696,11 @@ TalkEntryData *TalkData::getResponse(int index) { // The following class acts as a container for all the NPC conversations -void TalkDataList::saveToStream(Common::WriteStream *stream) { - TalkDataList::iterator i; - for (i = begin(); i != end(); ++i) { +void TalkDataList::saveToStream(Common::WriteStream *stream) const { + for (TalkDataList::const_iterator i = begin(); i != end(); ++i) { TalkData *rec = (*i).get(); - TalkEntryList::iterator i2; - for (i2 = rec->entries.begin(); i2 != rec->entries.end(); ++i2) { + for (TalkEntryList::const_iterator i2 = rec->entries.begin(); i2 != rec->entries.end(); ++i2) { TalkEntryData *entry = (*i2).get(); stream->writeUint16LE(entry->descId); } @@ -716,9 +711,8 @@ void TalkDataList::loadFromStream(Common::ReadStream *stream) { TalkDataList::iterator i; for (i = begin(); i != end(); ++i) { TalkData *rec = (*i).get(); - TalkEntryList::iterator i2; - for (i2 = rec->entries.begin(); i2 != rec->entries.end(); ++i2) { + for (TalkEntryList::const_iterator i2 = rec->entries.begin(); i2 != rec->entries.end(); ++i2) { TalkEntryData *entry = (*i2).get(); entry->descId = stream->readUint16LE(); } @@ -812,10 +806,8 @@ void SequenceDelayList::clear(bool forceClear) { } } -void SequenceDelayList::saveToStream(Common::WriteStream *stream) { - SequenceDelayList::iterator i; - - for (i = begin(); i != end(); ++i) { +void SequenceDelayList::saveToStream(Common::WriteStream *stream) const { + for (SequenceDelayList::const_iterator i = begin(); i != end(); ++i) { SequenceDelayData *entry = (*i).get(); stream->writeUint16LE(entry->sequenceOffset); stream->writeUint32LE(entry->timeoutCtr); @@ -1016,7 +1008,7 @@ RandomActionSet *RandomActionList::getRoom(uint16 roomNumber) { return NULL; } -void RandomActionSet::saveToStream(Common::WriteStream *stream) { +void RandomActionSet::saveToStream(Common::WriteStream *stream) const { stream->writeByte(numActions()); for (int actionIndex = 0; actionIndex < _numActions; ++actionIndex) stream->writeByte((byte)_types[actionIndex]); @@ -1030,8 +1022,8 @@ void RandomActionSet::loadFromStream(Common::ReadStream *stream) { } -void RandomActionList::saveToStream(Common::WriteStream *stream) { - for (iterator i = begin(); i != end(); ++i) +void RandomActionList::saveToStream(Common::WriteStream *stream) const { + for (const_iterator i = begin(); i != end(); ++i) (*i)->saveToStream(stream); } @@ -1196,7 +1188,7 @@ BarEntry &BarmanLists::getDetails(uint16 roomNumber) { error("Invalid room %d specified for barman details retrieval", roomNumber); } -void BarmanLists::saveToStream(Common::WriteStream *stream) { +void BarmanLists::saveToStream(Common::WriteStream *stream) const { for (int index = 0; index < 3; ++index) { uint16 value = (_barList[index].currentCustomer == NULL) ? 0 : (_barList[index].currentCustomer - &_barList[index].customers[0]) / sizeof(BarEntry) + 1; @@ -1296,7 +1288,7 @@ void ValueTableData::setField(FieldName fieldName, uint16 value) { setField((uint16) fieldName, value); } -void ValueTableData::saveToStream(Common::WriteStream *stream) { +void ValueTableData::saveToStream(Common::WriteStream *stream) const { // Write out the special fields stream->writeUint16LE(_numGroats); stream->writeSint16LE(_playerNewPos.position.x); @@ -1371,7 +1363,7 @@ void CurrentActionEntry::setSupportData(uint16 entryId) { setSupportData(newEntry); } -void CurrentActionEntry::saveToStream(Common::WriteStream *stream) { +void CurrentActionEntry::saveToStream(Common::WriteStream *stream) const { debugC(ERROR_DETAILED, kLureDebugAnimations, "Saving hotspot action entry dyn=%d id=%d", hasSupportData(), hasSupportData() ? supportData().id() : 0); stream->writeByte((uint8) _action); @@ -1466,14 +1458,12 @@ Common::String CurrentActionStack::getDebugInfo() const { return buffer; } -void CurrentActionStack::saveToStream(Common::WriteStream *stream) { - ActionsList::iterator i; - +void CurrentActionStack::saveToStream(Common::WriteStream *stream) const { debugC(ERROR_DETAILED, kLureDebugAnimations, "Saving hotspot action stack"); Common::String buffer = getDebugInfo(); debugC(ERROR_DETAILED, kLureDebugAnimations, "%s", buffer.c_str()); - for (i = _actions.begin(); i != _actions.end(); ++i) { + for (ActionsList::const_iterator i = _actions.begin(); i != _actions.end(); ++i) { CurrentActionEntry *rec = (*i).get(); rec->saveToStream(stream); } diff --git a/engines/lure/res_struct.h b/engines/lure/res_struct.h index 8d6c557297..a4d2f76cec 100644 --- a/engines/lure/res_struct.h +++ b/engines/lure/res_struct.h @@ -300,7 +300,7 @@ public: void load(byte *srcData) { memcpy(_data, srcData, ROOM_PATHS_SIZE); } - const byte *data() { return _data; } + const byte *data() const { return _data; } bool isOccupied(int x, int y); bool isOccupied(int x, int y, int width); void setOccupied(int x, int y, int width); @@ -334,7 +334,7 @@ public: class RoomDataList: public Common::List<Common::SharedPtr<RoomData> > { public: - void saveToStream(Common::WriteStream *stream); + void saveToStream(Common::WriteStream *stream) const; void loadFromStream(Common::ReadStream *stream); }; @@ -357,7 +357,7 @@ public: class RoomExitJoinList: public Common::List<Common::SharedPtr<RoomExitJoinData> > { public: - void saveToStream(Common::WriteStream *stream); + void saveToStream(Common::WriteStream *stream) const; void loadFromStream(Common::ReadStream *stream); }; @@ -433,13 +433,13 @@ public: if (_dynamicSupportData) delete _supportData; } - CurrentAction action() { return _action; } - CharacterScheduleEntry &supportData() { + CurrentAction action() const { return _action; } + CharacterScheduleEntry &supportData() const { if (!_supportData) error("Access made to non-defined action support record"); return *_supportData; } - bool hasSupportData() { return _supportData != NULL; } - uint16 roomNumber() { return _roomNumber; } + bool hasSupportData() const { return _supportData != NULL; } + uint16 roomNumber() const { return _roomNumber; } void setAction(CurrentAction newAction) { _action = newAction; } void setRoomNumber(uint16 roomNum) { _roomNumber = roomNum; } void setSupportData(CharacterScheduleEntry *newRec) { @@ -452,7 +452,7 @@ public: } void setSupportData(uint16 entryId); - void saveToStream(Common::WriteStream *stream); + void saveToStream(Common::WriteStream *stream) const; static CurrentActionEntry *loadFromStream(Common::ReadStream *stream); }; @@ -505,7 +505,7 @@ public: validateStack(); } - void saveToStream(Common::WriteStream *stream); + void saveToStream(Common::WriteStream *stream) const; void loadFromStream(Common::ReadStream *stream); void copyFrom(CurrentActionStack &stack); }; @@ -569,13 +569,13 @@ public: void enable() { flags |= 0x80; } void disable() { flags &= 0x7F; } Direction nonVisualDirection() { return (Direction) scriptLoadFlag; } - void saveToStream(Common::WriteStream *stream); + void saveToStream(Common::WriteStream *stream) const; void loadFromStream(Common::ReadStream *stream); }; class HotspotDataList: public Common::List<Common::SharedPtr<HotspotData> > { public: - void saveToStream(Common::WriteStream *stream); + void saveToStream(Common::WriteStream *stream) const; void loadFromStream(Common::ReadStream *stream); }; @@ -663,7 +663,7 @@ public: class TalkDataList: public Common::List<Common::SharedPtr<TalkData> > { public: - void saveToStream(Common::WriteStream *stream); + void saveToStream(Common::WriteStream *stream) const; void loadFromStream(Common::ReadStream *stream); }; @@ -722,7 +722,7 @@ public: void tick(); void clear(bool forceClear = false); - void saveToStream(Common::WriteStream *stream); + void saveToStream(Common::WriteStream *stream) const; void loadFromStream(Common::ReadStream *stream); }; @@ -760,8 +760,8 @@ public: RandomActionSet(uint16 *&offset); ~RandomActionSet(); - uint16 roomNumber() { return _roomNumber; } - int numActions() { return _numActions; } + uint16 roomNumber() const { return _roomNumber; } + int numActions() const { return _numActions; } void getEntry(int index, RandomActionType &actionType, uint16 &id) { assert((index >= 0) && (index < _numActions)); actionType = _types[index]; @@ -772,14 +772,14 @@ public: assert(_types[index] == REPEAT_ONCE); _types[index] = REPEAT_ONCE_DONE; } - void saveToStream(Common::WriteStream *stream); + void saveToStream(Common::WriteStream *stream) const; void loadFromStream(Common::ReadStream *stream); }; class RandomActionList: public Common::List<Common::SharedPtr<RandomActionSet> > { public: RandomActionSet *getRoom(uint16 roomNumber); - void saveToStream(Common::WriteStream *stream); + void saveToStream(Common::WriteStream *stream) const; void loadFromStream(Common::ReadStream *stream); }; @@ -828,7 +828,7 @@ public: void reset(); BarEntry &getDetails(uint16 roomNumber); - void saveToStream(Common::WriteStream *stream); + void saveToStream(Common::WriteStream *stream) const; void loadFromStream(Common::ReadStream *stream); }; @@ -923,7 +923,7 @@ public: uint8 &hdrFlagMask() { return _hdrFlagMask; } PlayerNewPosition &playerNewPos() { return _playerNewPos; } - void saveToStream(Common::WriteStream *stream); + void saveToStream(Common::WriteStream *stream) const; void loadFromStream(Common::ReadStream *stream); }; |