fix: QUEST_ACCEPTED in 3.3.5 passes questID directly as first arg, not log index

This commit is contained in:
Xurkon
2026-03-16 22:42:05 -05:00
parent f0327da3e5
commit 5e35aa6cb5
+22 -38
View File
@@ -648,60 +648,44 @@ function QuestieLearner:OnQuestComplete()
end
end
-- Fires after the player clicks Accept; questLogIndex and questId are available here
function QuestieLearner:OnQuestAccepted(questLogIndex, questId)
-- 3.3.5 API: GetQuestLogTitle(i) returns title,level,tag,suggestedGroup,isHeader,isCollapsed,isComplete,isDaily,questID
-- 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 questLogIndex then
questId = select(9, GetQuestLogTitle(questLogIndex))
end
end
-- Fallback: scan all log entries for the most recently added quest
-- Fires when a quest is accepted; in 3.3.5 the first (and only) arg IS the questID directly
function QuestieLearner:OnQuestAccepted(questId)
-- Fallback: scan log for an unknown quest in case the server sends log index instead
if not questId or questId <= 0 then
for i = 1, GetNumQuestLogEntries() do
local title, _, _, _, isHeader, _, _, _, id = GetQuestLogTitle(i)
local _, _, _, _, 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
if not (QuestieDB and QuestieDB.questData and QuestieDB.questData[id]) then
questId = id
break
end
end
end
end
Questie:Debug(Questie.DEBUG_LEARNER, "[QuestieLearner] OnQuestAccepted: idx=" .. tostring(questLogIndex) .. " id=" .. tostring(questId))
Questie:Debug(Questie.DEBUG_LEARNER, "[QuestieLearner] OnQuestAccepted id=" .. tostring(questId))
if not questId or questId <= 0 then return end
-- Build data table from quest log entry (richest source)
-- Build data table from quest log (scan for matching entry)
local data = {}
if questLogIndex then
local title, level, _, _, isHeader, _, isComplete, isDaily, id = GetQuestLogTitle(questLogIndex)
if not isHeader then
data[1] = title
data[5] = level and level > 0 and level or nil -- questLevel
end
-- Objectives from leaderboard
local numObj = GetNumQuestLeaderBoards and GetNumQuestLeaderBoards(questLogIndex) or 0
if numObj > 0 then
local objList = {}
for i = 1, numObj do
local text = GetQuestLogLeaderBoard and GetQuestLogLeaderBoard(i, questLogIndex)
if text then table.insert(objList, text) end
for i = 1, GetNumQuestLogEntries() do
local title, level, _, _, isHeader, _, _, _, id = GetQuestLogTitle(i)
if not isHeader and id == questId then
data[1] = title
data[5] = level and level > 0 and level or nil
local numObj = GetNumQuestLeaderBoards and GetNumQuestLeaderBoards(i) or 0
if numObj > 0 then
local objList = {}
for j = 1, numObj do
local objText = GetQuestLogLeaderBoard(j, i)
if objText then objList[#objList + 1] = objText end
end
if #objList > 0 then data[10] = objList end
end
if #objList > 0 then data[6] = objList end
break
end
-- Required money
local reqMoney = GetQuestLogRequiredMoney and GetQuestLogRequiredMoney(questLogIndex) or 0
if reqMoney and reqMoney > 0 then data[7] = reqMoney end
else
-- Fallback: use GetTitleText from the still-open quest frame
data[1] = GetTitleText and GetTitleText() or nil
end
-- Zone sort: record current map zone
-- Zone: record current map zone
local zoneId = GetZoneId()
if zoneId and zoneId > 0 then data[8] = zoneId end