From 31ddb9a53669dfb781c5685aa4df139f23954730 Mon Sep 17 00:00:00 2001 From: Xurkon Date: Mon, 1 Jun 2026 18:16:05 -0500 Subject: [PATCH] fix(quest): require multi-position learned spawns before overriding AscensionDB MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Add local _CountUniqueSpawnPositions helper (counts unique {x, y} across all zone buckets in a spawn table). - Gate the prioritizeMyData check on ld.settings.enabled, matching the Database/QuestieDB.lua fix — when the learner is fully disabled, the override lookup is skipped entirely. - Replace the NPC-15274-specific debug print in the monster() spawn selector with a universal reliability check: the learner data is only used when CountUniqueSpawnPositions(learnedSpawns) > 1. This is the consumer-side enforcement of the QuestieLearner cleanup (commit e71e072). Singleton-position spawn entries are typically the player's current position captured during quest dialog (accept/turn-in) rather than real kill evidence. By requiring at least 2 unique positions, we avoid letting that pollution clobber AscensionDB curated spawn data. The NPC-15274-specific debug print was removed — the universal check replaces it, and the diagnostic it provided is now expressed through the Questie DEBUG_DEVELOP log line (which still emits when the new condition is met). --- Modules/Quest/QuestieQuestPrivates.lua | 49 ++++++++++++++------------ 1 file changed, 27 insertions(+), 22 deletions(-) diff --git a/Modules/Quest/QuestieQuestPrivates.lua b/Modules/Quest/QuestieQuestPrivates.lua index 75c6767..209e4b5 100644 --- a/Modules/Quest/QuestieQuestPrivates.lua +++ b/Modules/Quest/QuestieQuestPrivates.lua @@ -26,6 +26,30 @@ local function _GetIconScaleForLoot() return Questie.db.profile.lootScale or 1 end +local function _CountUniqueSpawnPositions(spawns) + if type(spawns) ~= "table" then return 0 end + + local seen = {} + local count = 0 + for _, coords in pairs(spawns) do + if type(coords) == "table" then + for _, coord in ipairs(coords) do + local x = coord and coord[1] + local y = coord and coord[2] + if x and y then + local key = tostring(x) .. "," .. tostring(y) + if not seen[key] then + seen[key] = true + count = count + 1 + end + end + end + end + end + + return count +end + ---@class SpawnListBase ---@field Name string @@ -155,7 +179,7 @@ monster = function(npcId, objective) -- replace retail positions (e.g. format migration gaps, timing issues). if Questie.IsAscension and Questie.dbLearner and Questie.dbLearner.global then local ld = Questie.dbLearner.global - if ld.settings and ld.settings.prioritizeMyData then + if ld.settings and ld.settings.enabled and ld.settings.prioritizeMyData then local learnedNpc = ld.npcs and ld.npcs[npcId] if learnedNpc then local learnedSpawns = learnedNpc[7] @@ -168,28 +192,9 @@ monster = function(npcId, objective) and QuestieDB.ascensionOverrideKeys["NPC"] and QuestieDB.ascensionOverrideKeys["NPC"][npcId] and QuestieDB.ascensionOverrideKeys["NPC"][npcId][7] - if npcId == 15274 then - -- Count spawn entries per zone key - local spawnZones = "" - if type(spawns) == "table" then - for zk, coords in pairs(spawns) do - spawnZones = spawnZones .. "z" .. tostring(zk) .. "=" .. tostring(type(coords) == "table" and #coords or "?") .. " " - end - end - local learnedZones = "" - if type(learnedSpawns) == "table" then - for zk, coords in pairs(learnedSpawns) do - learnedZones = learnedZones .. "z" .. tostring(zk) .. "=" .. tostring(type(coords) == "table" and #coords or "?") .. " " - end - end - print(string.format("[QD] NPC 15274: dbSpawns={%s} learnedSpawns={%s} mc=%s threshold=%s ascProtected=%s -> uselearner=%s", - spawnZones, learnedZones, - tostring(learnedNpc.mc), tostring(threshold), - tostring(ascProtected), - tostring(learnedSpawns and next(learnedSpawns) and learnedNpc.mc and learnedNpc.mc >= threshold and not ascProtected))) - end + local hasReliableLearnedSpawns = _CountUniqueSpawnPositions(learnedSpawns) > 1 if learnedSpawns and next(learnedSpawns) and learnedNpc.mc and learnedNpc.mc >= threshold - and not ascProtected then + and hasReliableLearnedSpawns and not ascProtected then Questie:Debug(Questie.DEBUG_DEVELOP, "[monster] Preferring learned spawns for NPC:", npcId, "(mc=" .. tostring(learnedNpc.mc) .. ")") spawns = learnedSpawns isLearned = true