Forgottenserver: onStepOut not passing correct position

Created on 10 May 2019  路  5Comments  路  Source: otland/forgottenserver

Before creating an issue, please ensure:

  • [x] This is a bug in the software that resides in this repository, and not a
    support matter (use https://otland.net/forums/support.16/ for support)
  • [x] This issue is reproducible without changes to the code in this repository

Steps to reproduce (include any configuration/script required to reproduce)

function onStepOut(creature, item, position, fromPosition)

local toPositionTile = Tile(position):getGround()

local fromPositionTile = Tile(fromPosition):getGround()

print(toPositionTile.itemid)

print(fromPositionTile.itemid)

print(position == fromPosition)

end

Expected behaviour

The values should be different if the origin and destination tiles are different.

Actual behaviour

The values are the same even if origin and destination tiles are different .

Environment

Latest commits.

Most helpful comment

It's actually missleading, if you see it for real onStepOut is rather an onSteppedOut that's why I still think that the missleading fromPosition should be renamed to nextPosition and pushes the according position to it, as I did in #2589

All 5 comments

The same logic is used for both stepIn and stepOut, but it seems this doesn't work for stepOut:

    LuaScriptInterface::pushPosition(L, pos);
    LuaScriptInterface::pushPosition(L, creature->getLastPosition());

The pos end up being the same.

Tagging @EvilHero90 as he has some recent experience with movements due to revscriptsys.

I think this problem has already been asked a while around aswell.
The problem is that in Tile::postRemoveNotification we push the tile the player is standing on right now -> g_moveEvents->onCreatureMove(creature, this, MOVE_EVENT_STEP_OUT); this <- is the tile.
So when we try to get the const Position& pos = tile->getPosition(); in uint32_t MoveEvents::onCreatureMove then it gives us the tile we are moving away from, so fromPosition and position are equal.
Edit: fixed in #2587

Fix commit had some issues and got reverted, this Lua change in the steps to reproduce might be a workaround?

function onStepOut(creature, item, position, fromPosition)
    local toPositionTile = Tile(creature:getPosition()):getGround()
    local fromPositionTile = Tile(position):getGround()
    print(toPositionTile.itemid)
    print(fromPositionTile.itemid)
    print(creature:getPosition() == position)
end

It's actually missleading, if you see it for real onStepOut is rather an onSteppedOut that's why I still think that the missleading fromPosition should be renamed to nextPosition and pushes the according position to it, as I did in #2589

Was this page helpful?
0 / 5 - 0 ratings

Related issues

EPuncker picture EPuncker  路  3Comments

marksamman picture marksamman  路  3Comments

souzajunior picture souzajunior  路  4Comments

EPuncker picture EPuncker  路  5Comments

Imperians picture Imperians  路  4Comments