diff --git a/Compat/Compat.lua b/Compat/Compat.lua index 0266a96..badcbff 100644 --- a/Compat/Compat.lua +++ b/Compat/Compat.lua @@ -1090,6 +1090,14 @@ local questTagToName = { [85] = "Heroic", } +-- Reverse lookup (tag name -> tag id), exposed so callers can convert the live +-- questTag string returned by the game's own GetQuestLogTitle back into the +-- numeric tag id used throughout Questie. +QuestieCompat.QuestTagNameToId = {} +for id, name in pairs(questTagToName) do + QuestieCompat.QuestTagNameToId[name] = id +end + -- Retrieves tag information about the quest. -- https://wowpedia.fandom.com/wiki/API_GetQuestTagInfo function QuestieCompat.GetQuestTagInfo(questId) diff --git a/Database/QuestieDB.lua b/Database/QuestieDB.lua index 44c475c..44ce3b7 100644 --- a/Database/QuestieDB.lua +++ b/Database/QuestieDB.lua @@ -999,6 +999,25 @@ end ---@param questId number ---@return number|nil questType, string|nil questTag function QuestieDB.GetQuestTagInfo(questId) + -- Prefer the server's own live tag over static data whenever the quest is currently in + -- the quest log. Custom servers can reuse a Blizzard quest ID for different content (e.g. + -- Ascension's "Bride of the Embalmer" reusing ID 253, which Questie's static QuestTag.lua + -- correctly marks as non-group for retail's real quest 253), which the static tables below + -- have no way to know about. The live tag is authoritative once available, whether that + -- means it HAS a tag the static data misses, or has NO tag the static data wrongly assumes. + local cachedQuest = QuestLogCache.questLog_DO_NOT_MODIFY[questId] + if cachedQuest then + local liveTag = cachedQuest.questTag + if liveTag then + local liveTagId = QuestieCompat.QuestTagNameToId[liveTag] + if liveTagId then + return liveTagId, liveTag + end + else + return nil, nil + end + end + if questTagCorrections[questId] then return questTagCorrections[questId][1], questTagCorrections[questId][2] end