Proper fix for autowalk lag issue

master
BeniS 11 years ago
parent 725a16e38e
commit adc01ab9e3

@ -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)

@ -561,6 +561,20 @@ std::tuple<std::vector<Otc::Direction>, 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<Position, Node*, PositionHasher> nodes;
std::priority_queue<Node*, std::vector<Node*>, LessNode> searchList;

Loading…
Cancel
Save