Quantcast

* Fix an error when calling /wayb in a non-zoned area

James Whitehead II [01-12-09 - 17:43]
* Fix an error when calling /wayb in a non-zoned area
* Add uid = TomTom:GetClosestWaypoint()
* Altered the behavior of "Clear Waypoint" when interacting with "Automatically set closest waypoint".  When you clear a waypoint, if the 'closest' waypoint is the waypoint you cleared it will not be set
Filename
TomTom.lua
TomTom_CrazyArrow.lua
diff --git a/TomTom.lua b/TomTom.lua
index ab6c2e2..edf2cc1 100755
--- a/TomTom.lua
+++ b/TomTom.lua
@@ -743,6 +743,10 @@ function TomTom:AddZWaypoint(c, z, x, y, desc, persistent, minimap, world, custo
 	local coord = self:GetCoord(x / 100, y / 100)
 	local zone = self:GetMapFile(c, z)

+	if not zone then
+		return
+	end
+
 	-- Ensure there isn't already a waypoint at this location
 	if waypoints[zone] then
 		for uid in pairs(waypoints[zone]) do
@@ -921,7 +925,7 @@ for cidx,c in ipairs{GetMapContinents()} do
 	end
 end

-function TomTom:SetClosestWaypoint()
+function TomTom:GetClosestWaypoint()
 	local c,z,x,y = Astrolabe:GetCurrentPlayerPosition()
 	local zone = TomTom:GetMapFile(c, z)
 	local closest_uid = nil
@@ -936,8 +940,15 @@ function TomTom:SetClosestWaypoint()
 		end
 	end
 	if closest_dist then
-		local data = waypoints[closest_uid]
-		TomTom:SetCrazyArrow(closest_uid, TomTom.profile.arrow.arrival, data.title)
+		return closest_uid
+	end
+end
+
+function TomTom:SetClosestWaypoint()
+	local uid = self:GetClosestWaypoint()
+	if uid then
+		local data = waypoints[uid]
+		TomTom:SetCrazyArrow(uid, TomTom.profile.arrow.arrival, data.title)
 	end
 end

diff --git a/TomTom_CrazyArrow.lua b/TomTom_CrazyArrow.lua
index 8ca2606..b985cd8 100644
--- a/TomTom_CrazyArrow.lua
+++ b/TomTom_CrazyArrow.lua
@@ -297,10 +297,15 @@ local dropdown_info = {
 			-- Clear waypoint from crazy arrow
 			text = L["Clear waypoint from crazy arrow"],
 			func = function()
+				local prior = active_point
+
 				active_point = nil
 				if TomTom.profile.arrow.setclosest then
-					TomTom:SetClosestWaypoint()
-					return
+					local uid = TomTom:GetClosestWaypoint()
+					if uid and uid ~= prior then
+						TomTom:SetClosestWaypoint()
+						return
+					end
 				end
 			end,
 		},