Skip to content

Commit

Permalink
Re-design map list generation, fill in some gaps of missing phased zones
Browse files Browse the repository at this point in the history
Fixes #17
  • Loading branch information
Nevcairiel committed Apr 21, 2024
1 parent 6f4311d commit b671ca3
Showing 1 changed file with 39 additions and 27 deletions.
66 changes: 39 additions & 27 deletions Routes.lua
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,10 @@ local function GetZoneName(uiMapID)
elseif uiMapID == 2104 then
-- Wintergrasp (BG)
name = format("%s (BG)", name)
elseif uiMapID == 1527 or uiMapID == 1530 then -- Black Empire zones (Uldum, Vale)
name = format("%s (Black Empire)", name)
elseif uiMapID == 2070 then -- Tirisfal Glades after the fall of Undercity
name = format("%s (Lordaeron)", name)
end
return name
end
Expand All @@ -192,40 +196,48 @@ end
Routes.GetZoneName = GetZoneName

Routes.LZName = setmetatable({}, { __index = function() return 0 end})
local function processMapChildrenRecursive(parent)
local children = C_Map.GetMapChildrenInfo(parent)
if children and #children > 0 then
for i = 1, #children do
local id = children[i].mapID
if id then
if children[i].mapType == Enum.UIMapType.Zone or children[i].mapType == Enum.UIMapType.Continent then
local name = GetZoneName(id)

--[[
if Routes.LZName[name] and Routes.LZName[name] ~= 0 then
print(("Routes: Name %q already mapped to %d (new: %d)"):format(name, Routes.LZName[name], id))
end
--]]

Routes.LZName[name] = id
local COSMIC_MAP_ID = 946
local WORLD_MAP_ID = 947

processMapChildrenRecursive(id)
elseif children[i].mapType == Enum.UIMapType.World then
processMapChildrenRecursive(id)
end
local validParentIDs = { [COSMIC_MAP_ID] = true, [WORLD_MAP_ID] = true }
local function validMapParent(id)
-- invalid ID
if not id or id == 0 then return false end
-- parent we alreadychecked
if validParentIDs[id] then return true end

-- get map data
local data = Routes.Dragons.mapData[id]
if not data then return false end

-- only zones and continents
if data.mapType ~= Enum.UIMapType.Zone and data.mapType ~= Enum.UIMapType.Continent then return false end

-- walk up the tree
return validMapParent(data.parent)
end

local function processMapEntries()
for id, data in pairs(Routes.Dragons.mapData) do
if (data.mapType == Enum.UIMapType.Zone or data.mapType == Enum.UIMapType.Continent) and validMapParent(data.parent) then
validParentIDs[data.parent] = true

local name = GetZoneName(id)

--[[
if Routes.LZName[name] and Routes.LZName[name] ~= 0 then
print(("Routes: Name %q already mapped to %d (new: %d)"):format(name, Routes.LZName[name], id))
end
--]]

Routes.LZName[name] = id
end
end
end

local COSMIC_MAP_ID = 946
local WORLD_MAP_ID = 947

if WOW_PROJECT_ID == WOW_PROJECT_CLASSIC then
processMapChildrenRecursive(WORLD_MAP_ID)
else
processMapChildrenRecursive(COSMIC_MAP_ID)
end
-- initialize map list
processMapEntries()

------------------------------------------------------------------------------------------------------
-- Core Routes functions
Expand Down

0 comments on commit b671ca3

Please sign in to comment.