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:
BeniS 2013-02-13 15:06:22 +13:00
parent 0b29a4b466
commit 725a16e38e
2 changed files with 13 additions and 8 deletions

View File

@ -66,14 +66,6 @@ function UIGameMap:onMouseRelease(mousePosition, mouseButton)
-- happens when clicking outside of map boundaries -- happens when clicking outside of map boundaries
if not autoWalkPos then return false end 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 lookThing
local useThing local useThing
local creatureThing local creatureThing
@ -84,6 +76,18 @@ function UIGameMap:onMouseRelease(mousePosition, mouseButton)
lookThing = tile:getTopLookThing() lookThing = tile:getTopLookThing()
useThing = tile:getTopUseThing() useThing = tile:getTopUseThing()
creatureThing = tile:getTopCreature() 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 end
local ret = modules.game_interface.processMouseAction(mousePosition, mouseButton, autoWalkPos, lookThing, useThing, creatureThing) local ret = modules.game_interface.processMouseAction(mousePosition, mouseButton, autoWalkPos, lookThing, useThing, creatureThing)

View File

@ -515,6 +515,7 @@ void Client::registerLuaFunctions()
g_lua.bindClassMemberFunction<Tile>("hasCreature", &Tile::hasCreature); g_lua.bindClassMemberFunction<Tile>("hasCreature", &Tile::hasCreature);
g_lua.bindClassMemberFunction<Tile>("isEmpty", &Tile::isEmpty); g_lua.bindClassMemberFunction<Tile>("isEmpty", &Tile::isEmpty);
g_lua.bindClassMemberFunction<Tile>("isClickable", &Tile::isClickable); g_lua.bindClassMemberFunction<Tile>("isClickable", &Tile::isClickable);
g_lua.bindClassMemberFunction<Tile>("isPathable", &Tile::isPathable);
g_lua.bindClassMemberFunction<Tile>("overwriteMinimapColor", &Tile::overwriteMinimapColor); g_lua.bindClassMemberFunction<Tile>("overwriteMinimapColor", &Tile::overwriteMinimapColor);
g_lua.registerClass<UIItem, UIWidget>(); g_lua.registerClass<UIItem, UIWidget>();