Quantcast

Fix an error when setting archeo waypoints

James Whitehead II [10-21-12 - 18:39]
Fix an error when setting archeo waypoints

Also ensures that pandaria continent lookup work properly.
Filename
MapUtils.lua
libs/LibMapData-1.0/library.lua
sources/ArchaeologyDigSites.lua
diff --git a/MapUtils.lua b/MapUtils.lua
index 23cced8..cd8ef14 100644
--- a/MapUtils.lua
+++ b/MapUtils.lua
@@ -142,6 +142,7 @@ local continents = {
     [466] = 3,                   -- Outland (3)
     [485] = 4,                   -- Northrend (4)
     [751] = 5,                   -- Maelstrom (5)
+	[862] = 6, 					 -- Pandaria (6)

     -- Map from continentIndex to mapId
     [1] = 13,                    -- Kalimdor (13)
@@ -149,6 +150,7 @@ local continents = {
     [3] = 466,                   -- Outland (466)
     [4] = 485,                   -- Northrend (485)
     [5] = 751,                   -- Maelstrom (751)
+	[6] = 862,                   -- Pandaria (862)
 }

 -- Returns if a given map file is a continent map
diff --git a/libs/LibMapData-1.0/library.lua b/libs/LibMapData-1.0/library.lua
index a3272bf..ad2a636 100644
--- a/libs/LibMapData-1.0/library.lua
+++ b/libs/LibMapData-1.0/library.lua
@@ -2,7 +2,7 @@
 	Library contains a dataset for Map file names and floors giving the raw map data
 	it also has a few functions to help determine distance and directions.
 --]]
-local MAJOR, MINOR = "LibMapData-1.0", tonumber("108") or 999
+local MAJOR, MINOR = "LibMapData-1.0", 16057
 assert(LibStub, MAJOR.." requires LibStub")

 local lib = LibStub:NewLibrary(MAJOR, MINOR)
@@ -57,7 +57,7 @@ local transforms_x = {
 	[3] = 0,
 	[4] = 0,
 	[5] = 0,
-	[6] = 0,
+	[6] = 0, --1600,
 }
 local transforms_y = {
 	[1] = 17600.0,
@@ -65,7 +65,7 @@ local transforms_y = {
 	[3] = 0,
 	[4] = 0,
 	[5] = 0,
-	[6] = 0,
+	[6] = 0, --2800,
 }

 do
@@ -80,7 +80,7 @@ do
 	setmetatable(mapData, { __index = function(t, k)
 			if k then
 				if missingCache.data[k] == nil then
-					DEFAULT_CHAT_FRAME:AddMessage("LibMapData-1.0 is missing data for "..k)
+					--print("LibMapData-1.0 is missing data for ",k)
 					missingCache.data[k] = true
 				end
 			end
@@ -90,7 +90,7 @@ do
 	setmetatable(idToMap, { __index = function(t, k)
 			if k then
 				if missingCache.aid[k] == nil then
-					DEFAULT_CHAT_FRAME:AddMessage("LibMapData-1.0 is missing data for area id "..k)
+					--print("LibMapData-1.0 is missing data for area id ",k)
 					missingCache.aid[k] = true
 				end
 			end
@@ -100,7 +100,7 @@ do
 	setmetatable(mapToLocal, { __index = function(t,k)
 			if k then
 				if missingCache.locale[k] == nil then
-					DEFAULT_CHAT_FRAME:AddMessage("LibMapData-1.0 is missing localized data for "..k)
+					--print("LibMapData-1.0 is missing localized data for ",k)
 					missingCache.locale[k] = true
 				end
 			end
@@ -1583,7 +1583,7 @@ function lib:ConvertToWorldPoint(mapfile,x,y)
 	local fl = mapData[mapfile]
 	-- Convert to continet data
 	local x1,y1 = self:ConvertToContinent(mapfile,0,x,y)
-	return x1 + contOffsets[fl.continent], y1 + contOffsets[fl.continent]
+	return x1 + contOffsets[fl.continent][1], y1 + contOffsets[fl.continent][2]
 end

 --- API to convert from the world poistion in yars to the world map scale
diff --git a/sources/ArchaeologyDigSites.lua b/sources/ArchaeologyDigSites.lua
index 3a1a02e..61a68b1 100644
--- a/sources/ArchaeologyDigSites.lua
+++ b/sources/ArchaeologyDigSites.lua
@@ -35,25 +35,27 @@ local function UpdateDigSites()
         SetMapByID(continent)
     end

-    local sites = {}
-    for idx = 1, GetNumMapLandmarks() do
-        local name, desc, textureIdx, px, py = GetMapLandmarkInfo(idx)
-        local zoneName, mapFile, texPctX, texPctY, texX, texY, scrollX, scrollY = UpdateMapHighlight(px, py)
-
-        if textureIdx == 177 then
-            local key = string.format("%s:%f:%f:", name, px, py)
-            if not waypoints[key] then
-                local waypoint = addon:AddWaypoint(continent, nil, px, py, {
-                    title = string.format(L["Dig site: %s\n%s"], name, zoneName),
-                    priority = 0,
-					source = "archaeodig",
-                })
-                sites[key] = waypoint
-            else
-                sites[key] = waypoints[key]
-            end
-        end
-    end
+	if continent then
+		local sites = {}
+		for idx = 1, GetNumMapLandmarks() do
+			local name, desc, textureIdx, px, py = GetMapLandmarkInfo(idx)
+			local zoneName, mapFile, texPctX, texPctY, texX, texY, scrollX, scrollY = UpdateMapHighlight(px, py)
+
+			if textureIdx == 177 then
+				local key = string.format("%s:%f:%f:", name, px, py)
+				if not waypoints[key] then
+					local waypoint = addon:AddWaypoint(continent, nil, px, py, {
+						title = string.format(L["Dig site: %s\n%s"], name, zoneName),
+						priority = 0,
+						source = "archaeodig",
+					})
+					sites[key] = waypoint
+				else
+					sites[key] = waypoints[key]
+				end
+			end
+		end
+	end

     for key, waypoint in pairs(sites) do
         waypoints[key] = nil