Fix a bug with distance callbacks
James Whitehead II [10-23-12 - 19:03]
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.
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