mirror of
https://codeberg.org/Duvelcorp/MetaHunt.git
synced 2026-09-29 19:16:04 +00:00
NPC Finder: fix zone-ID mislabel and show all zones per NPC
- Translate the coord's WMA id to pfQuest before the MTH_DS_Zones parent lookup, so e.g. Feralas (WMA 121) no longer collides with pfQ 121 (Raven Hill) and prints its parent 'Duskwood' - Zone column now lists every distinct zone an NPC occupies, smallest-map first, so border/capital NPCs read 'Darnassus, Teldrassil' etc. (sort key matches)
This commit is contained in:
@@ -69,8 +69,14 @@ local function MTH_BOOKTAB_GetZoneAndSubzone(zoneId)
|
||||
local zid = tonumber(zoneId)
|
||||
if not zid then return "-", "-" end
|
||||
local zoneName = MTH_BOOK_GetZoneName(zid)
|
||||
local row = MTH_DS_Zones and (MTH_DS_Zones[zid] or MTH_DS_Zones[tostring(zid)])
|
||||
if row and row.parent and tonumber(row.parent) and tonumber(row.parent) ~= zid then
|
||||
-- Coord zone IDs are WMA; MTH_DS_Zones is keyed by pfQuest area IDs. Translate
|
||||
-- first, or WMA 121 (Feralas) collides with pfQ 121 (Raven Hill -> parent Duskwood).
|
||||
local pfqId = zid
|
||||
if type(MTH_MAP_WMA_TO_PFQ) == "table" then
|
||||
pfqId = MTH_MAP_WMA_TO_PFQ[zid] or zid
|
||||
end
|
||||
local row = MTH_DS_Zones and (MTH_DS_Zones[pfqId] or MTH_DS_Zones[tostring(pfqId)])
|
||||
if row and row.parent and tonumber(row.parent) and tonumber(row.parent) ~= pfqId then
|
||||
local parentName = MTH_BOOK_GetZoneName(row.parent)
|
||||
if parentName and string.sub(parentName, 1, 5) ~= "Zone " then
|
||||
return parentName, zoneName
|
||||
@@ -105,6 +111,47 @@ function MTH_BOOKTAB_GetNPCZoneSummary(vendor)
|
||||
end
|
||||
MTH_BOOK_GetNPCZoneSummary = MTH_BOOKTAB_GetNPCZoneSummary
|
||||
|
||||
-- Zone column text: every distinct zone the NPC sits in, most-specific (smallest
|
||||
-- map) first, so multi-location NPCs read e.g. "Darnassus, Teldrassil".
|
||||
function MTH_BOOKTAB_GetNPCZoneDisplay(vendor)
|
||||
if not vendor or not vendor.coords or table.getn(vendor.coords) == 0 then
|
||||
return "-"
|
||||
end
|
||||
local seen = {}
|
||||
local list = {}
|
||||
for i = 1, table.getn(vendor.coords) do
|
||||
local c = vendor.coords[i]
|
||||
if c and c[3] then
|
||||
local zoneName = MTH_BOOK_GetZoneName(c[3])
|
||||
if zoneName and zoneName ~= "-" and not seen[zoneName] then
|
||||
seen[zoneName] = true
|
||||
local area = nil
|
||||
local size = MTH_DS_MinimapSizes and (MTH_DS_MinimapSizes[tonumber(c[3])] or MTH_DS_MinimapSizes[c[3]])
|
||||
if type(size) == "table" and tonumber(size[1]) and tonumber(size[2]) then
|
||||
area = tonumber(size[1]) * tonumber(size[2])
|
||||
end
|
||||
table.insert(list, { name = zoneName, area = area, order = i })
|
||||
end
|
||||
end
|
||||
end
|
||||
local count = table.getn(list)
|
||||
if count == 0 then return "-" end
|
||||
-- Smallest map first; zones with no known size keep data order, at the end.
|
||||
table.sort(list, function(x, y)
|
||||
if x.area and y.area then
|
||||
if x.area ~= y.area then return x.area < y.area end
|
||||
return x.order < y.order
|
||||
end
|
||||
if x.area then return true end
|
||||
if y.area then return false end
|
||||
return x.order < y.order
|
||||
end)
|
||||
local names = {}
|
||||
for i = 1, count do table.insert(names, list[i].name) end
|
||||
return table.concat(names, ", ")
|
||||
end
|
||||
MTH_BOOK_GetNPCZoneDisplay = MTH_BOOKTAB_GetNPCZoneDisplay
|
||||
|
||||
function MTH_BOOK_NPCHasZoneId(vendor, zoneId)
|
||||
local zid = tonumber(zoneId)
|
||||
if not zid or not vendor or not vendor.coords then
|
||||
|
||||
+2
-2
@@ -1518,7 +1518,7 @@ local function MTH_BOOK_GetSortKey(entry, col)
|
||||
if not npc then return nil end
|
||||
local react = MTH_BOOK_GetNPCReactBucket(npc.fac)
|
||||
local functionSummary = MTH_BOOK_GetNPCFunctionSummary(npc)
|
||||
local zoneName = MTH_BOOK_GetNPCZoneSummary(npc)
|
||||
local zoneName = (type(MTH_BOOK_GetNPCZoneDisplay) == "function" and MTH_BOOK_GetNPCZoneDisplay(npc)) or MTH_BOOK_GetNPCZoneSummary(npc)
|
||||
if col == 1 then return tonumber(entry) or 0 end
|
||||
if col == 2 then
|
||||
local npcName = (MTH and MTH.GetLocalizedNPCNameById and MTH:GetLocalizedNPCNameById(entry, npc.name)) or npc.name
|
||||
@@ -4333,7 +4333,7 @@ local function MTH_BOOK_GetRowValues(entry)
|
||||
if not vendor then return { "", "", "", "", "" } end
|
||||
local react = MTH_BOOK_GetNPCReactBucket(vendor.fac)
|
||||
local functionSummary = MTH_BOOK_GetNPCFunctionSummary(vendor)
|
||||
local zoneName = MTH_BOOK_GetNPCZoneSummary(vendor)
|
||||
local zoneName = (type(MTH_BOOK_GetNPCZoneDisplay) == "function" and MTH_BOOK_GetNPCZoneDisplay(vendor)) or MTH_BOOK_GetNPCZoneSummary(vendor)
|
||||
local vendorName = (MTH and MTH.GetLocalizedNPCNameById and MTH:GetLocalizedNPCNameById(entry, vendor.name)) or vendor.name
|
||||
return {
|
||||
"|cFF33CCFF" .. tostring(entry) .. "|r",
|
||||
|
||||
Reference in New Issue
Block a user