Quantcast

Update LibMapData

James Whitehead II [11-24-10 - 21:42]
Update LibMapData
Filename
libs/LibMapData-1.0/library.lua
diff --git a/libs/LibMapData-1.0/library.lua b/libs/LibMapData-1.0/library.lua
index 82fa48f..28a4547 100644
--- a/libs/LibMapData-1.0/library.lua
+++ b/libs/LibMapData-1.0/library.lua
@@ -1647,6 +1647,24 @@ function lib:DistanceWithinContinent(srcMap,srcFloor, srcX, srcY, dstMap, dstFlo
 	return (x*x+y*y)^0.5,x,y
 end

+function lib:DistanceAndDirectionWithinContinent(srcMap,srcFloor, srcX, srcY, dstMap, dstFloor, dstX, dstY)
+	assert(srcFloor == nil or (type(srcFloor) == "number" and srcFloor))
+	assert(dstFloor == nil or (type(dstFloor) == "number" and dstFloor))
+	if type(dstMap) == "string" then
+		dstMap = idToMap[dstMap]
+	end
+	if type(srcMap) == "string" then
+		srcMap = idToMap[srcMap]
+	end
+	if mapData[srcMap].continent ~= mapData[dstMap].continent then
+		return 0,0,0
+	end
+	local startX, startY = self:ConvertToContinent(srcMap,srcFloor, srcX, srcY)
+	local endX, endY = self:ConvertToContinent(dstMap,dstFloor, dstX, dstY)
+	local x = (endX - startX)
+	local y = (endY - startY)
+	return (x*x+y*y)^0.5,x,y
+end
 --- API to convert coords to yards
 -- @param mapfile or area_id
 -- @param floor
@@ -1871,4 +1889,4 @@ for continent in pairs({GetMapContinents()}) do
 	end
 end
 print("All Tests passed")
-end
\ No newline at end of file
+end