diff options
Diffstat (limited to 'engines/adl/adl_v2.cpp')
-rw-r--r-- | engines/adl/adl_v2.cpp | 75 |
1 files changed, 38 insertions, 37 deletions
diff --git a/engines/adl/adl_v2.cpp b/engines/adl/adl_v2.cpp index 45810d64ca..c3e82117d8 100644 --- a/engines/adl/adl_v2.cpp +++ b/engines/adl/adl_v2.cpp @@ -245,6 +245,8 @@ void AdlEngine_v2::loadRoom(byte roomNr) { stream->seek(commandOffset); readCommands(*stream, _roomData.commands); } + + applyRoomWorkarounds(roomNr); } void AdlEngine_v2::showRoom() { @@ -286,32 +288,34 @@ void AdlEngine_v2::showRoom() { _linesPrinted = 0; } +// TODO: Merge this into AdlEngine? void AdlEngine_v2::takeItem(byte noun) { Common::List<Item>::iterator item; for (item = _state.items.begin(); item != _state.items.end(); ++item) { - if (item->noun != noun || item->room != _state.room) - continue; - - if (item->state == IDI_ITEM_DOESNT_MOVE) { - printMessage(_messageIds.itemDoesntMove); - return; - } - - if (item->state == IDI_ITEM_DROPPED) { - item->room = IDI_ANY; - _itemRemoved = true; - return; - } + if (item->noun == noun && item->room == _state.room && item->region == _state.region) { + if (item->state == IDI_ITEM_DOESNT_MOVE) { + printMessage(_messageIds.itemDoesntMove); + return; + } - Common::Array<byte>::const_iterator pic; - for (pic = item->roomPictures.begin(); pic != item->roomPictures.end(); ++pic) { - if (*pic == getCurRoom().curPicture || *pic == IDI_ANY) { + if (item->state == IDI_ITEM_DROPPED) { item->room = IDI_ANY; _itemRemoved = true; - item->state = IDI_ITEM_DROPPED; return; } + + Common::Array<byte>::const_iterator pic; + for (pic = item->roomPictures.begin(); pic != item->roomPictures.end(); ++pic) { + if (*pic == getCurRoom().curPicture || *pic == IDI_ANY) { + if (!isInventoryFull()) { + item->room = IDI_ANY; + _itemRemoved = true; + item->state = IDI_ITEM_DROPPED; + } + return; + } + } } } @@ -323,24 +327,20 @@ void AdlEngine_v2::drawItems() { for (item = _state.items.begin(); item != _state.items.end(); ++item) { // Skip items not in this room - if (item->room != _state.room) - continue; - - if (item->isOnScreen) - continue; - - if (item->state == IDI_ITEM_DROPPED) { - // Draw dropped item if in normal view - if (getCurRoom().picture == getCurRoom().curPicture) - drawItem(*item, _itemOffsets[_itemsOnScreen++]); - } else { - // Draw fixed item if current view is in the pic list - Common::Array<byte>::const_iterator pic; - - for (pic = item->roomPictures.begin(); pic != item->roomPictures.end(); ++pic) { - if (*pic == _state.curPicture || *pic == IDI_ANY) { - drawItem(*item, item->position); - break; + if (item->region == _state.region && item->room == _state.room && !item->isOnScreen) { + if (item->state == IDI_ITEM_DROPPED) { + // Draw dropped item if in normal view + if (getCurRoom().picture == getCurRoom().curPicture) + drawItem(*item, _itemOffsets[_itemsOnScreen++]); + } else { + // Draw fixed item if current view is in the pic list + Common::Array<byte>::const_iterator pic; + + for (pic = item->roomPictures.begin(); pic != item->roomPictures.end(); ++pic) { + if (*pic == _state.curPicture || *pic == IDI_ANY) { + drawItem(*item, item->position); + break; + } } } } @@ -367,12 +367,13 @@ DataBlockPtr AdlEngine_v2::readDataBlockPtr(Common::ReadStream &f) const { void AdlEngine_v2::loadItems(Common::ReadStream &stream) { byte id; while ((id = stream.readByte()) != 0xff && !stream.eos() && !stream.err()) { - Item item = Item(); + Item item; + item.id = id; item.noun = stream.readByte(); item.room = stream.readByte(); item.picture = stream.readByte(); - item.isLineArt = stream.readByte(); // Disk number in later games + item.region = stream.readByte(); item.position.x = stream.readByte(); item.position.y = stream.readByte(); item.state = stream.readByte(); |