From 725a16e38e68be8342f3733fe399fc106dcc94ef Mon Sep 17 00:00:00 2001 From: BeniS Date: Wed, 13 Feb 2013 15:06:22 +1300 Subject: [PATCH] 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. --- modules/game_interface/widgets/uigamemap.lua | 20 ++++++++++++-------- src/client/luafunctions.cpp | 1 + 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/modules/game_interface/widgets/uigamemap.lua b/modules/game_interface/widgets/uigamemap.lua index 6f490aab..2add9395 100644 --- a/modules/game_interface/widgets/uigamemap.lua +++ b/modules/game_interface/widgets/uigamemap.lua @@ -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) diff --git a/src/client/luafunctions.cpp b/src/client/luafunctions.cpp index 25b51356..390c4c38 100644 --- a/src/client/luafunctions.cpp +++ b/src/client/luafunctions.cpp @@ -515,6 +515,7 @@ void Client::registerLuaFunctions() g_lua.bindClassMemberFunction("hasCreature", &Tile::hasCreature); g_lua.bindClassMemberFunction("isEmpty", &Tile::isEmpty); g_lua.bindClassMemberFunction("isClickable", &Tile::isClickable); + g_lua.bindClassMemberFunction("isPathable", &Tile::isPathable); g_lua.bindClassMemberFunction("overwriteMinimapColor", &Tile::overwriteMinimapColor); g_lua.registerClass();