diff --git a/MapUtils.lua b/MapUtils.lua
index cc68db7..e87063f 100644
--- a/MapUtils.lua
+++ b/MapUtils.lua
@@ -46,7 +46,7 @@ function addon:GetVector(sm, sf, sx, sy, dm, df, dx, dy)
end
elseif astrolabe then
local dist, xd, yd = astrolabe:ComputeDistance(sm, sf, sx, sy, dm, df, dx, dy)
- local angle = GetDirection(xd, yd)
+ local angle = getDirection(xd, yd)
if dist and angle then
return dist, angle
end
@@ -58,7 +58,7 @@ function addon:GetVector(sm, sf, sx, sy, dm, df, dx, dy)
if mapdata then
local dist, xd, yd = mapdata:DistanceWithinContinent(sm, sf, sx, sy, dm, df, dx, dy)
- local angle = GetDirection(xd, yd)
+ local angle = getDirection(xd, yd)
if dist and angle then
return dist, angle
end
@@ -83,6 +83,7 @@ function addon:GetPlayerPosition()
local x, y = GetPlayerMapPosition("player")
if x and y and x > 0 and y > 0 then
local map, floor = GetCurrentMapAreaID()
+ floor = floor or self:GetDefaultFloor(map)
return map, floor, x, y
end
@@ -105,6 +106,7 @@ function addon:GetPlayerPosition()
-- Fetch the map and floor and return the information that we have
local map, floor = GetCurrentMapAreaID()
+ floor = floor or self:GetDefaultFloor(map)
return map, floor, x, y
end
@@ -114,7 +116,7 @@ end
function addon:GetVectorFromCurrent(map, floor, x, y)
local cmap, cfloor, cx, cy = self:GetPlayerPosition()
- if map and floor and x and y then
+ if cmap and cx and cy and map and x and y then
return self:GetVector(cmap, cfloor, cx, cy, map, floor, x, y)
end
end
@@ -175,3 +177,8 @@ function addon:GetNumMapFloors(map)
return floors
end
end
+
+function addon:GetDefaultFloor(map)
+ local floors = self:GetNumMapFloors(map)
+ return floors == 0 and 0 or 1
+end
diff --git a/TomTomLite.lua b/TomTomLite.lua
index 37cb0d7..705ae1a 100644
--- a/TomTomLite.lua
+++ b/TomTomLite.lua
@@ -96,6 +96,11 @@ function addon:CreateCrazyArrow(name, parent)
local map, floor, x, y = unpack(self.waypoint)
local distance, angle = addon:GetVectorFromCurrent(map, floor, x, y)
+ -- Bail out if we don't know what to do!
+ if not distance or not angle then
+ return
+ end
+
local facing = GetPlayerFacing()
local faceangle = angle - facing
@@ -216,7 +221,7 @@ function addon:AddWaypoint(map, floor, x, y, opt)
assert(type(y) == "number")
if floor == nil then
- floor = addon:GetNumMapFloors(map)
+ floor = addon:GetDefaultFloor(map)
end
local waypoint = {map, floor, x, y}
@@ -255,12 +260,12 @@ end
-------------------------------------------------------------------------]]--
function addon:TOMTOMLITE_WAYPOINT_ADDED(msg, waypoint, ...)
self:FireMessage("TOMTOMLITE_WAYPOINTS_CHANGED")
- self:Printf("Waypoint '%s' added at %.2f, %.2f", waypoint.title, waypoint[3], waypoint[4])
+ --self:Printf("Waypoint '%s' added at %.2f, %.2f", waypoint.title, waypoint[3], waypoint[4])
end
function addon:TOMTOMLITE_WAYPOINT_DELETED(msg, waypoint, ...)
self:FireMessage("TOMTOMLITE_WAYPOINTS_CHANGED")
- self:Printf("Waypoint '%s' REMOVED at %.2f, %.2f", waypoint.title, waypoint[3], waypoint[4])
+ --self:Printf("Waypoint '%s' REMOVED at %.2f, %.2f", waypoint.title, waypoint[3], waypoint[4])
end
function addon:TOMTOMLITE_WAYPOINTS_CHANGED(msg, ...)