fix(learner): restore persisted NPC spawns into override on load

InjectLearnedData stripped each learned NPC's spawn field [7] when injecting
into npcDataOverrides (CopyWithoutField(data,7) / k~=7), deferring to
_MergeSpawnEvidence. That promoter only runs on live kill evidence, so spawns
learned in a prior session never returned to the queryable DB on /reload, and
a freshly accepted quest (8325 -> Mana Wyrm 15274 on Sunstrider) had no pins
until the mob was re-killed.

Re-merge the saved [7] spawns into the override at injection time, normalized
to the canonical uiMapId via NormalizeSpawnZoneKey (so an areaId left by the
uiMapId->areaId migration, e.g. 3431/3430, maps back to 1241 for the renderer/
HBD), deep-merged with InsertIfNewBucket, and gated by IsAscensionProtected so
curated AscensionDB coords are never overwritten (always restored in learner
mode; in auto mode only non-curated NPCs). Regression from 7ce0cdc.
This commit is contained in:
Xurkon
2026-06-08 16:51:58 -05:00
parent c7af49d8bd
commit da5546fde0
2 changed files with 35 additions and 1 deletions
+1 -1
View File
@@ -31,7 +31,7 @@
- **[Tooltip - Item Starts Quest]** Item tooltips now surface a "Drops a quest !" line with the quest title when the item has a non-zero `startQuest` value in the static DB / Ascension override table and the player does not already have the quest (active or turned in). The item→quest relationship is a build-time DB field — we never know it ahead of runtime observation — so it is read directly from `QueryItemSingle` at hover time. The line uses `QuestieLib:GetColoredQuestName` so the quest title respects the same level/complete state formatting the rest of Questie uses. - **[Tooltip - Item Starts Quest]** Item tooltips now surface a "Drops a quest !" line with the quest title when the item has a non-zero `startQuest` value in the static DB / Ascension override table and the player does not already have the quest (active or turned in). The item→quest relationship is a build-time DB field — we never know it ahead of runtime observation — so it is read directly from `QueryItemSingle` at hover time. The line uses `QuestieLib:GetColoredQuestName` so the quest title respects the same level/complete state formatting the rest of Questie uses.
- **[QuestieDB - Auto Mode Learner Enrichment]** In `auto` data-source mode, `QuestieDB.GetQuest` now overlays the SavedVariables learner payload on top of the static DB record, filling only fields the static record leaves `nil` and deep-merging `objectives`/`objIndex`. This fixes quests like 8325 where the shipped DB carries only a stub record but QuestieLearner holds the real objective mapping — previously the stub blocked the learned objectives from ever surfacing. Learner data never clobbers a present static value, so it strictly enriches and cannot regress shipped data. - **[QuestieDB - Auto Mode Learner Enrichment]** In `auto` data-source mode, `QuestieDB.GetQuest` now overlays the SavedVariables learner payload on top of the static DB record, filling only fields the static record leaves `nil` and deep-merging `objectives`/`objIndex`. This fixes quests like 8325 where the shipped DB carries only a stub record but QuestieLearner holds the real objective mapping — previously the stub blocked the learned objectives from ever surfacing. Learner data never clobbers a present static value, so it strictly enriches and cannot regress shipped data.
- **[QuestieLearner - Accept-Time Objective Pin Seeding]** `OnQuestAccepted` now seeds objective pins directly from the SavedVariables learner payload (`objIndex`) the moment a quest is accepted in learner mode, instead of waiting for quest-log text sync. This makes quests like 8325 spawn pins immediately on accept when the objective mapping already exists. The accept-time ID lookup was also widened from `killcredit` to also cover `monster` objectives, and now falls back to `objData.Id` when no `IdList` is present, catching cases where the quest-log text does not normalize cleanly to the NPC name. - **[QuestieLearner - Accept-Time Objective Pin Seeding]** `OnQuestAccepted` now seeds objective pins directly from the SavedVariables learner payload (`objIndex`) the moment a quest is accepted in learner mode, instead of waiting for quest-log text sync. This makes quests like 8325 spawn pins immediately on accept when the objective mapping already exists. The accept-time ID lookup was also widened from `killcredit` to also cover `monster` objectives, and now falls back to `objData.Id` when no `IdList` is present, catching cases where the quest-log text does not normalize cleanly to the NPC name.
- **[Options - Tab Table Vararg Typo]** Five Options files initialized their tab tables with `{ ... }` instead of `{}` (`QuestieOptions.tabs` plus the Arrow, General, Keybinds, and Tracker tabs). At chunk scope WoW passes `...` = `(addonName, addonTable)`, so each table was seeded with two stray junk entries (`[1]="Questie"`, `[2]=<addonTable>`) instead of being empty, and the `{ ... }` expression is also a hard parse error under strict Lua 5.0. Changed all five to `{}`. - **[QuestieLearner - Persisted Spawn Restore on Load]** `InjectLearnedData` stripped each learned NPC's spawn field (`[7]`) when injecting into `QuestieDB.npcDataOverrides`, deferring to `_MergeSpawnEvidence`. But that promoter only runs on **live kill evidence**, so spawns learned in a prior session never returned to the queryable DB on `/reload` — pins for a freshly accepted quest (e.g. 8325 → Mana Wyrm 15274 on Sunstrider) stayed missing until the player re-killed the mob. The saved spawns are now re-merged into the override at injection time, normalized to the canonical uiMapId (so an areaId stored by the zone migration, e.g. 3431/3430, maps back to 1241 for the renderer/HBD) and gated by `IsAscensionProtected` so curated AscensionDB coords are never overwritten (always restored in learner mode; in auto mode only non-curated NPCs). Regression introduced by commit `7ce0cdc`. Five Options files initialized their tab tables with `{ ... }` instead of `{}` (`QuestieOptions.tabs` plus the Arrow, General, Keybinds, and Tracker tabs). At chunk scope WoW passes `...` = `(addonName, addonTable)`, so each table was seeded with two stray junk entries (`[1]="Questie"`, `[2]=<addonTable>`) instead of being empty, and the `{ ... }` expression is also a hard parse error under strict Lua 5.0. Changed all five to `{}`.
### Tooltip ### Tooltip
+34
View File
@@ -2770,6 +2770,40 @@ function QuestieLearner:InjectLearnedData()
end end
end end
end end
-- Restore persisted learner spawns ([7]) into the queryable override layer.
-- The branch above intentionally strips [7] to avoid clobbering curated
-- plugin coords, deferring to _MergeSpawnEvidence. But _MergeSpawnEvidence
-- only re-promotes from LIVE kill evidence, so spawns learned in a prior
-- session never came back on /reload, and a freshly accepted quest had no
-- pins until the mob was re-killed (e.g. quest 8325 -> Mana Wyrm 15274 on
-- Sunstrider). Re-merge the saved spawns here, gated by IsAscensionProtected
-- so curated AscensionDB coords are never overwritten: in learner mode the
-- check is always false (learner data fully restores); in auto mode only
-- non-curated NPCs are restored. Coords are deep-merged with InsertIfNewBucket
-- so any AscensionDB spawns already present are preserved and deduped.
local realNpcId = nid or npcId
if type(data[7]) == "table" and next(data[7]) and not IsAscensionProtected("NPC", realNpcId, 7) then
local ovr = QuestieDB.npcDataOverrides[realNpcId]
ovr[7] = ovr[7] or {}
for zoneId, coords in pairs(data[7]) do
if type(coords) == "table" then
-- Render the override under the canonical MAP id, matching the live
-- _MergeSpawnEvidence path (which stores topEvidence.zoneId already
-- normalized). The saved key may be an areaId (e.g. 3431/3430 from
-- the uiMapId->areaId migration above) — NormalizeSpawnZoneKey maps it
-- back to the uiMapId (1241) the pin renderer/HBD actually use.
local mapZone = NormalizeSpawnZoneKey(zoneId)
ovr[7][mapZone] = ovr[7][mapZone] or {}
local grid = GetCoordGridForZone(mapZone)
for _, coord in ipairs(coords) do
if type(coord) == "table" and coord[1] and coord[2] then
InsertIfNewBucket(ovr[7][mapZone], coord[1], coord[2], grid)
end
end
end
end
end
end end
for old, new in pairs(npcIdsToFix) do for old, new in pairs(npcIdsToFix) do
learned.npcs[new] = learned.npcs[old] learned.npcs[new] = learned.npcs[old]