CTMod Core Other bugging on GetLogIndexForQuestID
keiichi25 opened this issue ยท 3 comments
Getting constant bug pings with CTMod Core Other with the following:
25x bad argument #1 to '?' (outside of expected range -2147483648 to 2147483647 - Usage: local questLogIndex = C_QuestLog.GetLogIndexForQuestID(questID))
[string "=[C]"]: in function GetLogIndexForQuestID' [string "@CT_Core/CT_Core_Other.lua"]:691: in function <CT_Core/CT_Core_Other.lua:690> [string "=[C]"]: in function
GetBlock'
[string "@Blizzard_ObjectiveTracker/Blizzard_AutoQuestPopUpTracker.lua"]:82: in function AutoQuestPopupTracker_Update' [string "@Blizzard_ObjectiveTracker/Blizzard_QuestObjectiveTracker.lua"]:466: in function
Update'
[string "@Blizzard_ObjectiveTracker/Blizzard_ObjectiveTracker.lua"]:1462: in function <...zzard_ObjectiveTracker/Blizzard_ObjectiveTracker.lua:1393>
[string "=[C]"]: ?
[string "=[C]"]: in function `ObjectiveTracker_Update'
[string "@Blizzard_ObjectiveTracker/Blizzard_ObjectiveTracker.lua"]:987: in function <...zzard_ObjectiveTracker/Blizzard_ObjectiveTracker.lua:896>
Locals:
(*temporary) = "bad argument #1 to '?' (outside of expected range -2147483648 to 2147483647 - Usage: local questLogIndex = C_QuestLog.GetLogIndexForQuestID(questID))"
(I posted this on Curseforge back on Oct 3rd, but just created an account here)
This error appears (at least for me) only when a new quest is automatically offered (giving you an accept/decline box even though the quest was immediately added to your quest log). After some research (and teaching myself some lua basics), I found that what happens is that the questID has the word "OFFER" at the end. For example, the BC timewalking weekly, "The Swirling Vial", is presented when the item drops in your bags. At that point, before you accept it, the questID in your quest log is "40168OFFER".
I made a small change to CT_Core_Other.lua to verify that this was the problem and the change seemed to fix it. In line 691, I changed "C_QuestLog.GetLogIndexForQuestID(id)" to "C_QuestLog.GetLogIndexForQuestID(string.gsub(id,"%D+",""))", removing any non-numeric characters from id, changing "40168OFFER" to "40168". This may not be the best fix, but it worked to confirm the issue.
Thanks. I'll merge that with a simple check to make sure that a number even exists (in case Blizzard does something even more unusual).
hooksecurefunc(QUEST_TRACKER_MODULE, "GetBlock", function(__, id)
if type(id) == "string" then
id = tonumber(string.gsub(id, "%D+",""))
end
if id then
local questLogIndex = C_QuestLog.GetLogIndexForQuestID(id)
if questLogIndex then
info = C_QuestLog.GetInfo(questLogIndex)
end
end
end)
The worst that can happen is that the questLogIndex can't be found; and then it already omits adding a level to that quest.