Skip to content

Commit

Permalink
Fix usage items under player (#4758)
Browse files Browse the repository at this point in the history
* fix usage items under player

* Zbizu update

* Revert "Zbizu update"

This reverts commit fa16c68.

* update
  • Loading branch information
ArturKnopik authored Oct 6, 2024
1 parent 2444655 commit b99b9fd
Showing 1 changed file with 21 additions and 2 deletions.
23 changes: 21 additions & 2 deletions src/tile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1605,13 +1605,32 @@ bool Tile::isMoveableBlocking() const { return !ground || hasFlag(TILESTATE_BLOC
Item* Tile::getUseItem(int32_t index) const
{
const TileItemVector* items = getItemList();

// no items, get ground
if (!items || items->size() == 0) {
return ground;
}

// try getting thing by index
if (Thing* thing = getThing(index)) {
return thing->getItem();
Item* thingItem = thing->getItem();
if (thingItem) {
return thingItem;
}
}

return nullptr;
// try getting top movable item
Item* topDownItem = getTopDownItem();
if (topDownItem) {
return topDownItem;
}

// try getting door
for (auto it = items->rbegin(), end = items->rend(); it != end; ++it) {
if ((*it)->getDoor()) {
return (*it)->getItem();
}
}

return *items->begin();
}

0 comments on commit b99b9fd

Please sign in to comment.