diff --git a/Database/Zones/zoneDB.lua b/Database/Zones/zoneDB.lua index 529efa5..d789305 100644 --- a/Database/Zones/zoneDB.lua +++ b/Database/Zones/zoneDB.lua @@ -45,13 +45,23 @@ ZoneDB.zoneIDs = ZoneDB.private.zoneIDs or {} -- Overrides for UiMapId to AreaId +-- IMPORTANT: Only override specific real maps, NOT cosmic/world maps (946, 947, etc.) +-- that span multiple zones. Overriding 946/947 to a single zone breaks all other zones. local UiMapIdOverrides = { [246] = 3713, [1415] = 668, -- Eastern Kingdoms (matches Undercity on Ascension) - [947] = 668, -- Azeroth (matches Undercity on Ascension) [1241] = 3430, -- Sunstrider Isle (uiMapId 1241 → areaId 3430) - [946] = 3430, -- Sunstrider Isle ghost/loading map → areaId 3430 + [1238] = 668, -- Northshire Valley child map (Conquest of Azeroth) + [946] = 668, -- Northshire Valley zone map (Conquest of Azeroth) - GetCurrentUiMapID() returns 946, not 1238 } +-- Reverse mapping: areaId → uiMapId for GetUiMapIdByAreaId lookups. +-- Northshire Valley (areaId 668) uses uiMapId 1238. +ZoneDB.private.areaIdToUiMapId[668] = 1238 +areaIdToUiMapId[668] = 1238 +-- Also populate the cache so the fast path works without a lazy lookup. +if uiMapIdToAreaIdCache[1238] == nil then + uiMapIdToAreaIdCache[1238] = 668 +end local parentZoneToSubZone = {} -- Generated local zoneMap = {} -- Generated diff --git a/Modules/Arrow/QuestieArrow.lua b/Modules/Arrow/QuestieArrow.lua index 7bbabae..3d0e06b 100644 --- a/Modules/Arrow/QuestieArrow.lua +++ b/Modules/Arrow/QuestieArrow.lua @@ -657,13 +657,13 @@ sortedTargets = {} -- If that returns nil (map closed), fall back to C_Map.GetPlayerMapPosition + -- HBD:GetWorldCoordinatesFromZone which works regardless of map open/closed state. local playerX, playerY, playerInstance = HBD:GetPlayerWorldPosition() -if not playerX or not playerY or not playerInstance then + if not playerX or not playerY or not playerInstance then -- Fallback: get map-relative position then convert to world coords via HBD. -- Use the player's current uiMapId as the map basis for the conversion. - -- IMPORTANT: never use 946 (ghost window/world map) — it has no world coord data. - -- If GetCurrentUiMapId returns 946, fall back to ZoneDB from the actual zone. + -- IMPORTANT: never use 946/947 (world/cosmic maps) — they have no world coord data. + -- If GetCurrentUiMapId returns a world map, fall back to ZoneDB from the actual zone. local pUiMapId = QuestiePlayer:GetCurrentUiMapId() - if not pUiMapId or pUiMapId == 947 or pUiMapId == 0 or pUiMapId == 946 then + if not pUiMapId or pUiMapId == 946 or pUiMapId == 947 or pUiMapId == 0 then local zoneId = QuestiePlayer:GetCurrentZoneId() or select(7, GetInstanceInfo()) if debugArrow then print(string.format("UpdateNearestTargets: pUiMapId=%s (invalid), looking up via zoneId=%s", tostring(pUiMapId), tostring(zoneId))) @@ -672,6 +672,16 @@ if not playerX or not playerY or not playerInstance then pUiMapId = ZoneDB:GetUiMapIdByAreaId(zoneId) end end + -- Additional safeguard: if pUiMapId is still a world/cosmic map, force lookup from zone + if not pUiMapId or pUiMapId == 946 or pUiMapId == 947 or pUiMapId == 0 then + local zoneId = QuestiePlayer:GetCurrentZoneId() + if zoneId and zoneId ~= 0 then + pUiMapId = ZoneDB:GetUiMapIdByAreaId(zoneId) + if debugArrow then + print(string.format("UpdateNearestTargets: forced pUiMapId=%s via zoneId=%s", tostring(pUiMapId), tostring(zoneId))) + end + end + end pUiMapId = pUiMapId or 0 if debugArrow then diff --git a/Modules/QuestiePlayer.lua b/Modules/QuestiePlayer.lua index 01bce9b..5f5ba0b 100644 --- a/Modules/QuestiePlayer.lua +++ b/Modules/QuestiePlayer.lua @@ -110,7 +110,8 @@ function QuestiePlayer.HasRequiredClass(requiredClasses) end function QuestiePlayer:GetCurrentZoneId() - local uiMapId = C_Map.GetBestMapForUnit("player") + local uiMapIdOrTable = C_Map.GetBestMapForUnit("player") + local uiMapId = type(uiMapIdOrTable) == "table" and uiMapIdOrTable.uiMapID or uiMapIdOrTable if uiMapId then local areaId = ZoneDB:GetAreaIdByUiMapId(uiMapId) if areaId then @@ -123,7 +124,8 @@ function QuestiePlayer:GetCurrentZoneId() end function QuestiePlayer:GetCurrentUiMapId() - local uiMapId = C_Map.GetBestMapForUnit("player") + local uiMapIdOrTable = C_Map.GetBestMapForUnit("player") + local uiMapId = type(uiMapIdOrTable) == "table" and uiMapIdOrTable.uiMapID or uiMapIdOrTable if uiMapId then return uiMapId end