fix: suppress duplicate combat log npc learns

This commit is contained in:
Xurkon
2026-06-06 07:15:05 -05:00
parent 3f105e5782
commit 85d4a7a1e4
2 changed files with 50 additions and 2 deletions
+9 -2
View File
@@ -1406,6 +1406,8 @@ function QuestieLearner:LearnNPC(npcId, name, level, subName, npcFlags, factionS
CrossLinkAfterNPC(npcId) CrossLinkAfterNPC(npcId)
end end
_Learner:BroadcastIfCommsAvailable("NPC", npcId, existing) _Learner:BroadcastIfCommsAvailable("NPC", npcId, existing)
return isNew
end end
------------------------------------------------------------------------ ------------------------------------------------------------------------
@@ -3728,9 +3730,14 @@ function QuestieLearner:OnCombatLogEvent(timestamp, eventType, srcGUID, srcName,
-- Questie:Debug(Questie.DEBUG_LEARNER, "[QuestieLearner] Kill cached for correlation:", npcId, dstName, "@", tostring(px), tostring(py), "zone", tostring(zoneId)) -- Questie:Debug(Questie.DEBUG_LEARNER, "[QuestieLearner] Kill cached for correlation:", npcId, dstName, "@", tostring(px), tostring(py), "zone", tostring(zoneId))
end end
-- Unconditionally map the spawn position for Ascension DB building -- Unconditionally map the spawn position for Ascension DB building.
-- Only announce the first time we learn a unique NPC ID; repeated kills
-- still update evidence but should not spam "learned" debug output.
local npcWasKnown = Questie.dbLearner.global.npcs[npcId] ~= nil
self:LearnNPC(npcId, name, nil, nil, nil, nil, px, py, zoneId) self:LearnNPC(npcId, name, nil, nil, nil, nil, px, py, zoneId)
Questie:Debug(Questie.DEBUG_LEARNER, "[QuestieLearner] Combat-log learned NPC:", eventType, npcId, name or "?") if not npcWasKnown then
Questie:Debug(Questie.DEBUG_LEARNER, "[QuestieLearner] Combat-log learned NPC:", eventType, npcId, name or "?")
end
-- Phase 2: store per-GUID spawn evidence for weighted merge -- Phase 2: store per-GUID spawn evidence for weighted merge
self:_StoreGuidSpawnEvidence(npcId, dstGUID, zoneId, px, py) self:_StoreGuidSpawnEvidence(npcId, dstGUID, zoneId, px, py)
+41
View File
@@ -215,6 +215,47 @@ describe("QuestieLearner kill-path batching", function()
assert.equals(2, table.getn(queuedTimers)) assert.equals(2, table.getn(queuedTimers))
end) end)
it("only announces combat-log learning once per unique NPC id", function()
local debugMessages = {}
local originalDebug = Questie.Debug
Questie.Debug = function(self, level, ...)
local parts = { ... }
for i = 1, table.getn(parts) do
if parts[i] == "[QuestieLearner] Combat-log learned NPC:" then
debugMessages[table.getn(debugMessages) + 1] = level
break
end
end
end
QuestieLearner:OnCombatLogEvent(
1234,
"PARTY_KILL",
UnitGUID("player"),
UnitName("player"),
nil,
"Creature-0-0-0-0-7010-0000000001",
"Unique Boar",
nil
)
QuestieLearner:OnCombatLogEvent(
1235,
"PARTY_KILL",
UnitGUID("player"),
UnitName("player"),
nil,
"Creature-0-0-0-0-7010-0000000002",
"Unique Boar",
nil
)
assert.is_table(Questie.dbLearner.global.npcs[7010])
assert.equals(1, table.getn(debugMessages))
Questie.Debug = originalDebug
end)
it("still learns credited UNIT_DIED combat-log events when PARTY_KILL is absent", function() it("still learns credited UNIT_DIED combat-log events when PARTY_KILL is absent", function()
QuestieLearner:OnCombatLogEvent( QuestieLearner:OnCombatLogEvent(
1234, 1234,