diff --git a/modules/game_interface/widgets/uigamemap.lua b/modules/game_interface/widgets/uigamemap.lua index 2add9395..6b24b611 100644 --- a/modules/game_interface/widgets/uigamemap.lua +++ b/modules/game_interface/widgets/uigamemap.lua @@ -65,6 +65,14 @@ function UIGameMap:onMouseRelease(mousePosition, mouseButton) -- happens when clicking outside of map boundaries if not autoWalkPos then return false end + + local localPlayerPos = g_game.getLocalPlayer():getPosition() + if autoWalkPos.z ~= localPlayerPos.z then + local dz = autoWalkPos.z - localPlayerPos.z + autoWalkPos.x = autoWalkPos.x + dz + autoWalkPos.y = autoWalkPos.y + dz + autoWalkPos.z = localPlayerPos.z + end local lookThing local useThing @@ -76,18 +84,6 @@ function UIGameMap:onMouseRelease(mousePosition, mouseButton) lookThing = tile:getTopLookThing() useThing = tile:getTopUseThing() creatureThing = tile:getTopCreature() - - if tile:isWalkable() then - local localPlayerPos = g_game.getLocalPlayer():getPosition() - if autoWalkPos.z ~= localPlayerPos.z then - local dz = autoWalkPos.z - localPlayerPos.z - autoWalkPos.x = autoWalkPos.x + dz - autoWalkPos.y = autoWalkPos.y + dz - autoWalkPos.z = localPlayerPos.z - end - else - autoWalkPos = nil - end end local ret = modules.game_interface.processMouseAction(mousePosition, mouseButton, autoWalkPos, lookThing, useThing, creatureThing) diff --git a/src/client/map.cpp b/src/client/map.cpp index 533b6677..3aa4f9fc 100644 --- a/src/client/map.cpp +++ b/src/client/map.cpp @@ -561,6 +561,20 @@ std::tuple, Otc::PathFindResult> Map::findPath(const return ret; } + // check the goal pos is walkable + if(g_map.isAwareOfPosition(goalPos)) { + const TilePtr goalTile = getTile(goalPos); + if(!goalTile || !goalTile->isWalkable()) { + return ret; + } + } + else { + const MinimapTile& goalTile = g_minimap.getTile(goalPos); + if(goalTile.hasFlag(MinimapTileNotWalkable)) { + return ret; + } + } + std::unordered_map nodes; std::priority_queue, LessNode> searchList;