From 3712a58c1448a76bc465312d9a5b3d26691ee4c3 Mon Sep 17 00:00:00 2001 From: Kevin Ballard Date: Fri, 5 Aug 2016 00:11:24 -0700 Subject: [PATCH] Fix per-spec settings GetActiveSpecGroup() now just always returns 1. Instead we want to use the index of the active specialization. This does mean that previously-saved per-spec settings will now potentially apply to the wrong spec, but there's not much we can do about that. --- Cork.lua | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/Cork.lua b/Cork.lua index b9033f5..75bc6dd 100644 --- a/Cork.lua +++ b/Cork.lua @@ -22,8 +22,11 @@ ae.RegisterEvent("Cork", "ADDON_LOADED", function(event, addon) if addon:lower() ~= "cork" then return end CorkDB = setmetatable(CorkDB or {}, {__index = defaults}) - CorkDBPC = CorkDBPC or {{},{}} - if not CorkDBPC[1] then CorkDBPC = {CorkDBPC, {}} end + CorkDBPC = CorkDBPC or {{},{},{},{}} + if not CorkDBPC[1] then CorkDBPC = {CorkDBPC, {}, {}, {}} end + for _, i in ipairs({2,3,4}) do + if not CorkDBPC[i] then CorkDBPC[i] = {} end + end Cork.db = CorkDB anchor:SetPoint(Cork.db.point, Cork.db.x, Cork.db.y) @@ -35,19 +38,19 @@ end) local meta = {__index = Cork.defaultspc} ae.RegisterEvent("Cork", "PLAYER_LOGIN", function() - local lastgroup = GetActiveSpecGroup() - Cork.dbpc = setmetatable(CorkDBPC[lastgroup], meta) + local lastspec = GetSpecialization() + Cork.dbpc = setmetatable(CorkDBPC[lastspec], meta) for _,dataobj in pairs(Cork.sortedcorks) do if dataobj.Init then dataobj:Init() end end for _,dataobj in pairs(Cork.sortedcorks) do dataobj:Scan() end ae.RegisterEvent("Cork", "ZONE_CHANGED_NEW_AREA", Cork.Update) ae.RegisterEvent("Cork", "PLAYER_TALENT_UPDATE", function() - if lastgroup == GetActiveSpecGroup() then return end + if lastspec == GetSpecialization() then return end - lastgroup = GetActiveSpecGroup() + lastspec = GetSpecialization() for i,v in pairs(Cork.defaultspc) do if Cork.dbpc[i] == v then Cork.dbpc[i] = nil end end - Cork.dbpc = setmetatable(CorkDBPC[lastgroup], meta) + Cork.dbpc = setmetatable(CorkDBPC[lastspec], meta) if Cork.config.Update then Cork.config:Update() end for name,dataobj in pairs(Cork.corks) do if dataobj.Init then dataobj:Init() end end