Quantcast

Update to HereBeDragons 2.03

Ludovicus [02-27-20 - 20:01]
Update to HereBeDragons 2.03
Filename
libs/HereBeDragons/CHANGELOG.md
libs/HereBeDragons/HereBeDragons-2.0.lua
diff --git a/libs/HereBeDragons/CHANGELOG.md b/libs/HereBeDragons/CHANGELOG.md
index 93e111e..a9e523f 100755
--- a/libs/HereBeDragons/CHANGELOG.md
+++ b/libs/HereBeDragons/CHANGELOG.md
@@ -1,8 +1,10 @@
 # Lib: HereBeDragons

-## [2.02-release-10-gd4da4b5](https://github.com/Nevcairiel/HereBeDragons/tree/d4da4b5ce4d13617d23f1d5a4205fb3e5b641df2) (2020-02-02)
-[Full Changelog](https://github.com/Nevcairiel/HereBeDragons/compare/2.02-release...d4da4b5ce4d13617d23f1d5a4205fb3e5b641df2)
+## [2.03-release](https://github.com/Nevcairiel/HereBeDragons/tree/2.03-release) (2020-02-08)
+[Full Changelog](https://github.com/Nevcairiel/HereBeDragons/compare/2.02-release...2.03-release)

+- Unify overriding instance IDs
+- Add more 8.3 vision phasing IDs
 - Update TOC for 8.3
 - Add static override for the minor vision in the Vale of Eternal Bossoms
 - Check for existing static overrides as well
diff --git a/libs/HereBeDragons/HereBeDragons-2.0.lua b/libs/HereBeDragons/HereBeDragons-2.0.lua
index bbcc3be..2862cc4 100755
--- 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", 13
+local MAJOR, MINOR = "HereBeDragons-2.0", 14
 assert(LibStub, MAJOR .. " requires LibStub")

 local HereBeDragons, oldversion = LibStub:NewLibrary(MAJOR, MINOR)
@@ -66,13 +66,17 @@ local instanceIDOverrides = {
     [1626] = 1220, -- Suramar Withered Scenario
     [1662] = 1220, -- Suramar Invasion Scenario
     -- BfA
+    [2213] = 0,    -- Horrific Vision of Stormwind
     [2241] = 1,    -- Uldum N'zoth assault
+    [2274] = 1,    -- Uldum N'zoth Minor Vision
     [2275] = 870,  -- Vale of Eternal Blossoms N'zoth Minor Vision
 }

 local dynamicInstanceIDOverrides = {}
 instanceIDOverrides = setmetatable(instanceIDOverrides, { __index = dynamicInstanceIDOverrides })

+local function overrideInstance(instance) return instanceIDOverrides[instance] or instance end
+
 -- debug only
 HereBeDragons.___DIIDO = dynamicInstanceIDOverrides

@@ -241,10 +245,7 @@ local function applyCoordinateTransforms(x, y, instanceID)
             end
         end
     end
-    if instanceIDOverrides[instanceID] then
-        instanceID = instanceIDOverrides[instanceID]
-    end
-    return x, y, instanceID
+    return x, y, overrideInstance(instanceID)
 end

 local StartUpdateTimer
@@ -349,7 +350,7 @@ function HereBeDragons:GetWorldCoordinatesFromZone(x, y, zone)
     local width, height, left, top = data[1], data[2], data[3], data[4]
     x, y = left - width * x, top - height * y

-    return x, y, data.instance
+    return x, y, overrideInstance(data.instance)
 end

 --- Convert local/point coordinates to world coordinates in yards. The coordinates have to come from the Azeroth World Map
@@ -410,7 +411,7 @@ end
 local function TranslateAzerothWorldMapCoordinates(self, x, y, oZone, dZone, allowOutOfBounds)
     if (oZone ~= WORLD_MAP_ID and not mapData[oZone]) or (dZone ~= WORLD_MAP_ID and not mapData[dZone]) then return nil, nil end
     -- determine the instance we're working with
-    local instance = (oZone == WORLD_MAP_ID) and mapData[dZone].instance or mapData[oZone].instance
+    local instance = overrideInstance((oZone == WORLD_MAP_ID) and mapData[dZone].instance or mapData[oZone].instance)
     if not worldMapData[instance] then return nil, nil end

     if oZone == WORLD_MAP_ID then
@@ -439,7 +440,7 @@ function HereBeDragons:TranslateZoneCoordinates(x, y, oZone, dZone, allowOutOfBo
     if not xCoord then return nil, nil end

     local data = mapData[dZone]
-    if not data or data.instance ~= instance then return nil, nil end
+    if not data or overrideInstance(data.instance) ~= instance then return nil, nil end

     return self:GetZoneCoordinatesFromWorld(xCoord, yCoord, dZone, allowOutOfBounds)
 end
@@ -512,7 +513,7 @@ end
 function HereBeDragons:GetUnitWorldPosition(unitId)
     -- get the current position
     local y, x, _z, instanceID = UnitPosition(unitId)
-    if not x or not y then return nil, nil, instanceIDOverrides[instanceID] or instanceID end
+    if not x or not y then return nil, nil, overrideInstance(instanceID) end

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

     -- return transformed coordinates
     return applyCoordinateTransforms(x, y, instanceID)