mirror of
https://github.com/edubart/otclient.git
synced 2025-10-14 19:44:54 +02:00
Fix a lag issue with auto walking
* Auto walking on unwalkable objects was still being processed by the findPath algorithm. Ed, if this algorithm shouldn't be causing lag spikes for the client, perhaps I should find the cause in findPath. For now this will fix the issue however.
This commit is contained in:
@@ -66,14 +66,6 @@ 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
|
||||
local creatureThing
|
||||
@@ -84,6 +76,18 @@ 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)
|
||||
|
Reference in New Issue
Block a user