fix: use GetQuestLogTitle position 9 for questID in 3.3.5 and add full-log fallback scan
This commit is contained in:
@@ -650,20 +650,33 @@ end
|
|||||||
|
|
||||||
-- Fires after the player clicks Accept; questLogIndex and questId are available here
|
-- Fires after the player clicks Accept; questLogIndex and questId are available here
|
||||||
function QuestieLearner:OnQuestAccepted(questLogIndex, questId)
|
function QuestieLearner:OnQuestAccepted(questLogIndex, questId)
|
||||||
Questie:Debug(Questie.DEBUG_LEARNER, "[QuestieLearner] OnQuestAccepted: idx=" .. tostring(questLogIndex) .. " id=" .. tostring(questId))
|
-- 3.3.5 API: GetQuestLogTitle(i) returns title,level,tag,suggestedGroup,isHeader,isCollapsed,isComplete,isDaily,questID
|
||||||
-- Resolve questId from log index if not provided
|
-- questID is at position 9; resolve it from the log if the event didn't pass it
|
||||||
if not questId or questId <= 0 then
|
if not questId or questId <= 0 then
|
||||||
if questLogIndex then
|
if questLogIndex then
|
||||||
local _, _, _, _, _, _, _, id = GetQuestLogTitle(questLogIndex)
|
questId = select(9, GetQuestLogTitle(questLogIndex))
|
||||||
questId = id
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
-- Fallback: scan all log entries for the most recently added quest
|
||||||
|
if not questId or questId <= 0 then
|
||||||
|
for i = 1, GetNumQuestLogEntries() do
|
||||||
|
local title, _, _, _, isHeader, _, _, _, id = GetQuestLogTitle(i)
|
||||||
|
if not isHeader and id and id > 0 and not Questie.db.global.learnedData.quests[id] then
|
||||||
|
local dbQuest = QuestieDB and QuestieDB.npcData and QuestieDB.questData and QuestieDB.questData[id]
|
||||||
|
if not dbQuest then
|
||||||
|
questId = id
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
Questie:Debug(Questie.DEBUG_LEARNER, "[QuestieLearner] OnQuestAccepted: idx=" .. tostring(questLogIndex) .. " id=" .. tostring(questId))
|
||||||
if not questId or questId <= 0 then return end
|
if not questId or questId <= 0 then return end
|
||||||
|
|
||||||
-- Build data table from quest log entry (richest source)
|
-- Build data table from quest log entry (richest source)
|
||||||
local data = {}
|
local data = {}
|
||||||
if questLogIndex then
|
if questLogIndex then
|
||||||
local title, level, _, isHeader, _, isComplete, frequency, id = GetQuestLogTitle(questLogIndex)
|
local title, level, _, _, isHeader, _, isComplete, isDaily, id = GetQuestLogTitle(questLogIndex)
|
||||||
if not isHeader then
|
if not isHeader then
|
||||||
data[1] = title
|
data[1] = title
|
||||||
data[5] = level and level > 0 and level or nil -- questLevel
|
data[5] = level and level > 0 and level or nil -- questLevel
|
||||||
|
|||||||
Reference in New Issue
Block a user