From f0550fddeea15a22b12cf6df92be0ddaceb57b4a Mon Sep 17 00:00:00 2001 From: Xurkon Date: Mon, 16 Mar 2026 22:33:31 -0500 Subject: [PATCH] feat: add DEBUG_LEARNER and DEBUG_COMMS categories for targeted learner/comms debugging --- Modules/Network/QuestieComms.lua | 22 +++++++++---------- .../AdvancedTab/QuestieOptionsAdvanced.lua | 2 ++ Modules/QuestieLearner.lua | 16 +++++++------- Questie.lua | 4 ++++ 4 files changed, 25 insertions(+), 19 deletions(-) diff --git a/Modules/Network/QuestieComms.lua b/Modules/Network/QuestieComms.lua index 400dbfa..71288e9 100644 --- a/Modules/Network/QuestieComms.lua +++ b/Modules/Network/QuestieComms.lua @@ -221,7 +221,7 @@ end -- Removes the quest from everyones external quest-log function _QuestieComms:BroadcastQuestRemove(questId) -- broadcast quest update to group or raid local partyType = QuestiePlayer:GetGroupType() - Questie:Debug(Questie.DEBUG_DEVELOP, "[QuestieComms:BroadcastQuestRemove] QuestId:", questId, "partyType:", tostring(partyType)) + Questie:Debug(Questie.DEBUG_COMMS, "[QuestieComms:BroadcastQuestRemove] QuestId:", questId, "partyType:", tostring(partyType)) if partyType then --Do we really need to make this? local questPacket = _QuestieComms:CreatePacket(_QuestieComms.QC_ID_BROADCAST_QUEST_REMOVE); @@ -523,7 +523,7 @@ function _QuestieComms:BroadcastQuestLog(eventName, sendMode, targetPlayer) -- b return end local partyType = QuestiePlayer:GetGroupType() - Questie:Debug(Questie.DEBUG_DEVELOP, "[QuestieComms] Message", eventName, "partyType:", tostring(partyType)) + Questie:Debug(Questie.DEBUG_COMMS, "[QuestieComms] Message", eventName, "partyType:", tostring(partyType)) if partyType then local sorted = {} @@ -640,7 +640,7 @@ function _QuestieComms:BroadcastQuestLogV2(eventName, sendMode, targetPlayer) -- return end local partyType = QuestiePlayer:GetGroupType() - Questie:Debug(Questie.DEBUG_DEVELOP, "[QuestieComms] Message", eventName, "partyType:", tostring(partyType)) + Questie:Debug(Questie.DEBUG_COMMS, "[QuestieComms] Message", eventName, "partyType:", tostring(partyType)) if partyType then local sorted = {} @@ -754,7 +754,7 @@ end -- The "Hi" of questie, request others to send their questlog. function _QuestieComms:RequestQuestLog(eventName) -- broadcast quest update to group or raid local partyType = QuestiePlayer:GetGroupType() - Questie:Debug(Questie.DEBUG_DEVELOP, "[QuestieComms] Message", eventName, "partyType:", tostring(partyType)) + Questie:Debug(Questie.DEBUG_COMMS, "[QuestieComms] Message", eventName, "partyType:", tostring(partyType)) if partyType then --Do we really need to make this? local questPacket = _QuestieComms:CreatePacket(_QuestieComms.QC_ID_REQUEST_FULL_QUESTLIST); @@ -867,7 +867,7 @@ _QuestieComms.packets = { if not remoteQuestPacket then Questie:Error("[QuestieComms] QC_ID_BROADCAST_QUEST_REMOVE no remoteQuestPacket") end - Questie:Debug(Questie.DEBUG_DEVELOP, "[QuestieComms] Received: QC_ID_BROADCAST_QUEST_REMOVE") + Questie:Debug(Questie.DEBUG_COMMS, "[QuestieComms] Received: QC_ID_BROADCAST_QUEST_REMOVE") local playerName = remoteQuestPacket.playerName; local questId = remoteQuestPacket.id; @@ -985,11 +985,11 @@ function _QuestieComms:Broadcast(packet) packet.writeMode = nil -- we dont need to include these in the packet data if packetWriteMode == _QuestieComms.QC_WRITE_WHISPER then local compressedData = QuestieSerializer:Serialize(packet); - Questie:Debug(Questie.DEBUG_DEVELOP,"send(|cFFFF2222", string.len(compressedData), "|r)") + Questie:Debug(Questie.DEBUG_COMMS,"send(|cFFFF2222", string.len(compressedData), "|r)") Questie:SendCommMessage(_QuestieComms.prefix, compressedData, packetWriteMode, packetTarget, packetPriority) elseif packetWriteMode == _QuestieComms.QC_WRITE_CHANNEL then local compressedData = QuestieSerializer:Serialize(packet); - Questie:Debug(Questie.DEBUG_DEVELOP,"send(|cFFFF2222", string.len(compressedData), "|r)") + Questie:Debug(Questie.DEBUG_COMMS,"send(|cFFFF2222", string.len(compressedData), "|r)") -- Always do channel messages as BULK priority Questie:SendCommMessage(_QuestieComms.prefix, compressedData, packetWriteMode, GetChannelName("questiecom"), "BULK") --OLD: C_ChatInfo.SendAddonMessage("questie", compressedData, "CHANNEL", GetChannelName("questiecom")) @@ -1001,7 +1001,7 @@ function _QuestieComms:Broadcast(packet) Questie:SendCommMessage(_QuestieComms.prefix, compressedData, packetWriteMode, "BULK") else local compressedData = QuestieSerializer:Serialize(packet); - Questie:Debug(Questie.DEBUG_DEVELOP, "send(|cFFFF2222", string.len(compressedData), "|r)") + Questie:Debug(Questie.DEBUG_COMMS, "send(|cFFFF2222", string.len(compressedData), "|r)") Questie:SendCommMessage(_QuestieComms.prefix, compressedData, packetWriteMode, nil, packetPriority) --OLD: C_ChatInfo.SendAddonMessage("questie", compressedData, packet.writeMode) end @@ -1013,7 +1013,7 @@ end function _QuestieComms:OnCommReceived_unsafe(message, distribution, sender) --print("[" .. distribution .."][" .. sender .. "] " .. message) - Questie:Debug(Questie.DEBUG_DEVELOP, "|cFF22FF22", "sender:", "|r", sender, "distribution:", distribution, "Packet length:",string.len(message)) + Questie:Debug(Questie.DEBUG_COMMS, "|cFF22FF22", "sender:", "|r", sender, "distribution:", distribution, "Packet length:",string.len(message)) if message and sender and sender ~= UnitName("player") then local decompressedData if distribution == "YELL" then @@ -1027,7 +1027,7 @@ function _QuestieComms:OnCommReceived_unsafe(message, distribution, sender) --Check if the message version is the same base value if distribution == "YELL" and decompressedData.msgId and _QuestieComms.packets[decompressedData.msgId] then decompressedData.playerName = sender; - Questie:Debug(Questie.DEBUG_DEVELOP, "Executing message ID: ", decompressedData.msgId, "From: ", sender) + Questie:Debug(Questie.DEBUG_COMMS, "Executing message ID: ", decompressedData.msgId, "From: ", sender) _QuestieComms.packets[decompressedData.msgId].read(decompressedData) elseif(decompressedData and decompressedData.msgVer and floor(decompressedData.msgVer) == floor(commMessageVersion)) then if(decompressedData and decompressedData.msgId and _QuestieComms.packets[decompressedData.msgId]) then @@ -1049,7 +1049,7 @@ function _QuestieComms:OnCommReceived_unsafe(message, distribution, sender) end decompressedData.playerName = sender; - Questie:Debug(Questie.DEBUG_DEVELOP, "Executing message ID: ", decompressedData.msgId, "From: ", sender, "MessageVersion:", decompressedData.msgVer) + Questie:Debug(Questie.DEBUG_COMMS, "Executing message ID: ", decompressedData.msgId, "From: ", sender, "MessageVersion:", decompressedData.msgVer) _QuestieComms.packets[decompressedData.msgId].read(decompressedData); else diff --git a/Modules/Options/AdvancedTab/QuestieOptionsAdvanced.lua b/Modules/Options/AdvancedTab/QuestieOptionsAdvanced.lua index 4a1b3d6..b733d55 100644 --- a/Modules/Options/AdvancedTab/QuestieOptionsAdvanced.lua +++ b/Modules/Options/AdvancedTab/QuestieOptionsAdvanced.lua @@ -391,6 +391,8 @@ function QuestieOptions.tabs.advanced:Initialize() [2] = "DEBUG_INFO", [3] = "DEBUG_DEVELOP", [4] = "DEBUG_SPAM", + [5] = "DEBUG_LEARNER", + [6] = "DEBUG_COMMS", }, order = 5.09, name = function() return l10n('Debug level to print'); end, diff --git a/Modules/QuestieLearner.lua b/Modules/QuestieLearner.lua index 254db90..45ec59e 100644 --- a/Modules/QuestieLearner.lua +++ b/Modules/QuestieLearner.lua @@ -162,7 +162,7 @@ function QuestieLearner:LearnNPC(npcId, name, level, subName, npcFlags, factionS existing.mc = (existing.mc or 0) + 1 if isNew then - Questie:Debug(Questie.DEBUG_DEVELOP, "[QuestieLearner] New NPC learned:", npcId, name or "?") + Questie:Debug(Questie.DEBUG_LEARNER, "[QuestieLearner] New NPC learned:", npcId, name or "?") end _Learner:BroadcastIfCommsAvailable("NPC", npcId, existing) end @@ -179,11 +179,11 @@ end -- [17] details text [18] finishText [19] completedText function QuestieLearner:LearnQuest(questId, data) if not self:IsEnabled() then - Questie:Debug(Questie.DEBUG_DEVELOP, "[QuestieLearner] LearnQuest blocked: learner not enabled") + Questie:Debug(Questie.DEBUG_LEARNER, "[QuestieLearner] LearnQuest blocked: learner not enabled") return end if not Questie.db.global.learnedData.settings.learnQuests then - Questie:Debug(Questie.DEBUG_DEVELOP, "[QuestieLearner] LearnQuest blocked: learnQuests=", tostring(Questie.db.global.learnedData.settings.learnQuests)) + Questie:Debug(Questie.DEBUG_LEARNER, "[QuestieLearner] LearnQuest blocked: learnQuests=", tostring(Questie.db.global.learnedData.settings.learnQuests)) return end if not questId or questId <= 0 then return end @@ -204,7 +204,7 @@ function QuestieLearner:LearnQuest(questId, data) existing.mc = (existing.mc or 0) + 1 if isNew then - Questie:Debug(Questie.DEBUG_DEVELOP, "[QuestieLearner] New quest learned:", questId, existing[1] or "?") + Questie:Debug(Questie.DEBUG_LEARNER, "[QuestieLearner] New quest learned:", questId, existing[1] or "?") end _Learner:BroadcastIfCommsAvailable("QUEST", questId, existing) end @@ -259,7 +259,7 @@ function QuestieLearner:LearnItem(itemId, name, itemLevel, requiredLevel, itemCl existing.mc = (existing.mc or 0) + 1 if isNew then - Questie:Debug(Questie.DEBUG_DEVELOP, "[QuestieLearner] New item learned:", itemId, name or "?") + Questie:Debug(Questie.DEBUG_LEARNER, "[QuestieLearner] New item learned:", itemId, name or "?") end _Learner:BroadcastIfCommsAvailable("ITEM", itemId, existing) end @@ -313,7 +313,7 @@ function QuestieLearner:LearnObject(objectId, name) existing.mc = (existing.mc or 0) + 1 if isNew then - Questie:Debug(Questie.DEBUG_DEVELOP, "[QuestieLearner] New object learned:", objectId, name or "?") + Questie:Debug(Questie.DEBUG_LEARNER, "[QuestieLearner] New object learned:", objectId, name or "?") end _Learner:BroadcastIfCommsAvailable("OBJECT", objectId, existing) end @@ -650,7 +650,7 @@ end -- Fires after the player clicks Accept; questLogIndex and questId are available here function QuestieLearner:OnQuestAccepted(questLogIndex, questId) - Questie:Debug(Questie.DEBUG_DEVELOP, "[QuestieLearner] OnQuestAccepted: idx=" .. tostring(questLogIndex) .. " id=" .. tostring(questId)) + Questie:Debug(Questie.DEBUG_LEARNER, "[QuestieLearner] OnQuestAccepted: idx=" .. tostring(questLogIndex) .. " id=" .. tostring(questId)) -- Resolve questId from log index if not provided if not questId or questId <= 0 then if questLogIndex then @@ -881,7 +881,7 @@ function QuestieLearner:OnCombatLogEvent(...) end end - Questie:Debug(Questie.DEBUG_DEVELOP, "[QuestieLearner] Kill recorded: NPC", npcId, destName) + Questie:Debug(Questie.DEBUG_LEARNER, "[QuestieLearner] Kill recorded: NPC", npcId, destName) self:LearnNPC(npcId, destName, nil, nil, nil, nil) end diff --git a/Questie.lua b/Questie.lua index aa5b0e9..4a8e0d8 100644 --- a/Questie.lua +++ b/Questie.lua @@ -139,6 +139,8 @@ Questie.DEBUG_ELEVATED = 2 ^ 1 Questie.DEBUG_INFO = 2 ^ 2 Questie.DEBUG_DEVELOP = 2 ^ 3 Questie.DEBUG_SPAM = 2 ^ 4 +Questie.DEBUG_LEARNER = 2 ^ 5 +Questie.DEBUG_COMMS = 2 ^ 6 function Questie:Debug(msgDebugLevel, ...) if (Questie.db.profile.debugEnabled) then @@ -154,6 +156,8 @@ function Questie:Debug(msgDebugLevel, ...) if (band(msgDebugLevel, Questie.DEBUG_INFO) ~= 0) then prefix = prefix .. "|cff00bc32[INFO]|r " end if (band(msgDebugLevel, Questie.DEBUG_DEVELOP) ~= 0) then prefix = prefix .. "|cff7c83ff[DEVELOP]|r " end if (band(msgDebugLevel, Questie.DEBUG_SPAM) ~= 0) then prefix = prefix .. "|cffff8484[SPAM]|r " end + if (band(msgDebugLevel, Questie.DEBUG_LEARNER) ~= 0) then prefix = prefix .. "|cff00e5ff[LEARNER]|r " end + if (band(msgDebugLevel, Questie.DEBUG_COMMS) ~= 0) then prefix = prefix .. "|cffff9f00[COMMS]|r " end if orig_Print then orig_Print(Questie, prefix, ...)