From 7ad8efa7e1bed2ccc2254630ad3622cb213e4551 Mon Sep 17 00:00:00 2001 From: James Whitehead II Date: Tue, 23 Oct 2012 21:03:39 +0200 Subject: [PATCH] Fix a bug with distance callbacks If the player is within the distance callback circle when the waypoint is first set, the last parameter of the callback should be nil. This enables the callbacks to ignore the initial trigger of the callback. Practically, this stops /wayb from being immediately cleared. --- TomTom.lua | 3 ++- TomTom_Waypoints.lua | 4 ++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/TomTom.lua b/TomTom.lua index c4c0bfa..686700c 100755 --- a/TomTom.lua +++ b/TomTom.lua @@ -718,7 +718,8 @@ local function _both_tooltip_update(event, tooltip, uid, dist) end local function _both_clear_distance(event, uid, range, distance, lastdistance) - if not UnitOnTaxi("player") then + -- Only clear the waypoint if we weren't inside it when it was set + if lastdistance and not UnitOnTaxi("player") then TomTom:RemoveWaypoint(uid) end end diff --git a/TomTom_Waypoints.lua b/TomTom_Waypoints.lua index f8a72d4..e013209 100755 --- a/TomTom_Waypoints.lua +++ b/TomTom_Waypoints.lua @@ -150,6 +150,10 @@ function TomTom:SetWaypoint(waypoint, callbacks, show_minimap, show_world) table.sort(point.dlist) end + -- Clear the state for callbacks + point.state = nil + point.lastdist = nil + -- Link the actual frames back to the waypoint object point.minimap.point = point point.worldmap.point = point -- 1.7.9.5