-
Notifications
You must be signed in to change notification settings - Fork 406
Description
Hello. Having on map ground tile (for example dirt ID:351), border (for example grass ID:4543) and nature item (for example frostbite herb ID:7261) and when using on tile kitchen knife or any other item which have "use with" option, returns border item instead item on top of tile.
Steps to reproduce
- Create ground tile, border item and nature item on one tile.
- Use on that tile kitchen knife or any other item with "use with" option.
Expected behaviour
Item is used on nature item which is on top of a tile.
Actual behaviour
Item is used on border item which isn't on top of a tile.
Environment
Bug exists on master branch, tested with TFS and compiled OTClient from latest sources.
Trying to find the problem by myself I have found that using one item on another triggers g_game.useWith(selectedThing, tile:getTopMultiUseThing())
from https://github.com/edubart/otclient/blob/master/modules/game_interface/gameinterface.lua#L368 while ThingPtr Tile::getTopMultiUseThing()
from https://github.com/edubart/otclient/blob/master/src/client/tile.cpp#L475 iterates by tile things from stackpos 0 up to end of items. When iterating, border item matches !thing->isGround() && !thing->isOnTop()
from https://github.com/edubart/otclient/blob/master/src/client/tile.cpp#L500 returning that thing, not checking rest of items on tile.
My workaround was to reverse loop in that way
for(uint i = m_things.size(); i > 0; --i) {
ThingPtr thing = m_things[i - 1];
if(!thing->isGround() && !thing->isOnTop())
return thing;
}
which solved my issue, but I'm not sure if it won't break anything else, that's why I'm creating this issue.