diff --git a/data/scripts/actions/objects/cask_and_kegs.lua b/data/scripts/actions/objects/cask_and_kegs.lua index 1180257e..6eeb4b6f 100644 --- a/data/scripts/actions/objects/cask_and_kegs.lua +++ b/data/scripts/actions/objects/cask_and_kegs.lua @@ -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 diff --git a/src/items/tile.cpp b/src/items/tile.cpp index 6c980345..7be7a3ed 100644 --- a/src/items/tile.cpp +++ b/src/items/tile.cpp @@ -1888,11 +1888,25 @@ std::shared_ptr Tile::getUseItem(int32_t index) const { return ground; } - if (const auto &thing = getThing(index)) { - return thing->getItem(); + if (index >= 0 && index < static_cast(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 Tile::getDoorItem() const {