diff options
Diffstat (limited to 'engines/lure')
-rw-r--r-- | engines/lure/debugger.cpp | 42 | ||||
-rw-r--r-- | engines/lure/game.cpp | 8 | ||||
-rw-r--r-- | engines/lure/hotspots.cpp | 373 | ||||
-rw-r--r-- | engines/lure/hotspots.h | 108 | ||||
-rw-r--r-- | engines/lure/menu.cpp | 109 | ||||
-rw-r--r-- | engines/lure/res.cpp | 20 | ||||
-rw-r--r-- | engines/lure/res_struct.cpp | 202 | ||||
-rw-r--r-- | engines/lure/res_struct.h | 38 | ||||
-rw-r--r-- | engines/lure/room.cpp | 40 | ||||
-rw-r--r-- | engines/lure/sound.cpp | 57 | ||||
-rw-r--r-- | engines/lure/surface.cpp | 32 |
11 files changed, 510 insertions, 519 deletions
diff --git a/engines/lure/debugger.cpp b/engines/lure/debugger.cpp index ef4a22f73a..3fbbf84469 100644 --- a/engines/lure/debugger.cpp +++ b/engines/lure/debugger.cpp @@ -119,21 +119,21 @@ bool Debugger::cmd_listRooms(int argc, const char **argv) { DebugPrintf("Available rooms are:\n"); for (RoomDataList::iterator i = rooms.begin(); i != rooms.end(); ++i) { - RoomData *room = (*i).get(); + RoomData const &room = **i; // Explictly note the second drawbridge room as "Alt" - if (room->roomNumber == 49) { + if (room.roomNumber == 49) { strings.getString(47, buffer); strcat(buffer, " (alt)"); } else { - strings.getString(room->roomNumber, buffer); + strings.getString(room.roomNumber, buffer); } - DebugPrintf("#%d - %s", room->roomNumber, buffer); + DebugPrintf("#%d - %s", room.roomNumber, buffer); if (++ctr % 3 == 0) DebugPrintf("\n"); else { // Write out spaces between columns - int numSpaces = 25 - strlen(buffer) - ((room->roomNumber >= 10) ? 2 : 1); + int numSpaces = 25 - strlen(buffer) - (room.roomNumber >= 10 ? 2 : 1); char *s = buffer; while (numSpaces-- > 0) *s++ = ' '; *s = '\0'; @@ -243,13 +243,13 @@ bool Debugger::cmd_hotspots(int argc, const char **argv) { // Loop for displaying active hotspots HotspotList::iterator i; for (i = res.activeHotspots().begin(); i != res.activeHotspots().end(); ++i) { - Hotspot *hotspot = (*i).get(); + Hotspot const &hotspot = **i; - if (hotspot->nameId() == 0) strcpy(buffer, "none"); - else strings.getString(hotspot->nameId(), buffer); + if (hotspot.nameId() == 0) strcpy(buffer, "none"); + else strings.getString(hotspot.nameId(), buffer); - DebugPrintf("%4xh - %s pos=(%d,%d,%d)\n", hotspot->hotspotId(), buffer, - hotspot->x(), hotspot->y(), hotspot->roomNumber()); + DebugPrintf("%4xh - %s pos=(%d,%d,%d)\n", hotspot.hotspotId(), buffer, + hotspot.x(), hotspot.y(), hotspot.roomNumber()); } } else { // Presume it's a room's hotspots @@ -257,14 +257,14 @@ bool Debugger::cmd_hotspots(int argc, const char **argv) { HotspotDataList::iterator i; for (i = res.hotspotData().begin(); i != res.hotspotData().end(); ++i) { - HotspotData *hotspot = (*i).get(); + HotspotData const &hotspot = **i; - if (hotspot->roomNumber == roomNumber) { - if (hotspot->nameId == 0) strcpy(buffer, "none"); - else strings.getString(hotspot->nameId, buffer); + if (hotspot.roomNumber == roomNumber) { + if (hotspot.nameId == 0) strcpy(buffer, "none"); + else strings.getString(hotspot.nameId, buffer); - DebugPrintf("%4xh - %s pos=(%d,%d,%d)\n", hotspot->hotspotId, buffer, - hotspot->startX, hotspot->startY, hotspot->roomNumber); + DebugPrintf("%4xh - %s pos=(%d,%d,%d)\n", hotspot.hotspotId, buffer, + hotspot.startX, hotspot.startY, hotspot.roomNumber); } } } @@ -415,10 +415,10 @@ bool Debugger::cmd_room(int argc, const char **argv) { else { RoomExitHotspotList::iterator i; for (i = exits.begin(); i != exits.end(); ++i) { - RoomExitHotspotData *rec = (*i).get(); + RoomExitHotspotData const &rec = **i; DebugPrintf("\nArea - (%d,%d)-(%d,%d) Room=%d Cursor=%d Hotspot=%xh", - rec->xs, rec->ys, rec->xe, rec->ye, rec->destRoomNumber, rec->cursorNum, rec->hotspotId); + rec.xs, rec.ys, rec.xe, rec.ye, rec.destRoomNumber, rec.cursorNum, rec.hotspotId); } DebugPrintf("\n"); @@ -430,11 +430,11 @@ bool Debugger::cmd_room(int argc, const char **argv) { else { RoomExitList::iterator i2; for (i2 = room->exits.begin(); i2 != room->exits.end(); ++i2) { - RoomExitData *rec2 = (*i2).get(); + RoomExitData const &rec2 = **i2; DebugPrintf("\nExit - (%d,%d)-(%d,%d) Dest=%d,(%d,%d) Dir=%s Sequence=%xh", - rec2->xs, rec2->ys, rec2->xe, rec2->ye, rec2->roomNumber, - rec2->x, rec2->y, directionList[rec2->direction], rec2->sequenceOffset); + rec2.xs, rec2.ys, rec2.xe, rec2.ye, rec2.roomNumber, + rec2.x, rec2.y, directionList[rec2.direction], rec2.sequenceOffset); } DebugPrintf("\n"); diff --git a/engines/lure/game.cpp b/engines/lure/game.cpp index 9542c35785..eaed7ebbe7 100644 --- a/engines/lure/game.cpp +++ b/engines/lure/game.cpp @@ -71,12 +71,12 @@ void Game::tick() { uint16 *idList = new uint16[res.activeHotspots().size()]; int idSize = 0; for (i = res.activeHotspots().begin(); i != res.activeHotspots().end(); ++i) { - Hotspot *hotspot = (*i).get(); + Hotspot const &hotspot = **i; - if (!_preloadFlag || ((hotspot->layer() != 0xff) && - (hotspot->hotspotId() < FIRST_NONCHARACTER_ID))) + if (!_preloadFlag || ((hotspot.layer() != 0xff) && + (hotspot.hotspotId() < FIRST_NONCHARACTER_ID))) // Add hotspot to list to execute - idList[idSize++] = hotspot->hotspotId(); + idList[idSize++] = hotspot.hotspotId(); } debugC(ERROR_DETAILED, kLureDebugAnimations, "Hotspot ticks begin"); diff --git a/engines/lure/hotspots.cpp b/engines/lure/hotspots.cpp index 207c125a0c..ee7a185ea1 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 @@ -1169,30 +1169,30 @@ bool Hotspot::doorCloseCheck(uint16 doorId) { HotspotList::iterator i; HotspotList &lst = res.activeHotspots(); for (i = lst.begin(); i != lst.end(); ++i) { - Hotspot *hsCurrent = (*i).get(); + Hotspot const &hsCurrent = **i; // Skip entry if it's the door or the character - if ((hsCurrent->hotspotId() == hotspotId()) || - (hsCurrent->hotspotId() == doorHotspot->hotspotId())) + if ((hsCurrent.hotspotId() == hotspotId()) || + (hsCurrent.hotspotId() == doorHotspot->hotspotId())) continue; // Skip entry if it doesn't meet certain criteria - if ((hsCurrent->layer() == 0) || - (hsCurrent->roomNumber() != doorHotspot->roomNumber()) || - (hsCurrent->hotspotId() < PLAYER_ID) || - ((hsCurrent->hotspotId() >= 0x408) && (hsCurrent->hotspotId() < 0x2710))) + if ((hsCurrent.layer() == 0) || + (hsCurrent.roomNumber() != doorHotspot->roomNumber()) || + (hsCurrent.hotspotId() < PLAYER_ID) || + ((hsCurrent.hotspotId() >= 0x408) && (hsCurrent.hotspotId() < 0x2710))) continue; // Also skip entry if special Id - if ((hsCurrent->hotspotId() == 0xfffe) || (hsCurrent->hotspotId() == 0xffff)) + if ((hsCurrent.hotspotId() == 0xfffe) || (hsCurrent.hotspotId() == 0xffff)) continue; // Check to see if the character is intersecting the door area - int tempY = hsCurrent->y() + hsCurrent->heightCopy(); - if ((hsCurrent->x() >= bounds.right) || - (hsCurrent->x() + hsCurrent->widthCopy() <= bounds.left) || - (tempY + hsCurrent->charRectY() < bounds.top) || - (tempY - hsCurrent->yCorrection() - hsCurrent->charRectY() > bounds.bottom)) + int tempY = hsCurrent.y() + hsCurrent.heightCopy(); + if ((hsCurrent.x() >= bounds.right) || + (hsCurrent.x() + hsCurrent.widthCopy() <= bounds.left) || + (tempY + hsCurrent.charRectY() < bounds.top) || + (tempY - hsCurrent.yCorrection() - hsCurrent.charRectY() > bounds.bottom)) continue; // At this point we know a character is blocking door, so return false @@ -1883,12 +1883,12 @@ void Hotspot::doStatus(HotspotData *hotspot) { HotspotDataList &list = res.hotspotData(); HotspotDataList::iterator i; for (i = list.begin(); i != list.end(); ++i) { - HotspotData *rec = (*i).get(); + HotspotData const &rec = **i; - if (rec->roomNumber == PLAYER_ID) { + if (rec.roomNumber == PLAYER_ID) { if (numItems++ == 0) strcat(buffer, ": "); else strcat(buffer, ", "); - strings.getString(rec->nameId, buffer + strlen(buffer)); + strings.getString(rec.nameId, buffer + strlen(buffer)); } } @@ -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 @@ -2334,9 +2334,11 @@ void Hotspot::saveToStream(Common::WriteStream *stream) { void Hotspot::loadFromStream(Common::ReadStream *stream) { if (_data) _data->npcSchedule.loadFromStream(stream); - else + else { // Dummy read of terminator for empty actions list - assert(stream->readByte() == 0xff); + byte dummy = stream->readByte(); + assert(dummy == 0xff); + } _pathFinder.loadFromStream(stream); @@ -4111,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: @@ -4164,6 +4166,7 @@ PathFinderResult PathFinder::process() { bool altFlag; uint16 *pCurrent; PathFinderResult result = PF_UNFINISHED; + bool skipToFinalStep = false; if (!_inProgress) { // Following code only done during first call to method @@ -4186,188 +4189,190 @@ PathFinderResult PathFinder::process() { _inProgress = false; result = PF_OK; - goto final_step; - } - - // Path finding + skipToFinalStep = true; + } else { + // Path finding - _destX >>= 3; - _destY >>= 3; - _pSrc = &_layer[(_yCurrent + 1) * DECODED_PATHS_WIDTH + 1 + _xCurrent]; - _pDest = &_layer[(_yDestCurrent + 1) * DECODED_PATHS_WIDTH + 1 + _xDestCurrent]; + _destX >>= 3; + _destY >>= 3; + _pSrc = &_layer[(_yCurrent + 1) * DECODED_PATHS_WIDTH + 1 + _xCurrent]; + _pDest = &_layer[(_yDestCurrent + 1) * DECODED_PATHS_WIDTH + 1 + _xDestCurrent]; - // Flag starting/ending cells - *_pSrc = 1; - _destOccupied = *_pDest != 0; - result = _destOccupied ? PF_DEST_OCCUPIED : PF_OK; - *_pDest = 0; + // Flag starting/ending cells + *_pSrc = 1; + _destOccupied = *_pDest != 0; + result = _destOccupied ? PF_DEST_OCCUPIED : PF_OK; + *_pDest = 0; - // Set up the current pointer, adjusting away from edges if necessary + // Set up the current pointer, adjusting away from edges if necessary - if (_xCurrent >= _xDestCurrent) { - _xChangeInc = -1; - _xChangeStart = ROOM_PATHS_WIDTH; - } else { - _xChangeInc = 1; - _xChangeStart = 1; - } + if (_xCurrent >= _xDestCurrent) { + _xChangeInc = -1; + _xChangeStart = ROOM_PATHS_WIDTH; + } else { + _xChangeInc = 1; + _xChangeStart = 1; + } - if (_yCurrent >= _yDestCurrent) { - _yChangeInc = -1; - _yChangeStart = ROOM_PATHS_HEIGHT; - } else { - _yChangeInc = 1; - _yChangeStart = 1; + if (_yCurrent >= _yDestCurrent) { + _yChangeInc = -1; + _yChangeStart = ROOM_PATHS_HEIGHT; + } else { + _yChangeInc = 1; + _yChangeStart = 1; + } } } - // Major loop to populate data - _cellPopulated = false; - - while (1) { - // Loop through to process cells in the given area - if (!returnFlag) _yCtr = 0; - while (returnFlag || (_yCtr < ROOM_PATHS_HEIGHT)) { - if (!returnFlag) _xCtr = 0; + if (!skipToFinalStep) { + // Major loop to populate data + _cellPopulated = false; - while (returnFlag || (_xCtr < ROOM_PATHS_WIDTH)) { - if (!returnFlag) { - processCell(&_layer[(_yChangeStart + _yCtr * _yChangeInc) * DECODED_PATHS_WIDTH + - (_xChangeStart + _xCtr * _xChangeInc)]); - if (breakFlag && (_countdownCtr <= 0)) return PF_UNFINISHED; - } else { - returnFlag = false; + while (1) { + // Loop through to process cells in the given area + if (!returnFlag) _yCtr = 0; + while (returnFlag || (_yCtr < ROOM_PATHS_HEIGHT)) { + if (!returnFlag) _xCtr = 0; + + while (returnFlag || (_xCtr < ROOM_PATHS_WIDTH)) { + if (!returnFlag) { + processCell(&_layer[(_yChangeStart + _yCtr * _yChangeInc) * DECODED_PATHS_WIDTH + + (_xChangeStart + _xCtr * _xChangeInc)]); + if (breakFlag && (_countdownCtr <= 0)) return PF_UNFINISHED; + } else { + returnFlag = false; + } + ++_xCtr; } - ++_xCtr; + ++_yCtr; } - ++_yCtr; - } - // If the destination cell has been filled in, then break out of loop - if (*_pDest != 0) break; + // If the destination cell has been filled in, then break out of loop + if (*_pDest != 0) break; - if (_cellPopulated) { - // At least one cell populated, so go repeat loop - _cellPopulated = false; - } else { - result = PF_PART_PATH; - scanFlag = true; - break; + if (_cellPopulated) { + // At least one cell populated, so go repeat loop + _cellPopulated = false; + } else { + result = PF_PART_PATH; + scanFlag = true; + break; + } } - } - _inProgress = false; + _inProgress = false; - if (scanFlag || _destOccupied) { - // Adjust the end point if necessary to stop character walking into occupied area + if (scanFlag || _destOccupied) { + // Adjust the end point if necessary to stop character walking into occupied area - // Restore destination's occupied state if necessary - if (_destOccupied) { - *_pDest = 0xffff; - _destOccupied = false; - } + // Restore destination's occupied state if necessary + if (_destOccupied) { + *_pDest = 0xffff; + _destOccupied = false; + } - // Scan through lines - v = 0xff; - pTemp = _pDest; - scanLine(_destX, -1, pTemp, v); - scanLine(ROOM_PATHS_WIDTH - _destX, 1, pTemp, v); - scanLine(_destY, -DECODED_PATHS_WIDTH, pTemp, v); - scanLine(ROOM_PATHS_HEIGHT - _destY, DECODED_PATHS_WIDTH, pTemp, v); + // Scan through lines + v = 0xff; + pTemp = _pDest; + scanLine(_destX, -1, pTemp, v); + scanLine(ROOM_PATHS_WIDTH - _destX, 1, pTemp, v); + scanLine(_destY, -DECODED_PATHS_WIDTH, pTemp, v); + scanLine(ROOM_PATHS_HEIGHT - _destY, DECODED_PATHS_WIDTH, pTemp, v); + + if (pTemp == _pDest) { + clear(); + return PF_NO_WALK; + } - if (pTemp == _pDest) { - clear(); - return PF_NO_WALK; + _pDest = pTemp; } - _pDest = pTemp; - } - - // ****DEBUG**** - if (_hotspot->hotspotId() == PLAYER_ID) { - for (int ctr = 0; ctr < DECODED_PATHS_WIDTH * DECODED_PATHS_HEIGHT; ++ctr) - Room::getReference().tempLayer[ctr] = _layer[ctr]; - } + // ****DEBUG**** + if (_hotspot->hotspotId() == PLAYER_ID) { + for (int ctr = 0; ctr < DECODED_PATHS_WIDTH * DECODED_PATHS_HEIGHT; ++ctr) + Room::getReference().tempLayer[ctr] = _layer[ctr]; + } - // Determine the walk path by working backwards from the destination, adding in the - // walking steps in reverse order until source is reached - int stageCtr; - for (stageCtr = 0; stageCtr < 3; ++stageCtr) { - // Clear out any previously determined directions - clear(); + // Determine the walk path by working backwards from the destination, adding in the + // walking steps in reverse order until source is reached + int stageCtr; + for (stageCtr = 0; stageCtr < 3; ++stageCtr) { + // Clear out any previously determined directions + clear(); - altFlag = stageCtr == 1; - pCurrent = _pDest; + altFlag = stageCtr == 1; + pCurrent = _pDest; + + numSteps = 0; + currDirection = NO_DIRECTION; + while (1) { + v = *pCurrent - 1; + if (v == 0) break; + + newDirection = NO_DIRECTION; + if (!altFlag && (currDirection != LEFT) && (currDirection != RIGHT)) { + // Standard order direction checking + if (*(pCurrent - DECODED_PATHS_WIDTH) == v) newDirection = DOWN; + else if (*(pCurrent + DECODED_PATHS_WIDTH) == v) newDirection = UP; + else if (*(pCurrent + 1) == v) newDirection = LEFT; + else if (*(pCurrent - 1) == v) newDirection = RIGHT; + } else { + // Alternate order direction checking + if (*(pCurrent + 1) == v) newDirection = LEFT; + else if (*(pCurrent - 1) == v) newDirection = RIGHT; + else if (*(pCurrent - DECODED_PATHS_WIDTH) == v) newDirection = DOWN; + else if (*(pCurrent + DECODED_PATHS_WIDTH) == v) newDirection = UP; + } + if (newDirection == NO_DIRECTION) + error("Path finding process failed"); - numSteps = 0; - currDirection = NO_DIRECTION; - while (1) { - v = *pCurrent - 1; - if (v == 0) break; - - newDirection = NO_DIRECTION; - if (!altFlag && (currDirection != LEFT) && (currDirection != RIGHT)) { - // Standard order direction checking - if (*(pCurrent - DECODED_PATHS_WIDTH) == v) newDirection = DOWN; - else if (*(pCurrent + DECODED_PATHS_WIDTH) == v) newDirection = UP; - else if (*(pCurrent + 1) == v) newDirection = LEFT; - else if (*(pCurrent - 1) == v) newDirection = RIGHT; - } else { - // Alternate order direction checking - if (*(pCurrent + 1) == v) newDirection = LEFT; - else if (*(pCurrent - 1) == v) newDirection = RIGHT; - else if (*(pCurrent - DECODED_PATHS_WIDTH) == v) newDirection = DOWN; - else if (*(pCurrent + DECODED_PATHS_WIDTH) == v) newDirection = UP; - } - if (newDirection == NO_DIRECTION) - error("Path finding process failed"); + // Process for the specified direction + if (newDirection != currDirection) add(newDirection, 0); - // Process for the specified direction - if (newDirection != currDirection) add(newDirection, 0); + switch (newDirection) { + case UP: + pCurrent += DECODED_PATHS_WIDTH; + break; - switch (newDirection) { - case UP: - pCurrent += DECODED_PATHS_WIDTH; - break; + case DOWN: + pCurrent -= DECODED_PATHS_WIDTH; + break; - case DOWN: - pCurrent -= DECODED_PATHS_WIDTH; - break; + case LEFT: + ++pCurrent; + break; - case LEFT: - ++pCurrent; - break; + case RIGHT: + --pCurrent; + break; - case RIGHT: - --pCurrent; - break; + default: + break; + } - default: - break; + ++numSteps; + top().rawSteps() += 8; + currDirection = newDirection; } - ++numSteps; - top().rawSteps() += 8; - currDirection = newDirection; + if (stageCtr == 0) + // Save the number of steps needed + savedSteps = numSteps; + if ((stageCtr == 1) && (numSteps <= savedSteps)) + // Less steps were needed, so break out + break; } - if (stageCtr == 0) - // Save the number of steps needed - savedSteps = numSteps; - if ((stageCtr == 1) && (numSteps <= savedSteps)) - // Less steps were needed, so break out - break; - } + // Add final movement if necessary - // Add final movement if necessary - - if (result == PF_OK) { - if (_xDestPos < 0) - addBack(LEFT, -_xDestPos); - else if (_xDestPos > 0) - addBack(RIGHT, _xDestPos); + if (result == PF_OK) { + if (_xDestPos < 0) + addBack(LEFT, -_xDestPos); + else if (_xDestPos > 0) + addBack(RIGHT, _xDestPos); + } } -final_step: + // Final Step if (_xPos < 0) add(RIGHT, -_xPos); else if (_xPos > 0) add(LEFT, _xPos); @@ -4380,8 +4385,8 @@ Common::String PathFinder::getDebugInfo() const { WalkingActionList::const_iterator i; for (i = _list.begin(); i != _list.end(); ++i) { - WalkingActionEntry *e = (*i).get(); - buffer += Common::String::format("Direction=%d, numSteps=%d\n", e->direction(), e->numSteps()); + WalkingActionEntry const &e = **i; + buffer += Common::String::format("Direction=%d, numSteps=%d\n", e.direction(), e.numSteps()); } return buffer; @@ -4491,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) { @@ -4499,11 +4504,10 @@ 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) { - WalkingActionEntry *entry = (*i).get(); - stream->writeByte(entry->direction()); - stream->writeSint16LE(entry->rawSteps()); + for (WalkingActionList::const_iterator i = _list.begin(); i != _list.end(); ++i) { + WalkingActionEntry &entry = **i; + stream->writeByte(entry.direction()); + stream->writeSint16LE(entry.rawSteps()); } stream->writeByte(0xff); stream->writeSint16LE(_stepCtr); @@ -4678,18 +4682,17 @@ 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) { - Hotspot *hotspot = (*i).get(); - debugC(ERROR_INTERMEDIATE, kLureDebugAnimations, "Saving hotspot %xh", hotspot->hotspotId()); - bool dynamicObject = hotspot->hotspotId() != hotspot->originalId(); - stream->writeUint16LE(hotspot->originalId()); +void HotspotList::saveToStream(Common::WriteStream *stream) const { + for (HotspotList::const_iterator i = begin(); i != end(); ++i) { + Hotspot const &hotspot = **i; + debugC(ERROR_INTERMEDIATE, kLureDebugAnimations, "Saving hotspot %xh", hotspot.hotspotId()); + bool dynamicObject = hotspot.hotspotId() != hotspot.originalId(); + stream->writeUint16LE(hotspot.originalId()); stream->writeByte(dynamicObject); - stream->writeUint16LE(hotspot->destHotspotId()); - hotspot->saveToStream(stream); + stream->writeUint16LE(hotspot.destHotspotId()); + hotspot.saveToStream(stream); - debugC(ERROR_DETAILED, kLureDebugAnimations, "Saved hotspot %xh", hotspot->hotspotId()); + debugC(ERROR_DETAILED, kLureDebugAnimations, "Saved hotspot %xh", hotspot.hotspotId()); } stream->writeUint16LE(0); } 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/menu.cpp b/engines/lure/menu.cpp index 9919471c76..5a0dd26cba 100644 --- a/engines/lure/menu.cpp +++ b/engines/lure/menu.cpp @@ -276,11 +276,11 @@ uint16 PopupMenu::ShowInventory() { HotspotDataList::iterator i; for (i = rsc.hotspotData().begin(); i != rsc.hotspotData().end(); ++i) { - HotspotData *hotspot = (*i).get(); - if (hotspot->roomNumber == PLAYER_ID) { - idList[itemCtr] = hotspot->hotspotId; + HotspotData const &hotspot = **i; + if (hotspot.roomNumber == PLAYER_ID) { + idList[itemCtr] = hotspot.hotspotId; char *hotspotName = itemNames[itemCtr++] = (char *) malloc(MAX_HOTSPOT_NAME_SIZE); - strings.getString(hotspot->nameId, hotspotName); + strings.getString(hotspot.nameId, hotspotName); } } @@ -317,52 +317,52 @@ uint16 PopupMenu::ShowItems(Action contextAction, uint16 roomNumber) { // Loop for rooms for (ir = rooms.begin(); ir != rooms.end(); ++ir) { - RoomData *roomData = (*ir).get(); + RoomData const &roomData = **ir; // Pre-condition checks for whether to skip room - if ((roomData->hdrFlags != 15) && ((roomData->hdrFlags & fields.hdrFlagMask()) == 0)) + if ((roomData.hdrFlags != 15) && ((roomData.hdrFlags & fields.hdrFlagMask()) == 0)) continue; - if (((roomData->flags & HOTSPOTFLAG_MENU_EXCLUSION) != 0) || ((roomData->flags & HOTSPOTFLAG_FOUND) == 0)) + if (((roomData.flags & HOTSPOTFLAG_MENU_EXCLUSION) != 0) || ((roomData.flags & HOTSPOTFLAG_FOUND) == 0)) continue; - if ((roomData->actions & contextBitflag) == 0) + if ((roomData.actions & contextBitflag) == 0) continue; // Add room to list of entries to display if (numItems == MAX_NUM_DISPLAY_ITEMS) error("Out of space in ask list"); - entryIds[numItems] = roomData->roomNumber; - nameIds[numItems] = roomData->roomNumber; + entryIds[numItems] = roomData.roomNumber; + nameIds[numItems] = roomData.roomNumber; entryNames[numItems] = (char *) Memory::alloc(MAX_HOTSPOT_NAME_SIZE); - strings.getString(roomData->roomNumber, entryNames[numItems]); + strings.getString(roomData.roomNumber, entryNames[numItems]); ++numItems; } // Loop for hotspots for (ih = hotspots.begin(); ih != hotspots.end(); ++ih) { - HotspotData *hotspot = (*ih).get(); + HotspotData const &hotspot = **ih; - if ((hotspot->headerFlags != 15) && - ((hotspot->headerFlags & fields.hdrFlagMask()) == 0)) + if ((hotspot.headerFlags != 15) && + ((hotspot.headerFlags & fields.hdrFlagMask()) == 0)) continue; - if (((hotspot->flags & HOTSPOTFLAG_MENU_EXCLUSION) != 0) || ((hotspot->flags & HOTSPOTFLAG_FOUND) == 0)) + if (((hotspot.flags & HOTSPOTFLAG_MENU_EXCLUSION) != 0) || ((hotspot.flags & HOTSPOTFLAG_FOUND) == 0)) // Skip the current hotspot continue; // If the hotspot is room specific, skip if the character will not be in the specified room - if (((hotspot->flags & HOTSPOTFLAG_ROOM_SPECIFIC) != 0) && - (hotspot->roomNumber != roomNumber)) + if (((hotspot.flags & HOTSPOTFLAG_ROOM_SPECIFIC) != 0) && + (hotspot.roomNumber != roomNumber)) continue; // If hotspot does not allow action, then skip it - if ((hotspot->actions & contextBitflag) == 0) + if ((hotspot.actions & contextBitflag) == 0) continue; // If a special hotspot Id, then skip displaying - if ((hotspot->nameId == 0x17A) || (hotspot->nameId == 0x147)) + if ((hotspot.nameId == 0x17A) || (hotspot.nameId == 0x147)) continue; // Check if the hotspot's name is already used in an already set item itemCtr = 0; - while ((itemCtr < numItems) && (nameIds[itemCtr] != hotspot->nameId)) + while ((itemCtr < numItems) && (nameIds[itemCtr] != hotspot.nameId)) ++itemCtr; if (itemCtr != numItems) // Item's name is already present - skip hotspot @@ -370,10 +370,10 @@ uint16 PopupMenu::ShowItems(Action contextAction, uint16 roomNumber) { // Add hotspot to list of entries to display if (numItems == MAX_NUM_DISPLAY_ITEMS) error("Out of space in ask list"); - entryIds[numItems] = hotspot->hotspotId; - nameIds[numItems] = hotspot->nameId; + entryIds[numItems] = hotspot.hotspotId; + nameIds[numItems] = hotspot.nameId; entryNames[numItems] = (char *) Memory::alloc(MAX_HOTSPOT_NAME_SIZE); - strings.getString(hotspot->nameId, entryNames[numItems]); + strings.getString(hotspot.nameId, entryNames[numItems]); ++numItems; } @@ -515,7 +515,9 @@ uint16 PopupMenu::Show(int numEntries, const char *actions[]) { r.top = Surface::textY(); r.bottom = s->height() - Surface::textY() + 1; - for (;;) { + bool bailOut = false; + + while (!bailOut) { if (refreshFlag) { // Set up the contents of the menu s->fillRect(r, bgColor); @@ -546,8 +548,8 @@ uint16 PopupMenu::Show(int numEntries, const char *actions[]) { while (e.pollEvent()) { if (engine.shouldQuit()) { selectedIndex = 0xffff; - goto bail_out; - + bailOut = true; + break; } else if (e.type() == Common::EVENT_WHEELUP) { // Scroll upwards if (selectedIndex > 0) { @@ -571,10 +573,12 @@ uint16 PopupMenu::Show(int numEntries, const char *actions[]) { ++selectedIndex; refreshFlag = true; } else if ((keycode == Common::KEYCODE_RETURN) || (keycode == Common::KEYCODE_KP_ENTER)) { - goto bail_out; + bailOut = true; + break; } else if (keycode == Common::KEYCODE_ESCAPE) { selectedIndex = 0xffff; - goto bail_out; + bailOut = true; + break; } #ifdef LURE_CLICKABLE_MENUS @@ -586,46 +590,51 @@ uint16 PopupMenu::Show(int numEntries, const char *actions[]) { if (r.contains(x, y)) { selectedIndex = (y - r.top) / FONT_HEIGHT; if (e.type() == Common::EVENT_LBUTTONDOWN) - goto bail_out; + bailOut = true; + break; } #else } else if ((e.type() == Common::EVENT_LBUTTONDOWN) || (e.type() == Common::EVENT_MBUTTONDOWN)) { //mouse.waitForRelease(); - goto bail_out; + bailOut = true; + break; #endif } else if (e.type() == Common::EVENT_RBUTTONDOWN) { mouse.waitForRelease(); selectedIndex = 0xffff; - goto bail_out; + bailOut = true; + break; } } + if (!bailOut) { #ifndef LURE_CLICKABLE_MENUS - // Warping the mouse to "neutral" even if the top/bottom menu - // entry has been reached has both pros and cons. It makes the - // menu behave a bit more sensibly, but it also makes it harder - // to move the mouse pointer out of the ScummVM window. - - if (mouse.y() < yMiddle - POPMENU_CHANGE_SENSITIVITY) { - if (selectedIndex > 0) { - --selectedIndex; - refreshFlag = true; - } - mouse.setPosition(FULL_SCREEN_WIDTH / 2, yMiddle); - } else if (mouse.y() > yMiddle + POPMENU_CHANGE_SENSITIVITY) { - if (selectedIndex < numEntries - 1) { - ++selectedIndex; - refreshFlag = true; + // Warping the mouse to "neutral" even if the top/bottom menu + // entry has been reached has both pros and cons. It makes the + // menu behave a bit more sensibly, but it also makes it harder + // to move the mouse pointer out of the ScummVM window. + + if (mouse.y() < yMiddle - POPMENU_CHANGE_SENSITIVITY) { + if (selectedIndex > 0) { + --selectedIndex; + refreshFlag = true; + } + mouse.setPosition(FULL_SCREEN_WIDTH / 2, yMiddle); + } else if (mouse.y() > yMiddle + POPMENU_CHANGE_SENSITIVITY) { + if (selectedIndex < numEntries - 1) { + ++selectedIndex; + refreshFlag = true; + } + mouse.setPosition(FULL_SCREEN_WIDTH / 2, yMiddle); } - mouse.setPosition(FULL_SCREEN_WIDTH / 2, yMiddle); - } #endif - system.delayMillis(20); + system.delayMillis(20); + } } -bail_out: + // bailOut delete s; #ifndef LURE_CLICKABLE_MENUS diff --git a/engines/lure/res.cpp b/engines/lure/res.cpp index 6328301233..9ec641140b 100644 --- a/engines/lure/res.cpp +++ b/engines/lure/res.cpp @@ -386,7 +386,6 @@ RoomData *Resources::getRoom(uint16 roomNumber) { for (i = _roomData.begin(); i != _roomData.end(); ++i) { RoomData *rec = (*i).get(); if (rec->roomNumber == roomNumber) return rec; - ++rec; } return NULL; @@ -678,9 +677,9 @@ void Resources::deactivateHotspot(uint16 hotspotId, bool isDestId) { HotspotList::iterator i = _activeHotspots.begin(); while (i != _activeHotspots.end()) { - Hotspot *h = (*i).get(); - if ((!isDestId && (h->hotspotId() == hotspotId)) || - (isDestId && (h->destHotspotId() == hotspotId) && (h->hotspotId() == 0xffff))) { + Hotspot const &h = **i; + if ((!isDestId && (h.hotspotId() == hotspotId)) || + (isDestId && (h.destHotspotId() == hotspotId) && (h.hotspotId() == 0xffff))) { _activeHotspots.erase(i); break; } @@ -708,8 +707,7 @@ uint16 Resources::numInventoryItems() { HotspotDataList &list = _hotspotData; HotspotDataList::iterator i; for (i = list.begin(); i != list.end(); ++i) { - HotspotData *rec = (*i).get(); - if (rec->roomNumber == PLAYER_ID) ++numItems; + if ((*i)->roomNumber == PLAYER_ID) ++numItems; } return numItems; @@ -754,12 +752,12 @@ void Resources::saveToStream(Common::WriteStream *stream) { // Save out the schedule for any non-active NPCs HotspotDataList::iterator i; for (i = _hotspotData.begin(); i != _hotspotData.end(); ++i) { - HotspotData *rec = (*i).get(); - if (!rec->npcSchedule.isEmpty()) { - Hotspot *h = getActiveHotspot(rec->hotspotId); + HotspotData const &rec = **i; + if (!rec.npcSchedule.isEmpty()) { + Hotspot *h = getActiveHotspot(rec.hotspotId); if (h == NULL) { - stream->writeUint16LE(rec->hotspotId); - rec->npcSchedule.saveToStream(stream); + stream->writeUint16LE(rec.hotspotId); + rec.npcSchedule.saveToStream(stream); } } } diff --git a/engines/lure/res_struct.cpp b/engines/lure/res_struct.cpp index 222f55b5dc..aee4f11215 100644 --- a/engines/lure/res_struct.cpp +++ b/engines/lure/res_struct.cpp @@ -278,13 +278,11 @@ 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) { - RoomData *rec = (*i).get(); - stream->writeByte(rec->flags); - const byte *pathData = rec->paths.data(); +void RoomDataList::saveToStream(Common::WriteStream *stream) const { + for (RoomDataList::const_iterator i = begin(); i != end(); ++i) { + RoomData const &rec = **i; + stream->writeByte(rec.flags); + const byte *pathData = rec.paths.data(); stream->write(pathData, ROOM_PATHS_HEIGHT * ROOM_PATHS_WIDTH); } } @@ -294,10 +292,10 @@ void RoomDataList::loadFromStream(Common::ReadStream *stream) { byte data[ROOM_PATHS_HEIGHT * ROOM_PATHS_WIDTH]; for (i = begin(); i != end(); ++i) { - RoomData *rec = (*i).get(); - rec->flags = stream->readByte(); + RoomData &rec = **i; + rec.flags = stream->readByte(); stream->read(data, ROOM_PATHS_HEIGHT * ROOM_PATHS_WIDTH); - rec->paths.load(data); + rec.paths.load(data); } } @@ -317,17 +315,17 @@ RoomExitJoinData::RoomExitJoinData(RoomExitJoinResource *rec) { blocked = rec->blocked; } -void RoomExitJoinList::saveToStream(Common::WriteStream *stream) { - for (RoomExitJoinList::iterator i = begin(); i != end(); ++i) { - RoomExitJoinData *rec = (*i).get(); - - stream->writeUint16LE(rec->hotspots[0].hotspotId); - stream->writeUint16LE(rec->hotspots[1].hotspotId); - stream->writeByte(rec->hotspots[0].currentFrame); - stream->writeByte(rec->hotspots[0].destFrame); - stream->writeByte(rec->hotspots[1].currentFrame); - stream->writeByte(rec->hotspots[1].destFrame); - stream->writeByte(rec->blocked); +void RoomExitJoinList::saveToStream(Common::WriteStream *stream) const { + for (RoomExitJoinList::const_iterator i = begin(); i != end(); ++i) { + RoomExitJoinData const &rec = **i; + + stream->writeUint16LE(rec.hotspots[0].hotspotId); + stream->writeUint16LE(rec.hotspots[1].hotspotId); + stream->writeByte(rec.hotspots[0].currentFrame); + stream->writeByte(rec.hotspots[0].destFrame); + stream->writeByte(rec.hotspots[1].currentFrame); + stream->writeByte(rec.hotspots[1].destFrame); + stream->writeByte(rec.blocked); } // Write end of list marker @@ -336,21 +334,21 @@ void RoomExitJoinList::saveToStream(Common::WriteStream *stream) { void RoomExitJoinList::loadFromStream(Common::ReadStream *stream) { for (RoomExitJoinList::iterator i = begin(); i != end(); ++i) { - RoomExitJoinData *rec = (*i).get(); + RoomExitJoinData &rec = **i; uint16 hotspot1Id = stream->readUint16LE(); if (hotspot1Id == 0xffff) error("Invalid room exit join list"); uint16 hotspot2Id = stream->readUint16LE(); - if ((rec->hotspots[0].hotspotId != hotspot1Id) || - (rec->hotspots[1].hotspotId != hotspot2Id)) + if ((rec.hotspots[0].hotspotId != hotspot1Id) || + (rec.hotspots[1].hotspotId != hotspot2Id)) break; - rec->hotspots[0].currentFrame = stream->readByte(); - rec->hotspots[0].destFrame = stream->readByte(); - rec->hotspots[1].currentFrame = stream->readByte(); - rec->hotspots[1].destFrame = stream->readByte(); - rec->blocked = stream->readByte(); + rec.hotspots[0].currentFrame = stream->readByte(); + rec.hotspots[0].destFrame = stream->readByte(); + rec.hotspots[1].currentFrame = stream->readByte(); + rec.hotspots[1].destFrame = stream->readByte(); + rec.blocked = stream->readByte(); } // Read final end of list marker @@ -368,8 +366,8 @@ HotspotActionData::HotspotActionData(HotspotActionResource *rec) { uint16 HotspotActionList::getActionOffset(Action action) { iterator i; for (i = begin(); i != end(); ++i) { - HotspotActionData *rec = (*i).get(); - if (rec->action == action) return rec->sequenceOffset; + HotspotActionData const &rec = **i; + if (rec.action == action) return rec.sequenceOffset; } return 0; @@ -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,12 +532,11 @@ void HotspotData::loadFromStream(Common::ReadStream *stream) { // Hotspot data list -void HotspotDataList::saveToStream(Common::WriteStream *stream) { - iterator i; - for (i = begin(); i != end(); ++i) { - HotspotData *hotspot = (*i).get(); - stream->writeUint16LE(hotspot->hotspotId); - hotspot->saveToStream(stream); +void HotspotDataList::saveToStream(Common::WriteStream *stream) const { + for (const_iterator i = begin(); i != end(); ++i) { + HotspotData const &hotspot = **i; + stream->writeUint16LE(hotspot.hotspotId); + hotspot.saveToStream(stream); } stream->writeUint16LE(0); } @@ -582,14 +579,14 @@ bool MovementDataList::getFrame(uint16 currentFrame, int16 &xChange, iterator i; for (i = begin(); i != end(); ++i) { - MovementData *rec = (*i).get(); + MovementData const &rec = **i; if (foundFlag || (i == begin())) { - xChange = rec->xChange; - yChange = rec->yChange; - nextFrame = rec->frameNumber; + xChange = rec.xChange; + yChange = rec.yChange; + nextFrame = rec.frameNumber; if (foundFlag) return true; } - if (rec->frameNumber == currentFrame) foundFlag = true; + if (rec.frameNumber == currentFrame) foundFlag = true; } return true; @@ -699,15 +696,12 @@ 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) { - TalkData *rec = (*i).get(); - TalkEntryList::iterator i2; +void TalkDataList::saveToStream(Common::WriteStream *stream) const { + for (TalkDataList::const_iterator i = begin(); i != end(); ++i) { + TalkData const &rec = **i; - for (i2 = rec->entries.begin(); i2 != rec->entries.end(); ++i2) { - TalkEntryData *entry = (*i2).get(); - stream->writeUint16LE(entry->descId); + for (TalkEntryList::const_iterator i2 = rec.entries.begin(); i2 != rec.entries.end(); ++i2) { + stream->writeUint16LE((*i2)->descId); } } } @@ -715,12 +709,10 @@ void TalkDataList::saveToStream(Common::WriteStream *stream) { void TalkDataList::loadFromStream(Common::ReadStream *stream) { TalkDataList::iterator i; for (i = begin(); i != end(); ++i) { - TalkData *rec = (*i).get(); - TalkEntryList::iterator i2; + TalkData const &rec = **i; - for (i2 = rec->entries.begin(); i2 != rec->entries.end(); ++i2) { - TalkEntryData *entry = (*i2).get(); - entry->descId = stream->readUint16LE(); + for (TalkEntryList::const_iterator i2 = rec.entries.begin(); i2 != rec.entries.end(); ++i2) { + (*i2)->descId = stream->readUint16LE(); } } } @@ -785,17 +777,17 @@ void SequenceDelayList::tick() { g_system->getMillis()); for (i = begin(); i != end(); ++i) { - SequenceDelayData *entry = (*i).get(); - debugC(ERROR_DETAILED, kLureDebugScripts, "Delay List check %xh at time %d", entry->sequenceOffset, entry->timeoutCtr); + SequenceDelayData &entry = **i; + debugC(ERROR_DETAILED, kLureDebugScripts, "Delay List check %xh at time %d", entry.sequenceOffset, entry.timeoutCtr); - if (entry->timeoutCtr <= GAME_FRAME_DELAY) { + if (entry.timeoutCtr <= GAME_FRAME_DELAY) { // Timeout reached - delete entry from list and execute the sequence - uint16 seqOffset = entry->sequenceOffset; + uint16 seqOffset = entry.sequenceOffset; erase(i); Script::execute(seqOffset); return; } else { - entry->timeoutCtr -= GAME_FRAME_DELAY; + entry.timeoutCtr -= GAME_FRAME_DELAY; } } } @@ -804,22 +796,19 @@ void SequenceDelayList::clear(bool forceClear) { SequenceDelayList::iterator i = begin(); while (i != end()) { - SequenceDelayData *entry = (*i).get(); - if (entry->canClear || forceClear) + if ((*i)->canClear || forceClear) i = erase(i); else ++i; } } -void SequenceDelayList::saveToStream(Common::WriteStream *stream) { - SequenceDelayList::iterator i; - - for (i = begin(); i != end(); ++i) { - SequenceDelayData *entry = (*i).get(); - stream->writeUint16LE(entry->sequenceOffset); - stream->writeUint32LE(entry->timeoutCtr); - stream->writeByte(entry->canClear); +void SequenceDelayList::saveToStream(Common::WriteStream *stream) const { + for (SequenceDelayList::const_iterator i = begin(); i != end(); ++i) { + SequenceDelayData const &entry = **i; + stream->writeUint16LE(entry.sequenceOffset); + stream->writeUint32LE(entry.timeoutCtr); + stream->writeByte(entry.canClear); } stream->writeUint16LE(0); @@ -1016,7 +1005,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 +1019,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); } @@ -1052,9 +1041,9 @@ RoomExitIndexedHotspotData::RoomExitIndexedHotspotData(RoomExitIndexedHotspotRes uint16 RoomExitIndexedHotspotList::getHotspot(uint16 roomNumber, uint8 hotspotIndexId) { iterator i; for (i = begin(); i != end(); ++i) { - RoomExitIndexedHotspotData *entry = (*i).get(); - if ((entry->roomNumber == roomNumber) && (entry->hotspotIndex == hotspotIndexId)) - return entry->hotspotId; + RoomExitIndexedHotspotData const &entry = **i; + if ((entry.roomNumber == roomNumber) && (entry.hotspotIndex == hotspotIndexId)) + return entry.hotspotId; } // No hotspot @@ -1074,12 +1063,12 @@ PausedCharacter::PausedCharacter(uint16 SrcCharId, uint16 DestCharId) { void PausedCharacterList::reset(uint16 hotspotId) { iterator i; for (i = begin(); i != end(); ++i) { - PausedCharacter *rec = (*i).get(); + PausedCharacter &rec = **i; - if (rec->srcCharId == hotspotId) { - rec->counter = 1; - if (rec->destCharId < START_EXIT_ID) - rec->charHotspot->pauseCtr = 1; + if (rec.srcCharId == hotspotId) { + rec.counter = 1; + if (rec.destCharId < START_EXIT_ID) + rec.charHotspot->pauseCtr = 1; } } } @@ -1088,15 +1077,15 @@ void PausedCharacterList::countdown() { iterator i = begin(); while (i != end()) { - PausedCharacter *rec = (*i).get(); - --rec->counter; + PausedCharacter &rec = **i; + --rec.counter; // Handle reflecting counter to hotspot - if (rec->destCharId < START_EXIT_ID) - rec->charHotspot->pauseCtr = rec->counter + 1; + if (rec.destCharId < START_EXIT_ID) + rec.charHotspot->pauseCtr = rec.counter + 1; // If counter has reached zero, remove entry from list - if (rec->counter == 0) + if (rec.counter == 0) i = erase(i); else ++i; @@ -1109,13 +1098,13 @@ void PausedCharacterList::scan(Hotspot &h) { if (h.blockedState() != BS_NONE) { for (i = begin(); i != end(); ++i) { - PausedCharacter *rec = (*i).get(); + PausedCharacter &rec = **i; - if (rec->srcCharId == h.hotspotId()) { - rec->counter = IDLE_COUNTDOWN_SIZE; + if (rec.srcCharId == h.hotspotId()) { + rec.counter = IDLE_COUNTDOWN_SIZE; - if (rec->destCharId < START_EXIT_ID) - rec->charHotspot->pauseCtr = IDLE_COUNTDOWN_SIZE; + if (rec.destCharId < START_EXIT_ID) + rec.charHotspot->pauseCtr = IDLE_COUNTDOWN_SIZE; } } } @@ -1139,9 +1128,9 @@ int PausedCharacterList::check(uint16 charId, int numImpinging, uint16 *impingin // calling character and the impinging list entry bool foundEntry = false; for (i = res.pausedList().begin(); !foundEntry && (i != res.pausedList().end()); ++i) { - PausedCharacter *rec = (*i).get(); - foundEntry = (rec->srcCharId == charId) && - (rec->destCharId == hotspot->hotspotId()); + PausedCharacter const &rec = **i; + foundEntry = (rec.srcCharId == charId) && + (rec.destCharId == hotspot->hotspotId()); } if (foundEntry) @@ -1196,7 +1185,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 +1285,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 +1360,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); @@ -1443,11 +1432,11 @@ Common::String CurrentActionStack::getDebugInfo() const { buffer += Common::String::format("CurrentActionStack::list num_actions=%d\n", size()); for (i = _actions.begin(); i != _actions.end(); ++i) { - CurrentActionEntry *entry = (*i).get(); - buffer += Common::String::format("style=%d room#=%d", entry->action(), entry->roomNumber()); + CurrentActionEntry const &entry = **i; + buffer += Common::String::format("style=%d room#=%d", entry.action(), entry.roomNumber()); - if (entry->hasSupportData()) { - CharacterScheduleEntry &rec = entry->supportData(); + if (entry.hasSupportData()) { + CharacterScheduleEntry &rec = entry.supportData(); buffer += Common::String::format(", action=%d params=", rec.action()); @@ -1466,16 +1455,13 @@ 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) { - CurrentActionEntry *rec = (*i).get(); - rec->saveToStream(stream); + for (ActionsList::const_iterator i = _actions.begin(); i != _actions.end(); ++i) { + (*i)->saveToStream(stream); } stream->writeByte(0xff); // End of list marker debugC(ERROR_DETAILED, kLureDebugAnimations, "Finished saving hotspot action stack"); 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); }; diff --git a/engines/lure/room.cpp b/engines/lure/room.cpp index 219ed0263d..9a9313ece9 100644 --- a/engines/lure/room.cpp +++ b/engines/lure/room.cpp @@ -138,8 +138,8 @@ void Room::leaveRoom() { HotspotList &list = r.activeHotspots(); HotspotList::iterator i = list.begin(); while (i != list.end()) { - Hotspot *h = (i.operator*()).get(); - if (!h->persistant()) { + Hotspot const &h = **i; + if (!h.persistant()) { i = list.erase(i); } else { ++i; @@ -153,11 +153,11 @@ void Room::loadRoomHotspots() { HotspotDataList::iterator i; for (i = list.begin(); i != list.end(); ++i) { - HotspotData *rec = (*i).get(); + HotspotData const &rec = **i; - if ((rec->hotspotId < 0x7530) && (rec->roomNumber == _roomNumber) && - (rec->layer != 0)) - r.activateHotspot(rec->hotspotId); + if ((rec.hotspotId < 0x7530) && (rec.roomNumber == _roomNumber) && + (rec.layer != 0)) + r.activateHotspot(rec.hotspotId); } } @@ -252,24 +252,24 @@ CursorType Room::checkRoomExits() { RoomExitHotspotList::iterator i; for (i = exits.begin(); i != exits.end(); ++i) { - RoomExitHotspotData *rec = (*i).get(); + RoomExitHotspotData const &rec = **i; skipFlag = false; - if (rec->hotspotId != 0) { - join = res.getExitJoin(rec->hotspotId); + if (rec.hotspotId != 0) { + join = res.getExitJoin(rec.hotspotId); if ((join) && (join->blocked != 0)) skipFlag = true; } - if (!skipFlag && (m.x() >= rec->xs) && (m.x() <= rec->xe) && - (m.y() >= rec->ys) && (m.y() <= rec->ye)) { + if (!skipFlag && (m.x() >= rec.xs) && (m.x() <= rec.xe) && + (m.y() >= rec.ys) && (m.y() <= rec.ye)) { // Cursor is within exit area - CursorType cursorNum = (CursorType)rec->cursorNum; - _destRoomNumber = rec->destRoomNumber; + CursorType cursorNum = (CursorType)rec.cursorNum; + _destRoomNumber = rec.destRoomNumber; // If it's a hotspotted exit, change arrow to the + arrow - if (rec->hotspotId != 0) { - _hotspotId = rec->hotspotId; + if (rec.hotspotId != 0) { + _hotspotId = rec.hotspotId; _hotspot = res.getHotspot(_hotspotId); _hotspotNameId = _hotspot->nameId; _isExit = true; @@ -437,7 +437,7 @@ void Room::update() { // Handle first layer (layer 3) for (i = hotspots.begin(); i != hotspots.end(); ++i) { - Hotspot &h = *i.operator*(); + Hotspot &h = **i; if ((h.roomNumber() == _roomNumber) && h.isActiveAnimation() && (h.layer() == 3)) { addAnimation(h); @@ -449,28 +449,28 @@ void Room::update() { Common::List<Hotspot *> tempList; Common::List<Hotspot *>::iterator iTemp; for (i = hotspots.begin(); i != hotspots.end(); ++i) { - Hotspot *h = (i.operator*()).get(); + Hotspot *h = i->get(); if ((h->layer() != 1) || (h->roomNumber() != _roomNumber) || h->skipFlag() || !h->isActiveAnimation()) continue; int16 endY = h->y() + h->heightCopy(); for (iTemp = tempList.begin(); iTemp != tempList.end(); ++iTemp) { - Hotspot *hTemp = iTemp.operator*(); + Hotspot *hTemp = *iTemp; int16 tempY = hTemp->y() + hTemp->heightCopy(); if (endY < tempY) break; } tempList.insert(iTemp, h); } for (iTemp = tempList.begin(); iTemp != tempList.end(); ++iTemp) { - Hotspot &h = *iTemp.operator*(); + Hotspot &h = **iTemp; addAnimation(h); addLayers(h); } // Handle third layer (layer 2) for (i = hotspots.begin(); i != hotspots.end(); ++i) { - Hotspot &h = *i.operator*(); + Hotspot &h = **i; if ((h.roomNumber() == _roomNumber) && h.isActiveAnimation() && (h.layer() == 2)) { addAnimation(h); diff --git a/engines/lure/sound.cpp b/engines/lure/sound.cpp index 0aecae22ec..298483bed8 100644 --- a/engines/lure/sound.cpp +++ b/engines/lure/sound.cpp @@ -107,8 +107,7 @@ void SoundManager::saveToStream(Common::WriteStream *stream) { SoundListIterator i; for (i = _activeSounds.begin(); i != _activeSounds.end(); ++i) { - SoundDescResource *rec = (*i).get(); - stream->writeByte(rec->soundNumber); + stream->writeByte((*i)->soundNumber); } stream->writeByte(0xff); } @@ -335,14 +334,14 @@ void SoundManager::tidySounds() { SoundListIterator i = _activeSounds.begin(); while (i != _activeSounds.end()) { - SoundDescResource *rec = (*i).get(); + SoundDescResource const &rec = **i; - if (musicInterface_CheckPlaying(rec->soundNumber)) + if (musicInterface_CheckPlaying(rec.soundNumber)) // Still playing, so move to next entry ++i; else { // Mark the channels that it used as now being free - Common::fill(_channelsInUse+rec->channel, _channelsInUse+rec->channel+rec->numChannels, false); + Common::fill(_channelsInUse + rec.channel, _channelsInUse + rec.channel + rec.numChannels, false); i = _activeSounds.erase(i); } @@ -356,10 +355,10 @@ void SoundManager::removeSounds() { SoundListIterator i = _activeSounds.begin(); while (i != _activeSounds.end()) { - SoundDescResource *rec = (*i).get(); + SoundDescResource const &rec = **i; - if ((rec->flags & SF_IN_USE) != 0) - musicInterface_Stop(rec->soundNumber); + if ((rec.flags & SF_IN_USE) != 0) + musicInterface_Stop(rec.soundNumber); ++i; } @@ -370,13 +369,13 @@ void SoundManager::restoreSounds() { SoundListIterator i = _activeSounds.begin(); while (i != _activeSounds.end()) { - SoundDescResource *rec = (*i).get(); + SoundDescResource const &rec = **i; - if ((rec->numChannels != 0) && ((rec->flags & SF_RESTORE) != 0)) { - Common::fill(_channelsInUse+rec->channel, _channelsInUse+rec->channel+rec->numChannels, true); + if ((rec.numChannels != 0) && ((rec.flags & SF_RESTORE) != 0)) { + Common::fill(_channelsInUse + rec.channel, _channelsInUse + rec.channel + rec.numChannels, true); - musicInterface_Play(rec->soundNumber, rec->channel, rec->numChannels); - musicInterface_SetVolume(rec->channel, rec->volume); + musicInterface_Play(rec.soundNumber, rec.channel, rec.numChannels); + musicInterface_SetVolume(rec.channel, rec.volume); } ++i; @@ -397,10 +396,10 @@ void SoundManager::fadeOut() { g_system->lockMutex(_soundMutex); MusicListIterator i; for (i = _playingSounds.begin(); i != _playingSounds.end(); ++i) { - MidiMusic *music = (*i).get(); - if (music->getVolume() > 0) { + MidiMusic &music = **i; + if (music.getVolume() > 0) { inProgress = true; - music->setVolume(music->getVolume() >= 10 ? (music->getVolume() - 10) : 0); + music.setVolume(music.getVolume() >= 10 ? music.getVolume() - 10 : 0); } } @@ -468,8 +467,7 @@ void SoundManager::musicInterface_Stop(uint8 soundNumber) { g_system->lockMutex(_soundMutex); MusicListIterator i; for (i = _playingSounds.begin(); i != _playingSounds.end(); ++i) { - MidiMusic *music = (*i).get(); - if (music->soundNumber() == soundNum) { + if ((*i)->soundNumber() == soundNum) { _playingSounds.erase(i); break; } @@ -489,8 +487,7 @@ bool SoundManager::musicInterface_CheckPlaying(uint8 soundNumber) { g_system->lockMutex(_soundMutex); MusicListIterator i; for (i = _playingSounds.begin(); i != _playingSounds.end(); ++i) { - MidiMusic *music = (*i).get(); - if (music->soundNumber() == soundNum) { + if ((*i)->soundNumber() == soundNum) { result = true; break; } @@ -511,9 +508,9 @@ void SoundManager::musicInterface_SetVolume(uint8 channelNum, uint8 volume) { g_system->lockMutex(_soundMutex); MusicListIterator i; for (i = _playingSounds.begin(); i != _playingSounds.end(); ++i) { - MidiMusic *music = (*i).get(); - if (music->channelNumber() == channelNum) - music->setVolume(volume); + MidiMusic &music = **i; + if (music.channelNumber() == channelNum) + music.setVolume(volume); } g_system->unlockMutex(_soundMutex); } @@ -528,8 +525,7 @@ void SoundManager::musicInterface_KillAll() { g_system->lockMutex(_soundMutex); MusicListIterator i; for (i = _playingSounds.begin(); i != _playingSounds.end(); ++i) { - MidiMusic *music = (*i).get(); - music->stopMusic(); + (*i)->stopMusic(); } _playingSounds.clear(); @@ -561,8 +557,7 @@ void SoundManager::musicInterface_TidySounds() { g_system->lockMutex(_soundMutex); MusicListIterator i = _playingSounds.begin(); while (i != _playingSounds.end()) { - MidiMusic *music = (*i).get(); - if (!music->isPlaying()) + if (!(*i)->isPlaying()) i = _playingSounds.erase(i); else ++i; @@ -583,9 +578,9 @@ void SoundManager::doTimer() { MusicListIterator i; for (i = _playingSounds.begin(); i != _playingSounds.end(); ++i) { - MidiMusic *music = (*i).get(); - if (music->isPlaying()) - music->onTimer(); + MidiMusic &music = **i; + if (music.isPlaying()) + music.onTimer(); } g_system->unlockMutex(_soundMutex); @@ -635,7 +630,7 @@ MidiMusic::MidiMusic(MidiDriver *driver, ChannelEntry channels[NUM_CHANNELS], for (uint i = 0; i < packedSize; i++) #if defined(SCUMM_NEED_ALIGNMENT) - memcpy(dataDest++, (byte*)((byte*)data + *(idx + i) * sizeof(uint16)), sizeof(uint16)); + memcpy(dataDest++, (byte *)((byte *)data + *(idx + i) * sizeof(uint16)), sizeof(uint16)); #else *dataDest++ = data[*(idx + i)]; #endif diff --git a/engines/lure/surface.cpp b/engines/lure/surface.cpp index bfada8fde6..4d63647af5 100644 --- a/engines/lure/surface.cpp +++ b/engines/lure/surface.cpp @@ -1329,8 +1329,8 @@ bool CopyProtectionDialog::show() { ++hotspot6; // Add wording header and display screen - (hotspot2->get())->setFrameNumber(1); - (hotspot2->get())->copyTo(&screen.screen()); + (*hotspot2)->setFrameNumber(1); + (*hotspot2)->copyTo(&screen.screen()); screen.update(); screen.setPalette(&p); @@ -1340,8 +1340,8 @@ bool CopyProtectionDialog::show() { } while (!events.interruptableDelay(100)); // Change title text to selection - (hotspot2->get())->setFrameNumber(0); - (hotspot2->get())->copyTo(&screen.screen()); + (*hotspot2)->setFrameNumber(0); + (*hotspot2)->copyTo(&screen.screen()); screen.update(); // Clear any prior try @@ -1356,8 +1356,8 @@ bool CopyProtectionDialog::show() { HotspotsList::iterator tmpHotspot = _hotspots.begin(); for (int i = 0; i < _charIndex + 3; i++) ++tmpHotspot; - (tmpHotspot->get())->setFrameNumber(10); // Blank space - (tmpHotspot->get())->copyTo(&screen.screen()); + (*tmpHotspot)->setFrameNumber(10); // Blank space + (*tmpHotspot)->copyTo(&screen.screen()); screen.update(); } else if ((events.event().kbd.keycode >= Common::KEYCODE_0) && @@ -1366,8 +1366,8 @@ bool CopyProtectionDialog::show() { for (int i = 0; i < _charIndex + 3; i++) ++tmpHotspot; // Number pressed - (tmpHotspot->get())->setFrameNumber(events.event().kbd.ascii - '0'); - (tmpHotspot->get())->copyTo(&screen.screen()); + (*tmpHotspot)->setFrameNumber(events.event().kbd.ascii - '0'); + (*tmpHotspot)->copyTo(&screen.screen()); ++_charIndex; } @@ -1385,11 +1385,11 @@ bool CopyProtectionDialog::show() { return false; // At this point, two page numbers have been entered - validate them - int page1 = ((hotspot3->get())->frameNumber() * 10) + (hotspot4->get())->frameNumber(); - int page2 = ((hotspot5->get())->frameNumber() * 10) + (hotspot6->get())->frameNumber(); + int page1 = ((*hotspot3)->frameNumber() * 10) + (*hotspot4)->frameNumber(); + int page2 = ((*hotspot5)->frameNumber() * 10) + (*hotspot6)->frameNumber(); - if ((page1 == pageNumbers[(hotspot0->get())->frameNumber()]) && - (page2 == pageNumbers[(hotspot1->get())->frameNumber()])) + if ((page1 == pageNumbers[(*hotspot0)->frameNumber()]) && + (page2 == pageNumbers[(*hotspot1)->frameNumber()])) return true; } @@ -1404,11 +1404,11 @@ void CopyProtectionDialog::chooseCharacters() { int char2 = rnd.getRandomNumber(19); HotspotsList::iterator curHotspot = _hotspots.begin(); - (curHotspot->get())->setFrameNumber(char1); - (curHotspot->get())->copyTo(&screen.screen()); + (*curHotspot)->setFrameNumber(char1); + (*curHotspot)->copyTo(&screen.screen()); ++curHotspot; - (curHotspot->get())->setFrameNumber(char2); - (curHotspot->get())->copyTo(&screen.screen()); + (*curHotspot)->setFrameNumber(char2); + (*curHotspot)->copyTo(&screen.screen()); screen.update(); } |