Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Game::useWith improper behavior #877

Open
rookgaard opened this issue Oct 24, 2017 · 3 comments
Open

Game::useWith improper behavior #877

rookgaard opened this issue Oct 24, 2017 · 3 comments
Labels

Comments

@rookgaard
Copy link

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

  1. Create ground tile, border item and nature item on one tile.
  2. 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.

@Zolias
Copy link

Zolias commented Nov 26, 2017

I found the same issue when trying to lock a open, unlocked door. When using the key with the door the client will "target" the ground below the open door instead which obviously does not work. Have you found any downsides to your solution so far or would you say it's save to use?

@bpawel10
Copy link

Probably a duplicate of #644

@iryont iryont added the Rework label Feb 17, 2019
@vfjpl
Copy link
Contributor

vfjpl commented Mar 16, 2021

Can you check #1113 ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants