Quantcast

Update to HereBeDragons 2.0.9 aka gcd7e0dd

Ludovicus [06-19-19 - 22:38]
Update to HereBeDragons 2.0.9 aka gcd7e0dd
Filename
libs/HereBeDragons/CHANGELOG.md
libs/HereBeDragons/CHANGES.txt
libs/HereBeDragons/HereBeDragons-2.0.lua
libs/HereBeDragons/HereBeDragons-Migrate.lua
libs/HereBeDragons/HereBeDragons-Pins-2.0.lua
diff --git a/libs/HereBeDragons/CHANGELOG.md b/libs/HereBeDragons/CHANGELOG.md
new file mode 100644
index 0000000..60d8406
--- /dev/null
+++ b/libs/HereBeDragons/CHANGELOG.md
@@ -0,0 +1,10 @@
+# Lib: HereBeDragons
+
+## [2.01-release-5-gcd7e0dd](https://github.com/Nevcairiel/HereBeDragons/tree/cd7e0ddc76082130783f138b824f7659b6a4c3f3) (2019-05-26)
+[Full Changelog](https://github.com/Nevcairiel/HereBeDragons/compare/2.01-release...cd7e0ddc76082130783f138b824f7659b6a4c3f3)
+
+- Add World Map Data for Classic
+- Preliminary WoW Classic support
+- Add travis-ci support
+- Add LuaCheck and EditorConfig, and clean sources to pass
+- Fill in the map list by iterating over all known maps, in addition to processing the child tree
diff --git a/libs/HereBeDragons/CHANGES.txt b/libs/HereBeDragons/CHANGES.txt
deleted file mode 100755
index b59a35d..0000000
--- a/libs/HereBeDragons/CHANGES.txt
+++ /dev/null
@@ -1,41 +0,0 @@
-tag 529cf963909b0c048d607d9fb35e549e2867a61c 2.01-release
-Author:	Hendrik Leppkes <h.leppkes@gmail.com>
-Date:	Thu Jan 24 10:17:51 2019 +0100
-
-Tag as 2.01-release
-
-commit 6df387471e91795b8152b6271ce7a8fa15c9d151
-Author: Hendrik Leppkes <h.leppkes@gmail.com>
-Date:   Thu Jan 24 10:17:20 2019 +0100
-
-    Remove load guards
-
-commit 601d62a39f98f533d81027473efdfe5f52672df5
-Author: Hendrik Leppkes <h.leppkes@gmail.com>
-Date:   Thu Jan 24 10:06:55 2019 +0100
-
-    Add support for specifying the frame level category for world map pins
-
-commit 41e7284588afe1f43f987df7efd4669c5467ebb4
-Author: Hendrik Leppkes <h.leppkes@gmail.com>
-Date:   Tue Jan 22 13:13:53 2019 +0100
-
-    Remove HereBeDragons-1.0 from the source
-
-    1.0 was developed for Legion, and has not functioned in WoW 8.0
-
-commit 3ee227ed2b69d15ffeab4c9b06f06141dc879f78
-Author: Hendrik Leppkes <h.leppkes@gmail.com>
-Date:   Mon Sep 10 11:09:08 2018 +0200
-
-    Use the parent parameter instead of accessing the table, it holds the same value
-
-commit 6f03f6f9297155fba47b03f16c29dabd7445081d
-Author: Hendrik Leppkes <h.leppkes@gmail.com>
-Date:   Mon Sep 10 11:07:18 2018 +0200
-
-    Improve map discovery to handle improperly flagged dungeon floor maps
-
-    These maps sometimes do not show up as a child, and can only be detected
-    by checking the map group.
-
diff --git a/libs/HereBeDragons/HereBeDragons-2.0.lua b/libs/HereBeDragons/HereBeDragons-2.0.lua
old mode 100755
new mode 100644
index ff36303..bbfdad5
--- a/libs/HereBeDragons/HereBeDragons-2.0.lua
+++ b/libs/HereBeDragons/HereBeDragons-2.0.lua
@@ -1,6 +1,6 @@
 -- HereBeDragons is a data API for the World of Warcraft mapping system

-local MAJOR, MINOR = "HereBeDragons-2.0", 7
+local MAJOR, MINOR = "HereBeDragons-2.0", 9
 assert(LibStub, MAJOR .. " requires LibStub")

 local HereBeDragons, oldversion = LibStub:NewLibrary(MAJOR, MINOR)
@@ -15,6 +15,8 @@ HereBeDragons.worldMapData     = HereBeDragons.worldMapData or {}
 HereBeDragons.transforms       = HereBeDragons.transforms or {}
 HereBeDragons.callbacks        = HereBeDragons.callbacks or CBH:New(HereBeDragons, nil, nil, false)

+local WoWClassic = select(4, GetBuildInfo()) < 20000
+
 -- Data Constants
 local COSMIC_MAP_ID = 946
 local WORLD_MAP_ID = 947
@@ -23,8 +25,6 @@ local WORLD_MAP_ID = 947
 local PI2 = math.pi * 2
 local atan2 = math.atan2
 local pairs, ipairs = pairs, ipairs
-local type = type
-local band = bit.band

 -- WoW API upvalues
 local UnitPosition = UnitPosition
@@ -98,13 +98,13 @@ if not oldversion or oldversion < 7 then

     local function applyMapTransforms(instanceID, left, right, top, bottom)
         if transforms[instanceID] then
-            for _, transformData in ipairs(transforms[instanceID]) do
-                if left <= transformData.maxX and right >= transformData.minX and top <= transformData.maxY and bottom >= transformData.minY then
-                    instanceID = transformData.newInstanceID
-                    left   = left   + transformData.offsetX
-                    right  = right  + transformData.offsetX
-                    top    = top    + transformData.offsetY
-                    bottom = bottom + transformData.offsetY
+            for _, data in ipairs(transforms[instanceID]) do
+                if left <= data.maxX and right >= data.minX and top <= data.maxY and bottom >= data.minY then
+                    instanceID = data.newInstanceID
+                    left   = left   + data.offsetX
+                    right  = right  + data.offsetX
+                    top    = top    + data.offsetY
+                    bottom = bottom + data.offsetY
                     break
                 end
             end
@@ -170,27 +170,50 @@ if not oldversion or oldversion < 7 then

     local function fixupZones()
         local cosmic = C_Map.GetMapInfo(COSMIC_MAP_ID)
-        mapData[COSMIC_MAP_ID] = {0, 0, 0, 0}
-        mapData[COSMIC_MAP_ID].instance = -1
-        mapData[COSMIC_MAP_ID].name = cosmic.name
-        mapData[COSMIC_MAP_ID].mapType = cosmic.mapType
+        if cosmic then
+            mapData[COSMIC_MAP_ID] = {0, 0, 0, 0}
+            mapData[COSMIC_MAP_ID].instance = -1
+            mapData[COSMIC_MAP_ID].name = cosmic.name
+            mapData[COSMIC_MAP_ID].mapType = cosmic.mapType
+        end

         -- data for the azeroth world map
-        worldMapData[0] = { 76153.14, 50748.62, 65008.24, 23827.51 }
-        worldMapData[1] = { 77803.77, 51854.98, 13157.6, 28030.61 }
-        worldMapData[571] = { 71773.64, 50054.05, 36205.94, 12366.81 }
-        worldMapData[870] = { 67710.54, 45118.08, 33565.89, 38020.67 }
-        worldMapData[1220] = { 82758.64, 55151.28, 52943.46, 24484.72 }
-        worldMapData[1642] = { 77933.3, 51988.91, 44262.36, 32835.1 }
-        worldMapData[1643] = { 76060.47, 50696.96, 55384.8, 25774.35 }
+        if WoWClassic then
+            worldMapData[0] = { 44688.53, 29795.11, 32601.04, 9894.93 }
+            worldMapData[1] = { 44878.66, 29916.10, 8723.96, 14824.53 }
+        else
+            worldMapData[0] = { 76153.14, 50748.62, 65008.24, 23827.51 }
+            worldMapData[1] = { 77803.77, 51854.98, 13157.6, 28030.61 }
+            worldMapData[571] = { 71773.64, 50054.05, 36205.94, 12366.81 }
+            worldMapData[870] = { 67710.54, 45118.08, 33565.89, 38020.67 }
+            worldMapData[1220] = { 82758.64, 55151.28, 52943.46, 24484.72 }
+            worldMapData[1642] = { 77933.3, 51988.91, 44262.36, 32835.1 }
+            worldMapData[1643] = { 76060.47, 50696.96, 55384.8, 25774.35 }
+        end
     end

     local function gatherMapData()
         processTransforms()

-        processMapChildrenRecursive(COSMIC_MAP_ID)
+        -- find all maps in well known structures
+        if WoWClassic then
+            processMap(WORLD_MAP_ID)
+            processMapChildrenRecursive(WORLD_MAP_ID)
+        else
+            processMapChildrenRecursive(COSMIC_MAP_ID)
+        end

         fixupZones()
+
+        -- try to fill in holes in the map list
+        for i = 1, 2000 do
+            if not mapData[i] then
+                local mapInfo = C_Map.GetMapInfo(i)
+                if mapInfo and mapInfo.name then
+                    processMap(i, mapInfo, nil)
+                end
+            end
+        end
     end

     gatherMapData()
@@ -370,9 +393,6 @@ local function TranslateAzerothWorldMapCoordinates(self, x, y, oZone, dZone, all
     local instance = (oZone == WORLD_MAP_ID) and mapData[dZone].instance or mapData[oZone].instance
     if not worldMapData[instance] then return nil, nil end

-    local data = worldMapData[instance]
-    local width, height, left, top = data[1], data[2], data[3], data[4]
-
     if oZone == WORLD_MAP_ID then
         x, y = self:GetWorldCoordinatesFromAzerothWorldMap(x, y, instance)
         return self:GetZoneCoordinatesFromWorld(x, y, dZone, allowOutOfBounds)
@@ -426,11 +446,12 @@ end
 -- @param dY destination Y, in local zone/point coordinates
 -- @return distance, deltaX, deltaY in yards
 function HereBeDragons:GetZoneDistance(oZone, oX, oY, dZone, dX, dY)
-    local oX, oY, oInstance = self:GetWorldCoordinatesFromZone(oX, oY, oZone)
+    local oInstance, dInstance
+    oX, oY, oInstance = self:GetWorldCoordinatesFromZone(oX, oY, oZone)
     if not oX then return nil, nil, nil end

     -- translate dX, dY to the origin zone
-    local dX, dY, dInstance = self:GetWorldCoordinatesFromZone(dX, dY, dZone)
+    dX, dY, dInstance = self:GetWorldCoordinatesFromZone(dX, dY, dZone)
     if not dX then return nil, nil, nil end

     if oInstance ~= dInstance then return nil, nil, nil end
@@ -470,7 +491,7 @@ end
 -- @return x, y, instanceID
 function HereBeDragons:GetUnitWorldPosition(unitId)
     -- get the current position
-    local y, x, z, instanceID = UnitPosition(unitId)
+    local y, x, _z, instanceID = UnitPosition(unitId)
     if not x or not y then return nil, nil, instanceIDOverrides[instanceID] or instanceID end

     -- return transformed coordinates
@@ -482,7 +503,7 @@ end
 -- @return x, y, instanceID
 function HereBeDragons:GetPlayerWorldPosition()
     -- get the current position
-    local y, x, z, instanceID = UnitPosition("player")
+    local y, x, _z, instanceID = UnitPosition("player")
     if not x or not y then return nil, nil, instanceIDOverrides[instanceID] or instanceID end

     -- return transformed coordinates
@@ -502,7 +523,7 @@ end
 -- @return x, y, uiMapID, mapType
 function HereBeDragons:GetPlayerZonePosition(allowOutOfBounds)
     if not currentPlayerUIMapID then return nil, nil, nil, nil end
-    local x, y, instanceID = self:GetPlayerWorldPosition()
+    local x, y, _instanceID = self:GetPlayerWorldPosition()
     if not x or not y then return nil, nil, nil, nil end

     x, y = self:GetZoneCoordinatesFromWorld(x, y, currentPlayerUIMapID, allowOutOfBounds)
diff --git a/libs/HereBeDragons/HereBeDragons-Migrate.lua b/libs/HereBeDragons/HereBeDragons-Migrate.lua
old mode 100755
new mode 100644
index 537b9cb..d9ad7f3
--- a/libs/HereBeDragons/HereBeDragons-Migrate.lua
+++ b/libs/HereBeDragons/HereBeDragons-Migrate.lua
@@ -1,7 +1,7 @@
 local MAJOR, MINOR = "HereBeDragons-Migrate", 2
 assert(LibStub, MAJOR .. " requires LibStub")

-local HBDMigrate, oldversion = LibStub:NewLibrary(MAJOR, MINOR)
+local HBDMigrate, _oldversion = LibStub:NewLibrary(MAJOR, MINOR)
 if not HBDMigrate then return end

 local SetupMigrationData
@@ -52,7 +52,7 @@ function HBDMigrate:GetLegacyMapInfo(uiMapId)
     if not uiMapIdToIdMap then SetupMigrationData() end
     local c = uiMapIdToIdMap[uiMapId]
     if not c then return end
-
+
     local m, f = floor(c / 10000), (c % 10000)
     return m, f, MapMigrationData[m].mapFile
 end
diff --git a/libs/HereBeDragons/HereBeDragons-Pins-2.0.lua b/libs/HereBeDragons/HereBeDragons-Pins-2.0.lua
old mode 100755
new mode 100644
index 76da8b4..6470ec9
--- a/libs/HereBeDragons/HereBeDragons-Pins-2.0.lua
+++ b/libs/HereBeDragons/HereBeDragons-Pins-2.0.lua
@@ -3,7 +3,7 @@
 local MAJOR, MINOR = "HereBeDragons-Pins-2.0", 6
 assert(LibStub, MAJOR .. " requires LibStub")

-local pins, oldversion = LibStub:NewLibrary(MAJOR, MINOR)
+local pins, _oldversion = LibStub:NewLibrary(MAJOR, MINOR)
 if not pins then return end

 local HBD = LibStub("HereBeDragons-2.0")
@@ -198,7 +198,7 @@ local function UpdateMinimapPins(force)
     -- check for all values to be available (starting with 7.1.0, instances don't report coordinates)
     if not x or not y or (rotateMinimap and not facing) then
         minimapPinCount = 0
-        for pin, data in pairs(activeMinimapPins) do
+        for pin in pairs(activeMinimapPins) do
             pin:Hide()
             activeMinimapPins[pin] = nil
         end
@@ -397,14 +397,14 @@ function worldmapProvider:HandlePin(icon, data)
                 local parentMapID = HBD.mapData[data.uiMapID].parent
                 while parentMapID and HBD.mapData[parentMapID] do
                     if parentMapID == uiMapID then
-                        local mapType = HBD.mapData[parentMapID].mapType
+                        local parentMapType = HBD.mapData[parentMapID].mapType
                         -- show on any parent zones if they are normal zones
                         if data.worldMapShowFlag >= HBD_PINS_WORLDMAP_SHOW_PARENT and
-                            (mapType == Enum.UIMapType.Zone or mapType == Enum.UIMapType.Dungeon or mapType == Enum.UIMapType.Micro) then
+                            (parentMapType == Enum.UIMapType.Zone or parentMapType == Enum.UIMapType.Dungeon or parentMapType == Enum.UIMapType.Micro) then
                             show = true
                         -- show on the continent
                         elseif data.worldMapShowFlag >= HBD_PINS_WORLDMAP_SHOW_CONTINENT and
-                            mapType == Enum.UIMapType.Continent then
+                            parentMapType == Enum.UIMapType.Continent then
                             show = true
                         end
                         break