Skip to content

Commit

Permalink
* Fix item usage under players and doors
Browse files Browse the repository at this point in the history
  • Loading branch information
jprzimba committed Jan 12, 2025
1 parent 42bc023 commit cef8e10
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
2 changes: 1 addition & 1 deletion data/scripts/actions/objects/cask_and_kegs.lua
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ local targetIdList = {
local flasks = Action()

function flasks.onUse(player, item, fromPosition, target, toPosition, isHotkey)
if not target or not target:getItem() then
if not target or not target:isItem() then
return false
end

Expand Down
20 changes: 17 additions & 3 deletions src/items/tile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1888,11 +1888,25 @@ std::shared_ptr<Item> Tile::getUseItem(int32_t index) const {
return ground;
}

if (const auto &thing = getThing(index)) {
return thing->getItem();
if (index >= 0 && index < static_cast<int32_t>(items->size())) {
if (const auto &thing = getThing(index)) {
if (auto thingItem = thing->getItem()) {
return thingItem;
}
}
}

return nullptr;
if (auto topDownItem = getTopDownItem()) {
return topDownItem;
}

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

return !items->empty() ? *items->begin() : nullptr;
}

std::shared_ptr<Item> Tile::getDoorItem() const {
Expand Down

0 comments on commit cef8e10

Please sign in to comment.