fix: WotLKDB plugin stats + kill tracking improvements
QuestieInit:LoadBaseDB: - Count WotLKDB records BEFORE clearing globals - Store counts in QuestieX_WotLKDB_Counts global for Loader.lua to read QuestieLearner:OnCombatLogEvent: - Only record kill coords for NPCs already in QuestieDB (quest objectives) or that were explicitly cached via target/mouseover (known quest givers) - Prevents every random mob kill from polluting the learner database
This commit is contained in:
@@ -434,6 +434,13 @@ function QuestieInit:LoadDatabase(key)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function QuestieInit:LoadBaseDB()
|
function QuestieInit:LoadBaseDB()
|
||||||
|
local function _countTable(t)
|
||||||
|
if type(t) ~= "table" then return 0 end
|
||||||
|
local n = 0
|
||||||
|
for _ in pairs(t) do n = n + 1 end
|
||||||
|
return n
|
||||||
|
end
|
||||||
|
|
||||||
local function _pullGlobal(dbKey, globalName)
|
local function _pullGlobal(dbKey, globalName)
|
||||||
if type(_G[globalName]) == "table" then
|
if type(_G[globalName]) == "table" then
|
||||||
QuestieDB[dbKey] = _G[globalName]
|
QuestieDB[dbKey] = _G[globalName]
|
||||||
@@ -442,6 +449,15 @@ function QuestieInit:LoadBaseDB()
|
|||||||
end
|
end
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Count BEFORE pulling so we have accurate numbers even after the globals are cleared
|
||||||
|
local _counts = {
|
||||||
|
QUEST = _countTable(_G["QuestieX_WotLKDB_quest"]),
|
||||||
|
NPC = _countTable(_G["QuestieX_WotLKDB_npc"]),
|
||||||
|
OBJECT = _countTable(_G["QuestieX_WotLKDB_object"]),
|
||||||
|
ITEM = _countTable(_G["QuestieX_WotLKDB_item"]),
|
||||||
|
}
|
||||||
|
|
||||||
local _pulled = {
|
local _pulled = {
|
||||||
quest = _pullGlobal("questData", "QuestieX_WotLKDB_quest"),
|
quest = _pullGlobal("questData", "QuestieX_WotLKDB_quest"),
|
||||||
npc = _pullGlobal("npcData", "QuestieX_WotLKDB_npc"),
|
npc = _pullGlobal("npcData", "QuestieX_WotLKDB_npc"),
|
||||||
@@ -449,6 +465,10 @@ function QuestieInit:LoadBaseDB()
|
|||||||
item = _pullGlobal("itemData", "QuestieX_WotLKDB_item"),
|
item = _pullGlobal("itemData", "QuestieX_WotLKDB_item"),
|
||||||
}
|
}
|
||||||
Questie:Debug(Questie.DEBUG_DEVELOP, "[DBDiag] WotLKDB pull: quest=" .. tostring(_pulled.quest) .. " npc=" .. tostring(_pulled.npc) .. " obj=" .. tostring(_pulled.object) .. " item=" .. tostring(_pulled.item))
|
Questie:Debug(Questie.DEBUG_DEVELOP, "[DBDiag] WotLKDB pull: quest=" .. tostring(_pulled.quest) .. " npc=" .. tostring(_pulled.npc) .. " obj=" .. tostring(_pulled.object) .. " item=" .. tostring(_pulled.item))
|
||||||
|
|
||||||
|
-- Persist counts so WotLKDB Loader.lua can populate plugin.stats after PLAYER_LOGIN
|
||||||
|
_G.QuestieX_WotLKDB_Counts = _counts
|
||||||
|
|
||||||
QuestieInit:LoadDatabase("npcData")
|
QuestieInit:LoadDatabase("npcData")
|
||||||
QuestieInit:LoadDatabase("objectData")
|
QuestieInit:LoadDatabase("objectData")
|
||||||
QuestieInit:LoadDatabase("questData")
|
QuestieInit:LoadDatabase("questData")
|
||||||
|
|||||||
@@ -743,6 +743,17 @@ end
|
|||||||
-- Combat log: kill tracking with GUID-keyed cache
|
-- Combat log: kill tracking with GUID-keyed cache
|
||||||
------------------------------------------------------------------------
|
------------------------------------------------------------------------
|
||||||
|
|
||||||
|
-- Returns true if npcId is referenced in any active quest objective (monster kill type)
|
||||||
|
local function IsQuestObjectiveNpc(npcId)
|
||||||
|
if not QuestieDB then return false end
|
||||||
|
-- Check if this NPC appears in DB as a quest NPC (spawns field [7] or quest objectives)
|
||||||
|
local dbNpc = QuestieDB.GetNPC and QuestieDB:GetNPC(npcId)
|
||||||
|
if dbNpc then return true end
|
||||||
|
-- Check npcDataOverrides (from learner or plugins)
|
||||||
|
if QuestieDB.npcDataOverrides and QuestieDB.npcDataOverrides[npcId] then return true end
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
function QuestieLearner:OnCombatLogEvent(...)
|
function QuestieLearner:OnCombatLogEvent(...)
|
||||||
local args = { CombatLogGetCurrentEventInfo and CombatLogGetCurrentEventInfo() or ... }
|
local args = { CombatLogGetCurrentEventInfo and CombatLogGetCurrentEventInfo() or ... }
|
||||||
local event = args[2]
|
local event = args[2]
|
||||||
@@ -762,16 +773,14 @@ function QuestieLearner:OnCombatLogEvent(...)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Fallback: hex-prefix scan for creatures not in cache
|
|
||||||
if not npcId and destGUID and string.sub(destGUID, 1, 2) == "0x" then
|
|
||||||
local prefix = string.upper(string.sub(destGUID, 3, 6))
|
|
||||||
if CREATURE_HEX_PREFIXES[prefix] then
|
|
||||||
-- We don't have the ID but we have a name; nothing useful to record
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
if not npcId or npcId <= 0 then return end
|
if not npcId or npcId <= 0 then return end
|
||||||
|
|
||||||
|
-- Only record kill coordinates for NPCs that are known quest objective targets
|
||||||
|
-- (already in DB, or previously cached from quest interaction).
|
||||||
|
-- This avoids polluting the learner with every random mob kill.
|
||||||
|
local isCached = _Learner.guidNpcCache and _Learner.guidNpcCache[destGUID] ~= nil
|
||||||
|
if not isCached and not IsQuestObjectiveNpc(npcId) then return end
|
||||||
|
|
||||||
-- TTL cleanup: drop entries older than 10 minutes
|
-- TTL cleanup: drop entries older than 10 minutes
|
||||||
if _Learner.guidNpcCache then
|
if _Learner.guidNpcCache then
|
||||||
local now = time()
|
local now = time()
|
||||||
|
|||||||
Reference in New Issue
Block a user