From 26a1496d982521b1415bed7bed5b016c9a72b74c Mon Sep 17 00:00:00 2001 From: telkar-rg Date: Tue, 28 Nov 2023 11:43:34 +0100 Subject: [PATCH] removes unlearned professions from DataStore db --- .../DataStore_Crafts/DataStore_Crafts.lua | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/Altoholic-Addon/DataStore_Crafts/DataStore_Crafts.lua b/Altoholic-Addon/DataStore_Crafts/DataStore_Crafts.lua index 3a4a94e..0fcd23b 100644 --- a/Altoholic-Addon/DataStore_Crafts/DataStore_Crafts.lua +++ b/Altoholic-Addon/DataStore_Crafts/DataStore_Crafts.lua @@ -416,6 +416,12 @@ local function ScanProfessionLinks() local char = addon.ThisCharacter if not char then return end + + local old_professions = {} + -- start listing previously known professions + for skillName, v in pairs(char.Professions) do + old_professions[skillName] = 1 + end for i = GetNumSkillLines(), 1, -1 do -- 1st pass, expand all categories local _, isHeader = GetSkillLineInfo(i) @@ -444,6 +450,10 @@ local function ScanProfessionLinks() if field then char.Professions[skillName][field] = true + + -- remove a confimed Profession from the "old" list + old_professions[skillName] = nil + -- should be nil anyway for fishing, mining, etc.. local newLink = select(2, GetSpellLink(skillName)) if newLink then -- sometimes a nil value may be returned, so keep the old one if nil @@ -453,6 +463,12 @@ local function ScanProfessionLinks() end end end + + -- clear old professions which are no longer known + for oldProfession,_ in pairs(old_professions) do + wipe( char.Professions[oldProfession] ) -- clean the table first + char.Professions[oldProfession] = nil -- remove the entry + end end local SkillTypeToColor = {