JANITORIAL: Simply use *x instead of *x.get() on smart pointers.

This commit is contained in:
Christoph Mallon 2012-03-13 14:53:40 +01:00 committed by Alyssa Milburn
parent 612bfe4092
commit e40ba4c135
15 changed files with 231 additions and 241 deletions

View file

@ -232,8 +232,9 @@ bool TranslationManager::openTranslationsFile(File &inFile) {
ArchiveMemberList fileList; ArchiveMemberList fileList;
SearchMan.listMatchingMembers(fileList, "translations.dat"); SearchMan.listMatchingMembers(fileList, "translations.dat");
for (ArchiveMemberList::iterator it = fileList.begin(); it != fileList.end(); ++it) { for (ArchiveMemberList::iterator it = fileList.begin(); it != fileList.end(); ++it) {
SeekableReadStream *stream = it->get()->createReadStream(); ArchiveMember const &m = **it;
if (stream && inFile.open(stream, it->get()->getName())) { SeekableReadStream *const stream = m.createReadStream();
if (stream && inFile.open(stream, m.getName())) {
if (checkHeader(inFile)) if (checkHeader(inFile))
return true; return true;
inFile.close(); inFile.close();

View file

@ -1460,7 +1460,7 @@ void GUI_EoB::processButton(Button *button) {
// nullsub (at least EOBII) // nullsub (at least EOBII)
} else if (button->data0Val1 == 4) { } else if (button->data0Val1 == 4) {
if (button->data1Callback) if (button->data1Callback)
(*button->data1Callback.get())(button); (*button->data1Callback)(button);
} }
} else if (button->data1Val1 == 2) { } else if (button->data1Val1 == 2) {
if (!(button->flags2 & 4)) if (!(button->flags2 & 4))
@ -1469,7 +1469,7 @@ void GUI_EoB::processButton(Button *button) {
// nullsub (at least EOBII) // nullsub (at least EOBII)
} else if (button->data1Val1 == 4) { } else if (button->data1Val1 == 4) {
if (button->data1Callback) if (button->data1Callback)
(*button->data1Callback.get())(button); (*button->data1Callback)(button);
} }
} }
@ -1486,7 +1486,7 @@ void GUI_EoB::processButton(Button *button) {
// nullsub (at least EOBII) // nullsub (at least EOBII)
} else if (button->data0Val1 == 4) { } else if (button->data0Val1 == 4) {
if (button->data2Callback) if (button->data2Callback)
(*button->data2Callback.get())(button); (*button->data2Callback)(button);
} }
} else if (button->data2Val1 == 2) { } else if (button->data2Val1 == 2) {
_screen->drawBox(sx, sy, fx2, fy2, (button->flags2 & 1) ? button->data3Val2 : button->data2Val2); _screen->drawBox(sx, sy, fx2, fy2, (button->flags2 & 1) ? button->data3Val2 : button->data2Val2);
@ -1494,7 +1494,7 @@ void GUI_EoB::processButton(Button *button) {
// nullsub (at least EOBII) // nullsub (at least EOBII)
} else if (button->data2Val1 == 4) { } else if (button->data2Val1 == 4) {
if (button->data2Callback) if (button->data2Callback)
(*button->data2Callback.get())(button); (*button->data2Callback)(button);
} }
} }
@ -1507,7 +1507,7 @@ void GUI_EoB::processButton(Button *button) {
// nullsub (at least EOBII) // nullsub (at least EOBII)
} else if (button->data0Val1 == 4) { } else if (button->data0Val1 == 4) {
if (button->data0Callback) if (button->data0Callback)
(*button->data0Callback.get())(button); (*button->data0Callback)(button);
} else if (button->data0Val1 == 5) { } else if (button->data0Val1 == 5) {
_screen->drawBox(sx, sy, fx2, fy2, button->data0Val2); _screen->drawBox(sx, sy, fx2, fy2, button->data0Val2);
} else { } else {
@ -1876,7 +1876,7 @@ int GUI_EoB::processButtonList(Kyra::Button *buttonList, uint16 inputFlags, int8
processButton(buttonList); processButton(buttonList);
if (v6 && buttonList->buttonCallback) if (v6 && buttonList->buttonCallback)
runLoop = !(*buttonList->buttonCallback.get())(buttonList); runLoop = !(*buttonList->buttonCallback)(buttonList);
if ((flgs2 & 2) && (flgs & 0x20)) if ((flgs2 & 2) && (flgs & 0x20))
runLoop = false; runLoop = false;

View file

@ -243,7 +243,7 @@ int GUI_LoK::processButtonList(Button *list, uint16 inputFlag, int8 mouseWheel)
} }
if (mouseWheel && list->mouseWheel == mouseWheel && list->buttonCallback) { if (mouseWheel && list->mouseWheel == mouseWheel && list->buttonCallback) {
if ((*list->buttonCallback.get())(list)) if ((*list->buttonCallback)(list))
break; break;
} }
@ -282,7 +282,7 @@ int GUI_LoK::processButtonList(Button *list, uint16 inputFlag, int8 mouseWheel)
if (processMouseClick) { if (processMouseClick) {
if (list->buttonCallback) { if (list->buttonCallback) {
if ((*list->buttonCallback.get())(list)) if ((*list->buttonCallback)(list))
break; break;
} }
} }
@ -349,7 +349,7 @@ void GUI_LoK::processButton(Button *button) {
if (processType == 1 && shape) if (processType == 1 && shape)
_screen->drawShape(_screen->_curPage, shape, x, y, button->dimTableIndex, 0x10); _screen->drawShape(_screen->_curPage, shape, x, y, button->dimTableIndex, 0x10);
else if (processType == 4 && callback) else if (processType == 4 && callback)
(*callback.get())(button); (*callback)(button);
} }
void GUI_LoK::setGUILabels() { void GUI_LoK::setGUILabels() {

View file

@ -2165,7 +2165,7 @@ int GUI_LoL::processButtonList(Button *buttonList, uint16 inputFlag, int8 mouseW
if (buttonList->buttonCallback) { if (buttonList->buttonCallback) {
//_vm->removeInputTop(); //_vm->removeInputTop();
if ((*buttonList->buttonCallback.get())(buttonList)) if ((*buttonList->buttonCallback)(buttonList))
break; break;
} }

View file

@ -360,7 +360,7 @@ int GUI_v2::processButtonList(Button *buttonList, uint16 inputFlag, int8 mouseWh
if (buttonList->buttonCallback) { if (buttonList->buttonCallback) {
_vm->removeInputTop(); _vm->removeInputTop();
if ((*buttonList->buttonCallback.get())(buttonList)) if ((*buttonList->buttonCallback)(buttonList))
break; break;
} }

View file

@ -119,21 +119,21 @@ bool Debugger::cmd_listRooms(int argc, const char **argv) {
DebugPrintf("Available rooms are:\n"); DebugPrintf("Available rooms are:\n");
for (RoomDataList::iterator i = rooms.begin(); i != rooms.end(); ++i) { 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" // Explictly note the second drawbridge room as "Alt"
if (room->roomNumber == 49) { if (room.roomNumber == 49) {
strings.getString(47, buffer); strings.getString(47, buffer);
strcat(buffer, " (alt)"); strcat(buffer, " (alt)");
} else { } 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"); if (++ctr % 3 == 0) DebugPrintf("\n");
else { else {
// Write out spaces between columns // 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; char *s = buffer;
while (numSpaces-- > 0) *s++ = ' '; while (numSpaces-- > 0) *s++ = ' ';
*s = '\0'; *s = '\0';
@ -243,13 +243,13 @@ bool Debugger::cmd_hotspots(int argc, const char **argv) {
// Loop for displaying active hotspots // Loop for displaying active hotspots
HotspotList::iterator i; HotspotList::iterator i;
for (i = res.activeHotspots().begin(); i != res.activeHotspots().end(); ++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"); if (hotspot.nameId() == 0) strcpy(buffer, "none");
else strings.getString(hotspot->nameId(), buffer); else strings.getString(hotspot.nameId(), buffer);
DebugPrintf("%4xh - %s pos=(%d,%d,%d)\n", hotspot->hotspotId(), buffer, DebugPrintf("%4xh - %s pos=(%d,%d,%d)\n", hotspot.hotspotId(), buffer,
hotspot->x(), hotspot->y(), hotspot->roomNumber()); hotspot.x(), hotspot.y(), hotspot.roomNumber());
} }
} else { } else {
// Presume it's a room's hotspots // Presume it's a room's hotspots
@ -257,14 +257,14 @@ bool Debugger::cmd_hotspots(int argc, const char **argv) {
HotspotDataList::iterator i; HotspotDataList::iterator i;
for (i = res.hotspotData().begin(); i != res.hotspotData().end(); ++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.roomNumber == roomNumber) {
if (hotspot->nameId == 0) strcpy(buffer, "none"); if (hotspot.nameId == 0) strcpy(buffer, "none");
else strings.getString(hotspot->nameId, buffer); else strings.getString(hotspot.nameId, buffer);
DebugPrintf("%4xh - %s pos=(%d,%d,%d)\n", hotspot->hotspotId, buffer, DebugPrintf("%4xh - %s pos=(%d,%d,%d)\n", hotspot.hotspotId, buffer,
hotspot->startX, hotspot->startY, hotspot->roomNumber); hotspot.startX, hotspot.startY, hotspot.roomNumber);
} }
} }
} }
@ -415,10 +415,10 @@ bool Debugger::cmd_room(int argc, const char **argv) {
else { else {
RoomExitHotspotList::iterator i; RoomExitHotspotList::iterator i;
for (i = exits.begin(); i != exits.end(); ++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", 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"); DebugPrintf("\n");
@ -430,11 +430,11 @@ bool Debugger::cmd_room(int argc, const char **argv) {
else { else {
RoomExitList::iterator i2; RoomExitList::iterator i2;
for (i2 = room->exits.begin(); i2 != room->exits.end(); ++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", 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.xs, rec2.ys, rec2.xe, rec2.ye, rec2.roomNumber,
rec2->x, rec2->y, directionList[rec2->direction], rec2->sequenceOffset); rec2.x, rec2.y, directionList[rec2.direction], rec2.sequenceOffset);
} }
DebugPrintf("\n"); DebugPrintf("\n");

View file

@ -71,12 +71,12 @@ void Game::tick() {
uint16 *idList = new uint16[res.activeHotspots().size()]; uint16 *idList = new uint16[res.activeHotspots().size()];
int idSize = 0; int idSize = 0;
for (i = res.activeHotspots().begin(); i != res.activeHotspots().end(); ++i) { for (i = res.activeHotspots().begin(); i != res.activeHotspots().end(); ++i) {
Hotspot *hotspot = (*i).get(); Hotspot const &hotspot = **i;
if (!_preloadFlag || ((hotspot->layer() != 0xff) && if (!_preloadFlag || ((hotspot.layer() != 0xff) &&
(hotspot->hotspotId() < FIRST_NONCHARACTER_ID))) (hotspot.hotspotId() < FIRST_NONCHARACTER_ID)))
// Add hotspot to list to execute // Add hotspot to list to execute
idList[idSize++] = hotspot->hotspotId(); idList[idSize++] = hotspot.hotspotId();
} }
debugC(ERROR_DETAILED, kLureDebugAnimations, "Hotspot ticks begin"); debugC(ERROR_DETAILED, kLureDebugAnimations, "Hotspot ticks begin");

View file

@ -1169,30 +1169,30 @@ bool Hotspot::doorCloseCheck(uint16 doorId) {
HotspotList::iterator i; HotspotList::iterator i;
HotspotList &lst = res.activeHotspots(); HotspotList &lst = res.activeHotspots();
for (i = lst.begin(); i != lst.end(); ++i) { 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 // Skip entry if it's the door or the character
if ((hsCurrent->hotspotId() == hotspotId()) || if ((hsCurrent.hotspotId() == hotspotId()) ||
(hsCurrent->hotspotId() == doorHotspot->hotspotId())) (hsCurrent.hotspotId() == doorHotspot->hotspotId()))
continue; continue;
// Skip entry if it doesn't meet certain criteria // Skip entry if it doesn't meet certain criteria
if ((hsCurrent->layer() == 0) || if ((hsCurrent.layer() == 0) ||
(hsCurrent->roomNumber() != doorHotspot->roomNumber()) || (hsCurrent.roomNumber() != doorHotspot->roomNumber()) ||
(hsCurrent->hotspotId() < PLAYER_ID) || (hsCurrent.hotspotId() < PLAYER_ID) ||
((hsCurrent->hotspotId() >= 0x408) && (hsCurrent->hotspotId() < 0x2710))) ((hsCurrent.hotspotId() >= 0x408) && (hsCurrent.hotspotId() < 0x2710)))
continue; continue;
// Also skip entry if special Id // Also skip entry if special Id
if ((hsCurrent->hotspotId() == 0xfffe) || (hsCurrent->hotspotId() == 0xffff)) if ((hsCurrent.hotspotId() == 0xfffe) || (hsCurrent.hotspotId() == 0xffff))
continue; continue;
// Check to see if the character is intersecting the door area // Check to see if the character is intersecting the door area
int tempY = hsCurrent->y() + hsCurrent->heightCopy(); int tempY = hsCurrent.y() + hsCurrent.heightCopy();
if ((hsCurrent->x() >= bounds.right) || if ((hsCurrent.x() >= bounds.right) ||
(hsCurrent->x() + hsCurrent->widthCopy() <= bounds.left) || (hsCurrent.x() + hsCurrent.widthCopy() <= bounds.left) ||
(tempY + hsCurrent->charRectY() < bounds.top) || (tempY + hsCurrent.charRectY() < bounds.top) ||
(tempY - hsCurrent->yCorrection() - hsCurrent->charRectY() > bounds.bottom)) (tempY - hsCurrent.yCorrection() - hsCurrent.charRectY() > bounds.bottom))
continue; continue;
// At this point we know a character is blocking door, so return false // 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 &list = res.hotspotData();
HotspotDataList::iterator i; HotspotDataList::iterator i;
for (i = list.begin(); i != list.end(); ++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, ": "); if (numItems++ == 0) strcat(buffer, ": ");
else strcat(buffer, ", "); else strcat(buffer, ", ");
strings.getString(rec->nameId, buffer + strlen(buffer)); strings.getString(rec.nameId, buffer + strlen(buffer));
} }
} }
@ -4385,8 +4385,8 @@ Common::String PathFinder::getDebugInfo() const {
WalkingActionList::const_iterator i; WalkingActionList::const_iterator i;
for (i = _list.begin(); i != _list.end(); ++i) { for (i = _list.begin(); i != _list.end(); ++i) {
WalkingActionEntry *e = (*i).get(); WalkingActionEntry const &e = **i;
buffer += Common::String::format("Direction=%d, numSteps=%d\n", e->direction(), e->numSteps()); buffer += Common::String::format("Direction=%d, numSteps=%d\n", e.direction(), e.numSteps());
} }
return buffer; return buffer;
@ -4505,9 +4505,9 @@ void PathFinder::saveToStream(Common::WriteStream *stream) const {
// Save any active step sequence // Save any active step sequence
for (WalkingActionList::const_iterator i = _list.begin(); i != _list.end(); ++i) { for (WalkingActionList::const_iterator i = _list.begin(); i != _list.end(); ++i) {
WalkingActionEntry *entry = (*i).get(); WalkingActionEntry &entry = **i;
stream->writeByte(entry->direction()); stream->writeByte(entry.direction());
stream->writeSint16LE(entry->rawSteps()); stream->writeSint16LE(entry.rawSteps());
} }
stream->writeByte(0xff); stream->writeByte(0xff);
stream->writeSint16LE(_stepCtr); stream->writeSint16LE(_stepCtr);
@ -4684,15 +4684,15 @@ bool Support::isCharacterInList(uint16 *lst, int numEntries, uint16 charId) {
void HotspotList::saveToStream(Common::WriteStream *stream) const { void HotspotList::saveToStream(Common::WriteStream *stream) const {
for (HotspotList::const_iterator i = begin(); i != end(); ++i) { for (HotspotList::const_iterator i = begin(); i != end(); ++i) {
Hotspot *hotspot = (*i).get(); Hotspot const &hotspot = **i;
debugC(ERROR_INTERMEDIATE, kLureDebugAnimations, "Saving hotspot %xh", hotspot->hotspotId()); debugC(ERROR_INTERMEDIATE, kLureDebugAnimations, "Saving hotspot %xh", hotspot.hotspotId());
bool dynamicObject = hotspot->hotspotId() != hotspot->originalId(); bool dynamicObject = hotspot.hotspotId() != hotspot.originalId();
stream->writeUint16LE(hotspot->originalId()); stream->writeUint16LE(hotspot.originalId());
stream->writeByte(dynamicObject); stream->writeByte(dynamicObject);
stream->writeUint16LE(hotspot->destHotspotId()); stream->writeUint16LE(hotspot.destHotspotId());
hotspot->saveToStream(stream); hotspot.saveToStream(stream);
debugC(ERROR_DETAILED, kLureDebugAnimations, "Saved hotspot %xh", hotspot->hotspotId()); debugC(ERROR_DETAILED, kLureDebugAnimations, "Saved hotspot %xh", hotspot.hotspotId());
} }
stream->writeUint16LE(0); stream->writeUint16LE(0);
} }

View file

@ -276,11 +276,11 @@ uint16 PopupMenu::ShowInventory() {
HotspotDataList::iterator i; HotspotDataList::iterator i;
for (i = rsc.hotspotData().begin(); i != rsc.hotspotData().end(); ++i) { for (i = rsc.hotspotData().begin(); i != rsc.hotspotData().end(); ++i) {
HotspotData *hotspot = (*i).get(); HotspotData const &hotspot = **i;
if (hotspot->roomNumber == PLAYER_ID) { if (hotspot.roomNumber == PLAYER_ID) {
idList[itemCtr] = hotspot->hotspotId; idList[itemCtr] = hotspot.hotspotId;
char *hotspotName = itemNames[itemCtr++] = (char *) malloc(MAX_HOTSPOT_NAME_SIZE); 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 // Loop for rooms
for (ir = rooms.begin(); ir != rooms.end(); ++ir) { for (ir = rooms.begin(); ir != rooms.end(); ++ir) {
RoomData *roomData = (*ir).get(); RoomData const &roomData = **ir;
// Pre-condition checks for whether to skip room // 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; 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; continue;
if ((roomData->actions & contextBitflag) == 0) if ((roomData.actions & contextBitflag) == 0)
continue; continue;
// Add room to list of entries to display // Add room to list of entries to display
if (numItems == MAX_NUM_DISPLAY_ITEMS) error("Out of space in ask list"); if (numItems == MAX_NUM_DISPLAY_ITEMS) error("Out of space in ask list");
entryIds[numItems] = roomData->roomNumber; entryIds[numItems] = roomData.roomNumber;
nameIds[numItems] = roomData->roomNumber; nameIds[numItems] = roomData.roomNumber;
entryNames[numItems] = (char *) Memory::alloc(MAX_HOTSPOT_NAME_SIZE); entryNames[numItems] = (char *) Memory::alloc(MAX_HOTSPOT_NAME_SIZE);
strings.getString(roomData->roomNumber, entryNames[numItems]); strings.getString(roomData.roomNumber, entryNames[numItems]);
++numItems; ++numItems;
} }
// Loop for hotspots // Loop for hotspots
for (ih = hotspots.begin(); ih != hotspots.end(); ++ih) { for (ih = hotspots.begin(); ih != hotspots.end(); ++ih) {
HotspotData *hotspot = (*ih).get(); HotspotData const &hotspot = **ih;
if ((hotspot->headerFlags != 15) && if ((hotspot.headerFlags != 15) &&
((hotspot->headerFlags & fields.hdrFlagMask()) == 0)) ((hotspot.headerFlags & fields.hdrFlagMask()) == 0))
continue; 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 // Skip the current hotspot
continue; continue;
// If the hotspot is room specific, skip if the character will not be in the specified room // If the hotspot is room specific, skip if the character will not be in the specified room
if (((hotspot->flags & HOTSPOTFLAG_ROOM_SPECIFIC) != 0) && if (((hotspot.flags & HOTSPOTFLAG_ROOM_SPECIFIC) != 0) &&
(hotspot->roomNumber != roomNumber)) (hotspot.roomNumber != roomNumber))
continue; continue;
// If hotspot does not allow action, then skip it // If hotspot does not allow action, then skip it
if ((hotspot->actions & contextBitflag) == 0) if ((hotspot.actions & contextBitflag) == 0)
continue; continue;
// If a special hotspot Id, then skip displaying // If a special hotspot Id, then skip displaying
if ((hotspot->nameId == 0x17A) || (hotspot->nameId == 0x147)) if ((hotspot.nameId == 0x17A) || (hotspot.nameId == 0x147))
continue; continue;
// Check if the hotspot's name is already used in an already set item // Check if the hotspot's name is already used in an already set item
itemCtr = 0; itemCtr = 0;
while ((itemCtr < numItems) && (nameIds[itemCtr] != hotspot->nameId)) while ((itemCtr < numItems) && (nameIds[itemCtr] != hotspot.nameId))
++itemCtr; ++itemCtr;
if (itemCtr != numItems) if (itemCtr != numItems)
// Item's name is already present - skip hotspot // 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 // Add hotspot to list of entries to display
if (numItems == MAX_NUM_DISPLAY_ITEMS) error("Out of space in ask list"); if (numItems == MAX_NUM_DISPLAY_ITEMS) error("Out of space in ask list");
entryIds[numItems] = hotspot->hotspotId; entryIds[numItems] = hotspot.hotspotId;
nameIds[numItems] = hotspot->nameId; nameIds[numItems] = hotspot.nameId;
entryNames[numItems] = (char *) Memory::alloc(MAX_HOTSPOT_NAME_SIZE); entryNames[numItems] = (char *) Memory::alloc(MAX_HOTSPOT_NAME_SIZE);
strings.getString(hotspot->nameId, entryNames[numItems]); strings.getString(hotspot.nameId, entryNames[numItems]);
++numItems; ++numItems;
} }

View file

@ -677,9 +677,9 @@ void Resources::deactivateHotspot(uint16 hotspotId, bool isDestId) {
HotspotList::iterator i = _activeHotspots.begin(); HotspotList::iterator i = _activeHotspots.begin();
while (i != _activeHotspots.end()) { while (i != _activeHotspots.end()) {
Hotspot *h = (*i).get(); Hotspot const &h = **i;
if ((!isDestId && (h->hotspotId() == hotspotId)) || if ((!isDestId && (h.hotspotId() == hotspotId)) ||
(isDestId && (h->destHotspotId() == hotspotId) && (h->hotspotId() == 0xffff))) { (isDestId && (h.destHotspotId() == hotspotId) && (h.hotspotId() == 0xffff))) {
_activeHotspots.erase(i); _activeHotspots.erase(i);
break; break;
} }
@ -707,8 +707,7 @@ uint16 Resources::numInventoryItems() {
HotspotDataList &list = _hotspotData; HotspotDataList &list = _hotspotData;
HotspotDataList::iterator i; HotspotDataList::iterator i;
for (i = list.begin(); i != list.end(); ++i) { for (i = list.begin(); i != list.end(); ++i) {
HotspotData *rec = (*i).get(); if ((*i)->roomNumber == PLAYER_ID) ++numItems;
if (rec->roomNumber == PLAYER_ID) ++numItems;
} }
return numItems; return numItems;
@ -753,12 +752,12 @@ void Resources::saveToStream(Common::WriteStream *stream) {
// Save out the schedule for any non-active NPCs // Save out the schedule for any non-active NPCs
HotspotDataList::iterator i; HotspotDataList::iterator i;
for (i = _hotspotData.begin(); i != _hotspotData.end(); ++i) { for (i = _hotspotData.begin(); i != _hotspotData.end(); ++i) {
HotspotData *rec = (*i).get(); HotspotData const &rec = **i;
if (!rec->npcSchedule.isEmpty()) { if (!rec.npcSchedule.isEmpty()) {
Hotspot *h = getActiveHotspot(rec->hotspotId); Hotspot *h = getActiveHotspot(rec.hotspotId);
if (h == NULL) { if (h == NULL) {
stream->writeUint16LE(rec->hotspotId); stream->writeUint16LE(rec.hotspotId);
rec->npcSchedule.saveToStream(stream); rec.npcSchedule.saveToStream(stream);
} }
} }
} }

View file

@ -280,9 +280,9 @@ void RoomPathsData::decompress(RoomPathsDecompressedData &dataOut, int character
void RoomDataList::saveToStream(Common::WriteStream *stream) const { void RoomDataList::saveToStream(Common::WriteStream *stream) const {
for (RoomDataList::const_iterator i = begin(); i != end(); ++i) { for (RoomDataList::const_iterator i = begin(); i != end(); ++i) {
RoomData *rec = (*i).get(); RoomData const &rec = **i;
stream->writeByte(rec->flags); stream->writeByte(rec.flags);
const byte *pathData = rec->paths.data(); const byte *pathData = rec.paths.data();
stream->write(pathData, ROOM_PATHS_HEIGHT * ROOM_PATHS_WIDTH); stream->write(pathData, ROOM_PATHS_HEIGHT * ROOM_PATHS_WIDTH);
} }
} }
@ -292,10 +292,10 @@ void RoomDataList::loadFromStream(Common::ReadStream *stream) {
byte data[ROOM_PATHS_HEIGHT * ROOM_PATHS_WIDTH]; byte data[ROOM_PATHS_HEIGHT * ROOM_PATHS_WIDTH];
for (i = begin(); i != end(); ++i) { for (i = begin(); i != end(); ++i) {
RoomData *rec = (*i).get(); RoomData &rec = **i;
rec->flags = stream->readByte(); rec.flags = stream->readByte();
stream->read(data, ROOM_PATHS_HEIGHT * ROOM_PATHS_WIDTH); stream->read(data, ROOM_PATHS_HEIGHT * ROOM_PATHS_WIDTH);
rec->paths.load(data); rec.paths.load(data);
} }
} }
@ -317,15 +317,15 @@ RoomExitJoinData::RoomExitJoinData(RoomExitJoinResource *rec) {
void RoomExitJoinList::saveToStream(Common::WriteStream *stream) const { void RoomExitJoinList::saveToStream(Common::WriteStream *stream) const {
for (RoomExitJoinList::const_iterator i = begin(); i != end(); ++i) { for (RoomExitJoinList::const_iterator i = begin(); i != end(); ++i) {
RoomExitJoinData *rec = (*i).get(); RoomExitJoinData const &rec = **i;
stream->writeUint16LE(rec->hotspots[0].hotspotId); stream->writeUint16LE(rec.hotspots[0].hotspotId);
stream->writeUint16LE(rec->hotspots[1].hotspotId); stream->writeUint16LE(rec.hotspots[1].hotspotId);
stream->writeByte(rec->hotspots[0].currentFrame); stream->writeByte(rec.hotspots[0].currentFrame);
stream->writeByte(rec->hotspots[0].destFrame); stream->writeByte(rec.hotspots[0].destFrame);
stream->writeByte(rec->hotspots[1].currentFrame); stream->writeByte(rec.hotspots[1].currentFrame);
stream->writeByte(rec->hotspots[1].destFrame); stream->writeByte(rec.hotspots[1].destFrame);
stream->writeByte(rec->blocked); stream->writeByte(rec.blocked);
} }
// Write end of list marker // Write end of list marker
@ -334,21 +334,21 @@ void RoomExitJoinList::saveToStream(Common::WriteStream *stream) const {
void RoomExitJoinList::loadFromStream(Common::ReadStream *stream) { void RoomExitJoinList::loadFromStream(Common::ReadStream *stream) {
for (RoomExitJoinList::iterator i = begin(); i != end(); ++i) { for (RoomExitJoinList::iterator i = begin(); i != end(); ++i) {
RoomExitJoinData *rec = (*i).get(); RoomExitJoinData &rec = **i;
uint16 hotspot1Id = stream->readUint16LE(); uint16 hotspot1Id = stream->readUint16LE();
if (hotspot1Id == 0xffff) error("Invalid room exit join list"); if (hotspot1Id == 0xffff) error("Invalid room exit join list");
uint16 hotspot2Id = stream->readUint16LE(); uint16 hotspot2Id = stream->readUint16LE();
if ((rec->hotspots[0].hotspotId != hotspot1Id) || if ((rec.hotspots[0].hotspotId != hotspot1Id) ||
(rec->hotspots[1].hotspotId != hotspot2Id)) (rec.hotspots[1].hotspotId != hotspot2Id))
break; break;
rec->hotspots[0].currentFrame = stream->readByte(); rec.hotspots[0].currentFrame = stream->readByte();
rec->hotspots[0].destFrame = stream->readByte(); rec.hotspots[0].destFrame = stream->readByte();
rec->hotspots[1].currentFrame = stream->readByte(); rec.hotspots[1].currentFrame = stream->readByte();
rec->hotspots[1].destFrame = stream->readByte(); rec.hotspots[1].destFrame = stream->readByte();
rec->blocked = stream->readByte(); rec.blocked = stream->readByte();
} }
// Read final end of list marker // Read final end of list marker
@ -366,8 +366,8 @@ HotspotActionData::HotspotActionData(HotspotActionResource *rec) {
uint16 HotspotActionList::getActionOffset(Action action) { uint16 HotspotActionList::getActionOffset(Action action) {
iterator i; iterator i;
for (i = begin(); i != end(); ++i) { for (i = begin(); i != end(); ++i) {
HotspotActionData *rec = (*i).get(); HotspotActionData const &rec = **i;
if (rec->action == action) return rec->sequenceOffset; if (rec.action == action) return rec.sequenceOffset;
} }
return 0; return 0;
@ -534,9 +534,9 @@ void HotspotData::loadFromStream(Common::ReadStream *stream) {
void HotspotDataList::saveToStream(Common::WriteStream *stream) const { void HotspotDataList::saveToStream(Common::WriteStream *stream) const {
for (const_iterator i = begin(); i != end(); ++i) { for (const_iterator i = begin(); i != end(); ++i) {
HotspotData *hotspot = (*i).get(); HotspotData const &hotspot = **i;
stream->writeUint16LE(hotspot->hotspotId); stream->writeUint16LE(hotspot.hotspotId);
hotspot->saveToStream(stream); hotspot.saveToStream(stream);
} }
stream->writeUint16LE(0); stream->writeUint16LE(0);
} }
@ -579,14 +579,14 @@ bool MovementDataList::getFrame(uint16 currentFrame, int16 &xChange,
iterator i; iterator i;
for (i = begin(); i != end(); ++i) { for (i = begin(); i != end(); ++i) {
MovementData *rec = (*i).get(); MovementData const &rec = **i;
if (foundFlag || (i == begin())) { if (foundFlag || (i == begin())) {
xChange = rec->xChange; xChange = rec.xChange;
yChange = rec->yChange; yChange = rec.yChange;
nextFrame = rec->frameNumber; nextFrame = rec.frameNumber;
if (foundFlag) return true; if (foundFlag) return true;
} }
if (rec->frameNumber == currentFrame) foundFlag = true; if (rec.frameNumber == currentFrame) foundFlag = true;
} }
return true; return true;
@ -698,11 +698,10 @@ TalkEntryData *TalkData::getResponse(int index) {
void TalkDataList::saveToStream(Common::WriteStream *stream) const { void TalkDataList::saveToStream(Common::WriteStream *stream) const {
for (TalkDataList::const_iterator i = begin(); i != end(); ++i) { for (TalkDataList::const_iterator i = begin(); i != end(); ++i) {
TalkData *rec = (*i).get(); TalkData const &rec = **i;
for (TalkEntryList::const_iterator 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((*i2)->descId);
stream->writeUint16LE(entry->descId);
} }
} }
} }
@ -710,11 +709,10 @@ void TalkDataList::saveToStream(Common::WriteStream *stream) const {
void TalkDataList::loadFromStream(Common::ReadStream *stream) { void TalkDataList::loadFromStream(Common::ReadStream *stream) {
TalkDataList::iterator i; TalkDataList::iterator i;
for (i = begin(); i != end(); ++i) { for (i = begin(); i != end(); ++i) {
TalkData *rec = (*i).get(); TalkData const &rec = **i;
for (TalkEntryList::const_iterator 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(); (*i2)->descId = stream->readUint16LE();
entry->descId = stream->readUint16LE();
} }
} }
} }
@ -779,17 +777,17 @@ void SequenceDelayList::tick() {
g_system->getMillis()); g_system->getMillis());
for (i = begin(); i != end(); ++i) { for (i = begin(); i != end(); ++i) {
SequenceDelayData *entry = (*i).get(); SequenceDelayData &entry = **i;
debugC(ERROR_DETAILED, kLureDebugScripts, "Delay List check %xh at time %d", entry->sequenceOffset, entry->timeoutCtr); 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 // Timeout reached - delete entry from list and execute the sequence
uint16 seqOffset = entry->sequenceOffset; uint16 seqOffset = entry.sequenceOffset;
erase(i); erase(i);
Script::execute(seqOffset); Script::execute(seqOffset);
return; return;
} else { } else {
entry->timeoutCtr -= GAME_FRAME_DELAY; entry.timeoutCtr -= GAME_FRAME_DELAY;
} }
} }
} }
@ -798,8 +796,7 @@ void SequenceDelayList::clear(bool forceClear) {
SequenceDelayList::iterator i = begin(); SequenceDelayList::iterator i = begin();
while (i != end()) { while (i != end()) {
SequenceDelayData *entry = (*i).get(); if ((*i)->canClear || forceClear)
if (entry->canClear || forceClear)
i = erase(i); i = erase(i);
else else
++i; ++i;
@ -808,10 +805,10 @@ void SequenceDelayList::clear(bool forceClear) {
void SequenceDelayList::saveToStream(Common::WriteStream *stream) const { void SequenceDelayList::saveToStream(Common::WriteStream *stream) const {
for (SequenceDelayList::const_iterator i = begin(); i != end(); ++i) { for (SequenceDelayList::const_iterator i = begin(); i != end(); ++i) {
SequenceDelayData *entry = (*i).get(); SequenceDelayData const &entry = **i;
stream->writeUint16LE(entry->sequenceOffset); stream->writeUint16LE(entry.sequenceOffset);
stream->writeUint32LE(entry->timeoutCtr); stream->writeUint32LE(entry.timeoutCtr);
stream->writeByte(entry->canClear); stream->writeByte(entry.canClear);
} }
stream->writeUint16LE(0); stream->writeUint16LE(0);
@ -1044,9 +1041,9 @@ RoomExitIndexedHotspotData::RoomExitIndexedHotspotData(RoomExitIndexedHotspotRes
uint16 RoomExitIndexedHotspotList::getHotspot(uint16 roomNumber, uint8 hotspotIndexId) { uint16 RoomExitIndexedHotspotList::getHotspot(uint16 roomNumber, uint8 hotspotIndexId) {
iterator i; iterator i;
for (i = begin(); i != end(); ++i) { for (i = begin(); i != end(); ++i) {
RoomExitIndexedHotspotData *entry = (*i).get(); RoomExitIndexedHotspotData const &entry = **i;
if ((entry->roomNumber == roomNumber) && (entry->hotspotIndex == hotspotIndexId)) if ((entry.roomNumber == roomNumber) && (entry.hotspotIndex == hotspotIndexId))
return entry->hotspotId; return entry.hotspotId;
} }
// No hotspot // No hotspot
@ -1066,12 +1063,12 @@ PausedCharacter::PausedCharacter(uint16 SrcCharId, uint16 DestCharId) {
void PausedCharacterList::reset(uint16 hotspotId) { void PausedCharacterList::reset(uint16 hotspotId) {
iterator i; iterator i;
for (i = begin(); i != end(); ++i) { for (i = begin(); i != end(); ++i) {
PausedCharacter *rec = (*i).get(); PausedCharacter &rec = **i;
if (rec->srcCharId == hotspotId) { if (rec.srcCharId == hotspotId) {
rec->counter = 1; rec.counter = 1;
if (rec->destCharId < START_EXIT_ID) if (rec.destCharId < START_EXIT_ID)
rec->charHotspot->pauseCtr = 1; rec.charHotspot->pauseCtr = 1;
} }
} }
} }
@ -1080,15 +1077,15 @@ void PausedCharacterList::countdown() {
iterator i = begin(); iterator i = begin();
while (i != end()) { while (i != end()) {
PausedCharacter *rec = (*i).get(); PausedCharacter &rec = **i;
--rec->counter; --rec.counter;
// Handle reflecting counter to hotspot // Handle reflecting counter to hotspot
if (rec->destCharId < START_EXIT_ID) if (rec.destCharId < START_EXIT_ID)
rec->charHotspot->pauseCtr = rec->counter + 1; rec.charHotspot->pauseCtr = rec.counter + 1;
// If counter has reached zero, remove entry from list // If counter has reached zero, remove entry from list
if (rec->counter == 0) if (rec.counter == 0)
i = erase(i); i = erase(i);
else else
++i; ++i;
@ -1101,13 +1098,13 @@ void PausedCharacterList::scan(Hotspot &h) {
if (h.blockedState() != BS_NONE) { if (h.blockedState() != BS_NONE) {
for (i = begin(); i != end(); ++i) { for (i = begin(); i != end(); ++i) {
PausedCharacter *rec = (*i).get(); PausedCharacter &rec = **i;
if (rec->srcCharId == h.hotspotId()) { if (rec.srcCharId == h.hotspotId()) {
rec->counter = IDLE_COUNTDOWN_SIZE; rec.counter = IDLE_COUNTDOWN_SIZE;
if (rec->destCharId < START_EXIT_ID) if (rec.destCharId < START_EXIT_ID)
rec->charHotspot->pauseCtr = IDLE_COUNTDOWN_SIZE; rec.charHotspot->pauseCtr = IDLE_COUNTDOWN_SIZE;
} }
} }
} }
@ -1131,9 +1128,9 @@ int PausedCharacterList::check(uint16 charId, int numImpinging, uint16 *impingin
// calling character and the impinging list entry // calling character and the impinging list entry
bool foundEntry = false; bool foundEntry = false;
for (i = res.pausedList().begin(); !foundEntry && (i != res.pausedList().end()); ++i) { for (i = res.pausedList().begin(); !foundEntry && (i != res.pausedList().end()); ++i) {
PausedCharacter *rec = (*i).get(); PausedCharacter const &rec = **i;
foundEntry = (rec->srcCharId == charId) && foundEntry = (rec.srcCharId == charId) &&
(rec->destCharId == hotspot->hotspotId()); (rec.destCharId == hotspot->hotspotId());
} }
if (foundEntry) if (foundEntry)
@ -1435,11 +1432,11 @@ Common::String CurrentActionStack::getDebugInfo() const {
buffer += Common::String::format("CurrentActionStack::list num_actions=%d\n", size()); buffer += Common::String::format("CurrentActionStack::list num_actions=%d\n", size());
for (i = _actions.begin(); i != _actions.end(); ++i) { for (i = _actions.begin(); i != _actions.end(); ++i) {
CurrentActionEntry *entry = (*i).get(); CurrentActionEntry const &entry = **i;
buffer += Common::String::format("style=%d room#=%d", entry->action(), entry->roomNumber()); buffer += Common::String::format("style=%d room#=%d", entry.action(), entry.roomNumber());
if (entry->hasSupportData()) { if (entry.hasSupportData()) {
CharacterScheduleEntry &rec = entry->supportData(); CharacterScheduleEntry &rec = entry.supportData();
buffer += Common::String::format(", action=%d params=", rec.action()); buffer += Common::String::format(", action=%d params=", rec.action());
@ -1464,8 +1461,7 @@ void CurrentActionStack::saveToStream(Common::WriteStream *stream) const {
debugC(ERROR_DETAILED, kLureDebugAnimations, "%s", buffer.c_str()); debugC(ERROR_DETAILED, kLureDebugAnimations, "%s", buffer.c_str());
for (ActionsList::const_iterator i = _actions.begin(); i != _actions.end(); ++i) { for (ActionsList::const_iterator i = _actions.begin(); i != _actions.end(); ++i) {
CurrentActionEntry *rec = (*i).get(); (*i)->saveToStream(stream);
rec->saveToStream(stream);
} }
stream->writeByte(0xff); // End of list marker stream->writeByte(0xff); // End of list marker
debugC(ERROR_DETAILED, kLureDebugAnimations, "Finished saving hotspot action stack"); debugC(ERROR_DETAILED, kLureDebugAnimations, "Finished saving hotspot action stack");

View file

@ -138,8 +138,8 @@ void Room::leaveRoom() {
HotspotList &list = r.activeHotspots(); HotspotList &list = r.activeHotspots();
HotspotList::iterator i = list.begin(); HotspotList::iterator i = list.begin();
while (i != list.end()) { while (i != list.end()) {
Hotspot *h = i->get(); Hotspot const &h = **i;
if (!h->persistant()) { if (!h.persistant()) {
i = list.erase(i); i = list.erase(i);
} else { } else {
++i; ++i;
@ -153,11 +153,11 @@ void Room::loadRoomHotspots() {
HotspotDataList::iterator i; HotspotDataList::iterator i;
for (i = list.begin(); i != list.end(); ++i) { for (i = list.begin(); i != list.end(); ++i) {
HotspotData *rec = (*i).get(); HotspotData const &rec = **i;
if ((rec->hotspotId < 0x7530) && (rec->roomNumber == _roomNumber) && if ((rec.hotspotId < 0x7530) && (rec.roomNumber == _roomNumber) &&
(rec->layer != 0)) (rec.layer != 0))
r.activateHotspot(rec->hotspotId); r.activateHotspot(rec.hotspotId);
} }
} }
@ -252,24 +252,24 @@ CursorType Room::checkRoomExits() {
RoomExitHotspotList::iterator i; RoomExitHotspotList::iterator i;
for (i = exits.begin(); i != exits.end(); ++i) { for (i = exits.begin(); i != exits.end(); ++i) {
RoomExitHotspotData *rec = (*i).get(); RoomExitHotspotData const &rec = **i;
skipFlag = false; skipFlag = false;
if (rec->hotspotId != 0) { if (rec.hotspotId != 0) {
join = res.getExitJoin(rec->hotspotId); join = res.getExitJoin(rec.hotspotId);
if ((join) && (join->blocked != 0)) if ((join) && (join->blocked != 0))
skipFlag = true; skipFlag = true;
} }
if (!skipFlag && (m.x() >= rec->xs) && (m.x() <= rec->xe) && if (!skipFlag && (m.x() >= rec.xs) && (m.x() <= rec.xe) &&
(m.y() >= rec->ys) && (m.y() <= rec->ye)) { (m.y() >= rec.ys) && (m.y() <= rec.ye)) {
// Cursor is within exit area // Cursor is within exit area
CursorType cursorNum = (CursorType)rec->cursorNum; CursorType cursorNum = (CursorType)rec.cursorNum;
_destRoomNumber = rec->destRoomNumber; _destRoomNumber = rec.destRoomNumber;
// If it's a hotspotted exit, change arrow to the + arrow // If it's a hotspotted exit, change arrow to the + arrow
if (rec->hotspotId != 0) { if (rec.hotspotId != 0) {
_hotspotId = rec->hotspotId; _hotspotId = rec.hotspotId;
_hotspot = res.getHotspot(_hotspotId); _hotspot = res.getHotspot(_hotspotId);
_hotspotNameId = _hotspot->nameId; _hotspotNameId = _hotspot->nameId;
_isExit = true; _isExit = true;

View file

@ -107,8 +107,7 @@ void SoundManager::saveToStream(Common::WriteStream *stream) {
SoundListIterator i; SoundListIterator i;
for (i = _activeSounds.begin(); i != _activeSounds.end(); ++i) { for (i = _activeSounds.begin(); i != _activeSounds.end(); ++i) {
SoundDescResource *rec = (*i).get(); stream->writeByte((*i)->soundNumber);
stream->writeByte(rec->soundNumber);
} }
stream->writeByte(0xff); stream->writeByte(0xff);
} }
@ -335,14 +334,14 @@ void SoundManager::tidySounds() {
SoundListIterator i = _activeSounds.begin(); SoundListIterator i = _activeSounds.begin();
while (i != _activeSounds.end()) { 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 // Still playing, so move to next entry
++i; ++i;
else { else {
// Mark the channels that it used as now being free // 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); i = _activeSounds.erase(i);
} }
@ -356,10 +355,10 @@ void SoundManager::removeSounds() {
SoundListIterator i = _activeSounds.begin(); SoundListIterator i = _activeSounds.begin();
while (i != _activeSounds.end()) { while (i != _activeSounds.end()) {
SoundDescResource *rec = (*i).get(); SoundDescResource const &rec = **i;
if ((rec->flags & SF_IN_USE) != 0) if ((rec.flags & SF_IN_USE) != 0)
musicInterface_Stop(rec->soundNumber); musicInterface_Stop(rec.soundNumber);
++i; ++i;
} }
@ -370,13 +369,13 @@ void SoundManager::restoreSounds() {
SoundListIterator i = _activeSounds.begin(); SoundListIterator i = _activeSounds.begin();
while (i != _activeSounds.end()) { while (i != _activeSounds.end()) {
SoundDescResource *rec = (*i).get(); SoundDescResource const &rec = **i;
if ((rec->numChannels != 0) && ((rec->flags & SF_RESTORE) != 0)) { if ((rec.numChannels != 0) && ((rec.flags & SF_RESTORE) != 0)) {
Common::fill(_channelsInUse+rec->channel, _channelsInUse+rec->channel+rec->numChannels, true); Common::fill(_channelsInUse + rec.channel, _channelsInUse + rec.channel + rec.numChannels, true);
musicInterface_Play(rec->soundNumber, rec->channel, rec->numChannels); musicInterface_Play(rec.soundNumber, rec.channel, rec.numChannels);
musicInterface_SetVolume(rec->channel, rec->volume); musicInterface_SetVolume(rec.channel, rec.volume);
} }
++i; ++i;
@ -397,10 +396,10 @@ void SoundManager::fadeOut() {
g_system->lockMutex(_soundMutex); g_system->lockMutex(_soundMutex);
MusicListIterator i; MusicListIterator i;
for (i = _playingSounds.begin(); i != _playingSounds.end(); ++i) { for (i = _playingSounds.begin(); i != _playingSounds.end(); ++i) {
MidiMusic *music = (*i).get(); MidiMusic &music = **i;
if (music->getVolume() > 0) { if (music.getVolume() > 0) {
inProgress = true; 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); g_system->lockMutex(_soundMutex);
MusicListIterator i; MusicListIterator i;
for (i = _playingSounds.begin(); i != _playingSounds.end(); ++i) { for (i = _playingSounds.begin(); i != _playingSounds.end(); ++i) {
MidiMusic *music = (*i).get(); if ((*i)->soundNumber() == soundNum) {
if (music->soundNumber() == soundNum) {
_playingSounds.erase(i); _playingSounds.erase(i);
break; break;
} }
@ -489,8 +487,7 @@ bool SoundManager::musicInterface_CheckPlaying(uint8 soundNumber) {
g_system->lockMutex(_soundMutex); g_system->lockMutex(_soundMutex);
MusicListIterator i; MusicListIterator i;
for (i = _playingSounds.begin(); i != _playingSounds.end(); ++i) { for (i = _playingSounds.begin(); i != _playingSounds.end(); ++i) {
MidiMusic *music = (*i).get(); if ((*i)->soundNumber() == soundNum) {
if (music->soundNumber() == soundNum) {
result = true; result = true;
break; break;
} }
@ -511,9 +508,9 @@ void SoundManager::musicInterface_SetVolume(uint8 channelNum, uint8 volume) {
g_system->lockMutex(_soundMutex); g_system->lockMutex(_soundMutex);
MusicListIterator i; MusicListIterator i;
for (i = _playingSounds.begin(); i != _playingSounds.end(); ++i) { for (i = _playingSounds.begin(); i != _playingSounds.end(); ++i) {
MidiMusic *music = (*i).get(); MidiMusic &music = **i;
if (music->channelNumber() == channelNum) if (music.channelNumber() == channelNum)
music->setVolume(volume); music.setVolume(volume);
} }
g_system->unlockMutex(_soundMutex); g_system->unlockMutex(_soundMutex);
} }
@ -528,8 +525,7 @@ void SoundManager::musicInterface_KillAll() {
g_system->lockMutex(_soundMutex); g_system->lockMutex(_soundMutex);
MusicListIterator i; MusicListIterator i;
for (i = _playingSounds.begin(); i != _playingSounds.end(); ++i) { for (i = _playingSounds.begin(); i != _playingSounds.end(); ++i) {
MidiMusic *music = (*i).get(); (*i)->stopMusic();
music->stopMusic();
} }
_playingSounds.clear(); _playingSounds.clear();
@ -561,8 +557,7 @@ void SoundManager::musicInterface_TidySounds() {
g_system->lockMutex(_soundMutex); g_system->lockMutex(_soundMutex);
MusicListIterator i = _playingSounds.begin(); MusicListIterator i = _playingSounds.begin();
while (i != _playingSounds.end()) { while (i != _playingSounds.end()) {
MidiMusic *music = (*i).get(); if (!(*i)->isPlaying())
if (!music->isPlaying())
i = _playingSounds.erase(i); i = _playingSounds.erase(i);
else else
++i; ++i;
@ -583,9 +578,9 @@ void SoundManager::doTimer() {
MusicListIterator i; MusicListIterator i;
for (i = _playingSounds.begin(); i != _playingSounds.end(); ++i) { for (i = _playingSounds.begin(); i != _playingSounds.end(); ++i) {
MidiMusic *music = (*i).get(); MidiMusic &music = **i;
if (music->isPlaying()) if (music.isPlaying())
music->onTimer(); music.onTimer();
} }
g_system->unlockMutex(_soundMutex); g_system->unlockMutex(_soundMutex);

View file

@ -1329,8 +1329,8 @@ bool CopyProtectionDialog::show() {
++hotspot6; ++hotspot6;
// Add wording header and display screen // Add wording header and display screen
(hotspot2->get())->setFrameNumber(1); (*hotspot2)->setFrameNumber(1);
(hotspot2->get())->copyTo(&screen.screen()); (*hotspot2)->copyTo(&screen.screen());
screen.update(); screen.update();
screen.setPalette(&p); screen.setPalette(&p);
@ -1340,8 +1340,8 @@ bool CopyProtectionDialog::show() {
} while (!events.interruptableDelay(100)); } while (!events.interruptableDelay(100));
// Change title text to selection // Change title text to selection
(hotspot2->get())->setFrameNumber(0); (*hotspot2)->setFrameNumber(0);
(hotspot2->get())->copyTo(&screen.screen()); (*hotspot2)->copyTo(&screen.screen());
screen.update(); screen.update();
// Clear any prior try // Clear any prior try
@ -1356,8 +1356,8 @@ bool CopyProtectionDialog::show() {
HotspotsList::iterator tmpHotspot = _hotspots.begin(); HotspotsList::iterator tmpHotspot = _hotspots.begin();
for (int i = 0; i < _charIndex + 3; i++) for (int i = 0; i < _charIndex + 3; i++)
++tmpHotspot; ++tmpHotspot;
(tmpHotspot->get())->setFrameNumber(10); // Blank space (*tmpHotspot)->setFrameNumber(10); // Blank space
(tmpHotspot->get())->copyTo(&screen.screen()); (*tmpHotspot)->copyTo(&screen.screen());
screen.update(); screen.update();
} else if ((events.event().kbd.keycode >= Common::KEYCODE_0) && } else if ((events.event().kbd.keycode >= Common::KEYCODE_0) &&
@ -1366,8 +1366,8 @@ bool CopyProtectionDialog::show() {
for (int i = 0; i < _charIndex + 3; i++) for (int i = 0; i < _charIndex + 3; i++)
++tmpHotspot; ++tmpHotspot;
// Number pressed // Number pressed
(tmpHotspot->get())->setFrameNumber(events.event().kbd.ascii - '0'); (*tmpHotspot)->setFrameNumber(events.event().kbd.ascii - '0');
(tmpHotspot->get())->copyTo(&screen.screen()); (*tmpHotspot)->copyTo(&screen.screen());
++_charIndex; ++_charIndex;
} }
@ -1385,11 +1385,11 @@ bool CopyProtectionDialog::show() {
return false; return false;
// At this point, two page numbers have been entered - validate them // At this point, two page numbers have been entered - validate them
int page1 = ((hotspot3->get())->frameNumber() * 10) + (hotspot4->get())->frameNumber(); int page1 = ((*hotspot3)->frameNumber() * 10) + (*hotspot4)->frameNumber();
int page2 = ((hotspot5->get())->frameNumber() * 10) + (hotspot6->get())->frameNumber(); int page2 = ((*hotspot5)->frameNumber() * 10) + (*hotspot6)->frameNumber();
if ((page1 == pageNumbers[(hotspot0->get())->frameNumber()]) && if ((page1 == pageNumbers[(*hotspot0)->frameNumber()]) &&
(page2 == pageNumbers[(hotspot1->get())->frameNumber()])) (page2 == pageNumbers[(*hotspot1)->frameNumber()]))
return true; return true;
} }
@ -1404,11 +1404,11 @@ void CopyProtectionDialog::chooseCharacters() {
int char2 = rnd.getRandomNumber(19); int char2 = rnd.getRandomNumber(19);
HotspotsList::iterator curHotspot = _hotspots.begin(); HotspotsList::iterator curHotspot = _hotspots.begin();
(curHotspot->get())->setFrameNumber(char1); (*curHotspot)->setFrameNumber(char1);
(curHotspot->get())->copyTo(&screen.screen()); (*curHotspot)->copyTo(&screen.screen());
++curHotspot; ++curHotspot;
(curHotspot->get())->setFrameNumber(char2); (*curHotspot)->setFrameNumber(char2);
(curHotspot->get())->copyTo(&screen.screen()); (*curHotspot)->copyTo(&screen.screen());
screen.update(); screen.update();
} }

View file

@ -200,9 +200,8 @@ void Debugger::enter() {
bool Debugger::handleCommand(int argc, const char **argv, bool &result) { bool Debugger::handleCommand(int argc, const char **argv, bool &result) {
if (_cmds.contains(argv[0])) { if (_cmds.contains(argv[0])) {
Debuglet *debuglet = _cmds[argv[0]].get(); assert(_cmds[argv[0]]);
assert(debuglet); result = (*_cmds[argv[0]])(argc, argv);
result = (*debuglet)(argc, argv);
return true; return true;
} }