Quantcast

Update Astrolabe to r155

James Whitehead II [10-02-12 - 07:09]
Update Astrolabe to r155

This includes the change to remove the clicking noise when in a zone.
Filename
libs/Astrolabe/Astrolabe.lua
libs/Astrolabe/AstrolabeMapMonitor.lua
diff --git a/libs/Astrolabe/Astrolabe.lua b/libs/Astrolabe/Astrolabe.lua
index dcb1967..a29f2de 100755
--- a/libs/Astrolabe/Astrolabe.lua
+++ b/libs/Astrolabe/Astrolabe.lua
@@ -1,7 +1,7 @@
 --[[
 Name: Astrolabe
-Revision: $Rev: 147 $
-$Date: 2012-08-28 17:45:40 +0100 (Tue, 28 Aug 2012) $
+Revision: $Rev: 154 $
+$Date: 2012-10-02 05:08:43 +0200 (Tue, 02 Oct 2012) $
 Author(s): Esamynn (esamynn at wowinterface.com)
 Inspired By: Gatherer by Norganna
              MapLibrary by Kristofer Karlsson (krka at kth.se)
@@ -42,7 +42,7 @@ Note:
 -- DO NOT MAKE CHANGES TO THIS LIBRARY WITHOUT FIRST CHANGING THE LIBRARY_VERSION_MAJOR
 -- STRING (to something unique) OR ELSE YOU MAY BREAK OTHER ADDONS THAT USE THIS LIBRARY!!!
 local LIBRARY_VERSION_MAJOR = "Astrolabe-1.0"
-local LIBRARY_VERSION_MINOR = tonumber(string.match("$Revision: 147 $", "(%d+)") or 1)
+local LIBRARY_VERSION_MINOR = tonumber(string.match("$Revision: 154 $", "(%d+)") or 1)

 if not DongleStub then error(LIBRARY_VERSION_MAJOR .. " requires DongleStub.") end
 if not DongleStub:IsNewerVersion(LIBRARY_VERSION_MAJOR, LIBRARY_VERSION_MINOR) then return end
@@ -106,6 +106,7 @@ local max = math.max
 local yield = coroutine.yield
 local next = next
 local GetFramerate = GetFramerate
+local band = bit.band

 local real_GetCurrentMapAreaID = GetCurrentMapAreaID
 local function GetCurrentMapAreaID()
@@ -141,7 +142,7 @@ end

 local function getSystemPosition( mapData, f, x, y )
 	if ( f ~= 0 ) then
-		mapData = rawget(mapData, f) or MicroDungeonSize[mapData.system][f];
+		mapData = rawget(mapData, f) or MicroDungeonSize[mapData.originSystem][f];
 	end
 	x = x * mapData.width + mapData.xOffset;
 	y = y * mapData.height + mapData.yOffset;
@@ -182,7 +183,7 @@ function Astrolabe:ComputeDistance( m1, f1, x1, y1, m2, f2, x2, y2 )
 		-- points in the same zone on the same floor
 		local mapData = WorldMapSize[m1];
 		if ( f1 ~= 0 ) then
-			mapData = rawget(mapData, f1) or MicroDungeonSize[mapData.system][f1];
+			mapData = rawget(mapData, f1) or MicroDungeonSize[mapData.originSystem][f1];
 		end
 		xDelta = (x2 - x1) * mapData.width;
 		yDelta = (y2 - y1) * mapData.height;
@@ -258,7 +259,7 @@ function Astrolabe:TranslateWorldMapPosition( M, F, xPos, yPos, nM, nF )
 			xPos, yPos = getSystemPosition(map, F, xPos, yPos);
 			mapData = WorldMapSize[nM];
 			if ( nF ~= 0 ) then
-				mapData = rawget(mapData, nF) or MicroDungeonSize[mapData.system][nF];
+				mapData = rawget(mapData, nF) or MicroDungeonSize[mapData.originSystem][nF];
 			end

 		else
@@ -282,7 +283,7 @@ function Astrolabe:TranslateWorldMapPosition( M, F, xPos, yPos, nM, nF )
 					yPos = (yPos / nCont.scale) + nCont.yOffset;
 					mapData = WorldMapSize[nM];
 					if ( nF ~= 0 ) then
-						mapData = rawget(mapData, nF) or MicroDungeonSize[mapData.system][nF];
+						mapData = rawget(mapData, nF) or MicroDungeonSize[mapData.originSystem][nF];
 					end
 				end

@@ -318,7 +319,14 @@ function Astrolabe:GetUnitPosition( unit, noMapChange )
 		SetMapToCurrentZone();
 		x, y = GetPlayerMapPosition(unit);
 		if ( x <= 0 and y <= 0 ) then
-			WorldMapZoomOutButton_OnClick();
+			-- attempt to zoom out once - logic copied from WorldMapZoomOutButton_OnClick()
+				if ( ZoomOut() ) then
+					-- do nothing
+				elseif ( GetCurrentMapZone() ~= WORLDMAP_WORLD_ID ) then
+					SetMapZoom(GetCurrentMapContinent());
+				else
+					SetMapZoom(WORLDMAP_WORLD_ID);
+				end
 			x, y = GetPlayerMapPosition(unit);
 			if ( x <= 0 and y <= 0 ) then
 				-- we are in an instance without a map or otherwise off map
@@ -355,7 +363,14 @@ function Astrolabe:GetCurrentPlayerPosition()
 		SetMapToCurrentZone();
 		x, y = GetPlayerMapPosition("player");
 		if ( x <= 0 and y <= 0 ) then
-			WorldMapZoomOutButton_OnClick();
+			-- attempt to zoom out once - logic copied from WorldMapZoomOutButton_OnClick()
+				if ( ZoomOut() ) then
+					-- do nothing
+				elseif ( GetCurrentMapZone() ~= WORLDMAP_WORLD_ID ) then
+					SetMapZoom(GetCurrentMapContinent());
+				else
+					SetMapZoom(WORLDMAP_WORLD_ID);
+				end
 			x, y = GetPlayerMapPosition("player");
 			if ( x <= 0 and y <= 0 ) then
 				-- we are in an instance without a map or otherwise off map
@@ -393,13 +408,20 @@ function Astrolabe:GetMapInfo( mapID, mapFloor )
 	local mapData = WorldMapSize[mapID];
 	local system, systemParent = mapData.system, WorldMapSize[0][mapData.system] and true or false
 	if ( mapFloor ~= 0 ) then
-		mapData = rawget(mapData, mapFloor) or MicroDungeonSize[mapData.system][mapFloor];
+		mapData = rawget(mapData, mapFloor) or MicroDungeonSize[mapData.originSystem][mapFloor];
 	end
 	if ( mapData ~= zeroData ) then
 		return system, systemParent, mapData.width, mapData.height, mapData.xOffset, mapData.yOffset;
 	end
 end

+function Astrolabe:GetMapFilename( mapID )
+	local mapData = self.HarvestedMapData[mapID]
+	if ( mapData ) then
+		return mapData.mapName
+	end
+end
+

 --------------------------------------------------------------------------------------------------------------
 -- Working Table Cache System
@@ -986,10 +1008,7 @@ function Astrolabe:OnShow( frame )
 		SetMapToCurrentZone();
 	end
 	local M, F = Astrolabe:GetCurrentPlayerPosition();
-	if ( M and M >= 0 ) then
-		SetMapByID(M);
-		SetDungeonMapLevel(F);
-	else
+	if not ( M and M >= 0 ) then
 		frame:Hide();
 		return
 	end
@@ -1232,6 +1251,24 @@ WorldMapSize = {

 MicroDungeonSize = {}

+
+--------------------------------------------------------------------------------------------------------------
+-- Internal Data Table Setup
+--------------------------------------------------------------------------------------------------------------
+
+-- Map Data API Flag Fields --
+
+-- GetAreaMapInfo - flags
+local WORLDMAPAREA_DEFAULT_DUNGEON_FLOOR_IS_TERRAIN = 0x00000004
+local WORLDMAPAREA_VIRTUAL_CONTINENT = 0x00000008
+
+-- GetDungeonMapInfo - flags
+local DUNGEONMAP_MICRO_DUNGEON = 0x00000001
+
+
+-- Zero Data Table
+-- Used to prevent runtime Lua errors due to missing data
+
 local function zeroDataFunc(tbl, key)
 	if ( type(key) == "number" ) then
 		return zeroData;
@@ -1266,7 +1303,8 @@ local harvestedDataVersion = Astrolabe.HarvestedMapData.VERSION
 Astrolabe.HarvestedMapData.VERSION = nil

 for mapID, harvestedData in pairs(Astrolabe.HarvestedMapData) do
-	local terrainMapID = GetAreaMapInfo(mapID)
+	local terrainMapID, _, _, _, _, _, _, _, _, flags = GetAreaMapInfo(mapID)
+	local originSystem = terrainMapID;
 	local mapData = WorldMapSize[mapID];
 	if not ( mapData ) then mapData = {}; end
 	if ( harvestedData.numFloors > 0 or harvestedData.hiddenFloor ) then
@@ -1299,7 +1337,8 @@ for mapID, harvestedData in pairs(Astrolabe.HarvestedMapData) do
 		end
 		for f = 1, harvestedData.numFloors do
 			if not ( mapData[f] ) then
-				if ( f == 1 and harvestedData[0] and harvestedData[0].TLx and harvestedData[0].TLy and harvestedData[0].BRx and harvestedData[0].BRy ) then
+				if ( f == 1 and harvestedData[0] and harvestedData[0].TLx and harvestedData[0].TLy and harvestedData[0].BRx and harvestedData[0].BRy and
+				  band(flags, WORLDMAPAREA_DEFAULT_DUNGEON_FLOOR_IS_TERRAIN) == WORLDMAPAREA_DEFAULT_DUNGEON_FLOOR_IS_TERRAIN ) then
 					-- handle dungeon maps which use zone level data for the first floor
 					mapData[f] = {};
 					local floorData = mapData[f]
@@ -1378,11 +1417,15 @@ for mapID, harvestedData in pairs(Astrolabe.HarvestedMapData) do
 	if not ( next(mapData, nil) ) then
 		mapData = { xOffset = 0, height = 1, yOffset = 0, width = 1 };
 		-- if this is an outside continent level or world map then throw up an extra warning
-		if ( harvestedData.cont > 0 and harvestedData.zone == 0 ) then
+		if ( harvestedData.cont > 0 and harvestedData.zone == 0 and not (band(flags, WORLDMAPAREA_VIRTUAL_CONTINENT) == WORLDMAPAREA_VIRTUAL_CONTINENT) ) then
 			printError(("Astrolabe is missing data for world map %s [%d] (%d, %d)."):format(harvestedData.mapName, mapID, harvestedData.cont, harvestedData.zone));
 		end
 	end

+	if not ( mapData.originSystem ) then
+		mapData.originSystem = originSystem;
+	end
+
 	-- store the data in the WorldMapSize DB
 	WorldMapSize[mapID] = mapData;

@@ -1407,34 +1450,35 @@ Astrolabe.HarvestedMapData.VERSION = harvestedDataVersion

 -- micro dungeons
 for _, ID in ipairs(GetDungeonMaps()) do
-	local floorIndex, minX, maxX, minY, maxY, terrainMapID, parentWorldMapID = GetDungeonMapInfo(ID);
-	local TLx, TLy, BRx, BRy = -maxX, -maxY, -minX, -minY
-	-- apply any necessary transforms
-	local transformApplied = false
-	for transformID, transformData in pairs(TRANSFORMS) do
-		if ( transformData.terrainMapID == terrainMapID ) then
-			if ( (transformData.TLx < TLx and BRx < transformData.BRx) and (transformData.TLy < TLy and BRy < transformData.BRy) ) then
-				TLx = TLx - transformData.offsetX;
-				BRx = BRx - transformData.offsetX;
-				BRy = BRy - transformData.offsetY;
-				TLy = TLy - transformData.offsetY;
-				terrainMapID = transformData.newTerrainMapID;
-				transformApplied = true;
-				break;
+	local floorIndex, minX, maxX, minY, maxY, terrainMapID, parentWorldMapID, flags = GetDungeonMapInfo(ID);
+	if ( band(flags, DUNGEONMAP_MICRO_DUNGEON) == DUNGEONMAP_MICRO_DUNGEON ) then
+		local TLx, TLy, BRx, BRy = -maxX, -maxY, -minX, -minY
+		-- apply any necessary transforms
+		local transformApplied = false
+		for transformID, transformData in pairs(TRANSFORMS) do
+			if ( transformData.terrainMapID == terrainMapID ) then
+				if ( (transformData.TLx < TLx and BRx < transformData.BRx) and (transformData.TLy < TLy and BRy < transformData.BRy) ) then
+					TLx = TLx - transformData.offsetX;
+					BRx = BRx - transformData.offsetX;
+					BRy = BRy - transformData.offsetY;
+					TLy = TLy - transformData.offsetY;
+					transformApplied = true;
+					break;
+				end
 			end
 		end
-	end
-	if ( MicroDungeonSize[terrainMapID] ) then
-		-- only consider systems that can have micro dungeons
-		if ( MicroDungeonSize[terrainMapID][floorIndex] and not transformApplied ) then
-			printError("Astrolabe detected a duplicate microdungeon floor!", terrainMapID, ID);
+		if ( MicroDungeonSize[terrainMapID] ) then
+			-- only consider systems that can have micro dungeons
+			if ( MicroDungeonSize[terrainMapID][floorIndex] ) then
+				printError("Astrolabe detected a duplicate microdungeon floor!", terrainMapID, ID);
+			end
+			MicroDungeonSize[terrainMapID][floorIndex] = {
+				width = BRx - TLx,
+				height = BRy - TLy,
+				xOffset = TLx,
+				yOffset = TLy,
+			};
 		end
-		MicroDungeonSize[terrainMapID][floorIndex] = {
-			width = BRx - TLx,
-			height = BRy - TLy,
-			xOffset = TLx,
-			yOffset = TLy,
-		};
 	end
 end

diff --git a/libs/Astrolabe/AstrolabeMapMonitor.lua b/libs/Astrolabe/AstrolabeMapMonitor.lua
index 58b83cc..2d193f1 100755
--- a/libs/Astrolabe/AstrolabeMapMonitor.lua
+++ b/libs/Astrolabe/AstrolabeMapMonitor.lua
@@ -1,7 +1,7 @@
 --[[
 Name: AstrolabeMapMonitor
 Revision: $Rev: 44 $
-$Date: 2007-03-30 19:56:21 +0100 (Fri, 30 Mar 2007) $
+$Date: 2007-03-30 20:56:21 +0200 (Fri, 30 Mar 2007) $
 Author(s): Esamynn (esamynn@wowinterface.com)
 Inspired By: Gatherer by Norganna
              MapLibrary by Kristofer Karlsson (krka@kth.se)