From 2b3601361eeff0cb5f70b1305753451607dec749 Mon Sep 17 00:00:00 2001 From: Alar of Runetotem Date: Mon, 2 Sep 2024 21:20:25 +0200 Subject: [PATCH 1/2] Fix: was using deprecated functions --- .gitignore | 1 + Debug.lua | 4 ++-- GarrisonCommander.lua | 7 +++---- Init.lua | 19 ++++++++----------- MatchMaker.lua | 41 ++++++++++++++++++++++++++--------------- OrderHall.lua | 2 +- ShipYard.lua | 2 +- Widgets.lua | 2 +- minimap.lua | 3 ++- 9 files changed, 45 insertions(+), 36 deletions(-) diff --git a/.gitignore b/.gitignore index 7f0d39f..307d228 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ /_build/ .buildpath .project +.vscode diff --git a/Debug.lua b/Debug.lua index e0fa1a3..a1dec51 100644 --- a/Debug.lua +++ b/Debug.lua @@ -355,9 +355,9 @@ for k,v in pairs(addon) do local original=addon[k] wrapped=function(...) tinsert(callstack,k) - local membefore=GetAddOnMemoryUsage("GarrisonCommander") + local membefore=C_AddOns.GetAddOnMemoryUsage("GarrisonCommander") local a1,a2,a3,a4,a5,a6,a7,a8,a9=original(...) - local memafter=GetAddOnMemoryUsage("GarrisonCommander") + local memafter=C_AddOns.GetAddOnMemoryUsage("GarrisonCommander") tremove(callstack) memorysinks[k].mem=memorysinks[k].mem+memafter-membefore memorysinks[k].calls=memorysinks[k].calls+1 diff --git a/GarrisonCommander.lua b/GarrisonCommander.lua index e1dbd88..48cc2ea 100644 --- a/GarrisonCommander.lua +++ b/GarrisonCommander.lua @@ -8,7 +8,6 @@ local tremove=tremove local setmetatable=setmetatable local getmetatable=getmetatable local type=type -local GetAddOnMetadata=GetAddOnMetadata local CreateFrame=CreateFrame local wipe=wipe local format=format @@ -512,14 +511,14 @@ function addon:showdata(fullargs,action,missionid) end function addon:CheckMP() - if (IsAddOnLoaded("MasterPlan")) then + if (C_AddOns.IsAddOnLoaded("MasterPlan")) then MP=true ns.MP=true MPSwitch=true end end function addon:CheckGMM() - if (IsAddOnLoaded("GarrisonMissionManager")) then + if (C_AddOns.IsAddOnLoaded("GarrisonMissionManager")) then GMM=true self:RefreshParties() self:RefreshMissions() @@ -867,7 +866,7 @@ function addon:SetDbDefaults(default) end function addon:CreatePrivateDb() self.privatedb=self:RegisterDatabase( - GetAddOnMetadata(me,"X-Database")..'perChar', + C_AddOns.GetAddOnMetadata(me,"X-Database")..'perChar', { profile={ ignored={ diff --git a/Init.lua b/Init.lua index e217a60..db9f8be 100644 --- a/Init.lua +++ b/Init.lua @@ -5,21 +5,13 @@ local minvers=39 assert(minor>=minvers,me ..': Need at least Libinit version ' .. minvers) local _G=_G local setmetatable=setmetatable -local next=next local pairs=pairs -local wipe=wipe -local GetChatFrame=GetChatFrame -local format=format local GetTime=GetTime -local strjoin=strjoin -local strspilit=strsplit -local tostringall=tostringall -local tostring=tostring local tonumber=tonumber local type=type --@debug@ -LoadAddOn("Blizzard_DebugTools") -LoadAddOn("LibDebug") +C_AddOns.LoadAddOn("Blizzard_DebugTools") +C_AddOns.LoadAddOn("LibDebug") if LibDebug then LibDebug() ns.print=print else ns.print=function() end end --@end-debug@ --[===[@non-debug@ @@ -33,6 +25,7 @@ ns.D=LibStub("LibDeformat-3.0") ns.C=addon:GetColorTable() ns.L=addon:GetLocale() ns.G=C_Garrison +---@diagnostic disable-next-line: undefined-field ns.GMF=_G.GarrisonMissionFrame ns.blacklist=false ns.prioritylist=false @@ -47,12 +40,15 @@ if not ns.GMF then --@debug@ print(GetTime()) --@end-debug@ +---@diagnostic disable-next-line: undefined-field ns.GMF=_G.GarrisonMissionFrame end if not ns.GMF then error("GarrisonCommander is being loaded before Blizzard_GarrisonUI is available") end +---@diagnostic disable-next-line: undefined-field ns.GSF=_G.GarrisonShipyardFrame ns.GMFMissions=ns.GMF.MissionTab.MissionList ns.GSFMissions=ns.GSF.MissionTab.MissionList +---@diagnostic disable-next-line: inject-field _G.GARRISON_FOLLOWER_MAX_ITEM_LEVEL = _G.GARRISON_FOLLOWER_MAX_ITEM_LEVEL or 675 local NavalDomination={ Alliance=39068, @@ -313,7 +309,6 @@ ns.traitTable={ [231]="Bodyguard", [56]="Enchanting", [57]="Engineering", - [62]="Evergreen", [53]="Herbalism", [52]="Mining", [58]="Inscription", @@ -370,6 +365,7 @@ setmetatable(ENV, {__index=_G, __newindex=function(t,k,v) assert(type(_G[k]) == 'nil',"Attempting to override global " ..k) +---@diagnostic disable-next-line: redundant-return-value return rawset(t,k,v) end } @@ -381,5 +377,6 @@ function ns.Configure() if old_env ~= _G and old_env ~= ENV then error("The calling function has a modified environment, I won't replace it.", 2) end +---@diagnostic disable-next-line: param-type-mismatch setfenv(2, ENV) end diff --git a/MatchMaker.lua b/MatchMaker.lua index 81430fb..3af2615 100644 --- a/MatchMaker.lua +++ b/MatchMaker.lua @@ -1,6 +1,6 @@ local me,ns=... ns.Configure() -local addon=addon --#addon +local addon=ns.addon --#addon local _G=_G local P=ns.party --local holdEvents,releaseEvents=addon.holdEvents,addon.releaseEvents @@ -11,25 +11,25 @@ local pairs=pairs local format=format local tonumber=tonumber local tinsert=tinsert -local tremove=tremove local loadstring=loadstring local assert=assert local rawset=rawset local strsplit=strsplit -local epicMountTrait=221 -local extraTrainingTrait=80 --all followers +35 -local fastLearnerTrait=29 -- only this follower +50 -local hearthStoneProTrait=236 -- all followers +36 -local scavengerTrait=79 -- More resources -local GARRISON_CURRENCY=GARRISON_CURRENCY -local GARRISON_SHIP_OIL_CURRENCY=GARRISON_SHIP_OIL_CURRENCY -local LE_FOLLOWER_TYPE_GARRISON_6_0=_G.LE_FOLLOWER_TYPE_GARRISON_6_0 -- 1 +-- local epicMountTrait=221 +-- local extraTrainingTrait=80 --all followers +35 +-- local fastLearnerTrait=29 -- only this follower +50 +-- local hearthStoneProTrait=236 -- all followers +36 +-- local scavengerTrait=79 -- More resources +-- local GARRISON_CURRENCY=GARRISON_CURRENCY +-- local GARRISON_SHIP_OIL_CURRENCY=GARRISON_SHIP_OIL_CURRENCY +-- local LE_FOLLOWER_TYPE_GARRISON_6_0=_G.LE_FOLLOWER_TYPE_GARRISON_6_0 -- 1 +---@diagnostic disable-next-line: undefined-field local LE_FOLLOWER_TYPE_SHIPYARD_6_2=_G.LE_FOLLOWER_TYPE_SHIPYARD_6_2 -- 2 local dbg -local useCap=false -local currentCap=100 +-- local useCap=false +-- local currentCap=100 local testID=0 - +--- #class G local function formatScore(c,r,x,t,maxres,cap) c=tonumber(c) or 0 r=tonumber(r) or 0 @@ -149,7 +149,7 @@ local function AddMoreFollowers(self,mission,scores,justdo,max) local missionScore=self:MissionScore(mission) --@debug@ if missionID==testID then - print("AddMoreFollowers called with ",#scores,justdo,justone,P:FreeSlots()) + print("AddMoreFollowers called with ",#scores,justdo,max,P:FreeSlots()) end if dbg then scroller:AddRow("AddMore") @@ -228,7 +228,9 @@ local function MatchMaker(self,mission,party,includeBusy,onlyBest) else filters.skipBusy=not includeBusy end +---@diagnostic disable-next-line: undefined-global local scores=new() +---@diagnostic disable-next-line: undefined-global local troops=new() P:Open(missionID,mission.numFollowers) local missionTypeID=mission.followerTypeID @@ -258,10 +260,12 @@ local function MatchMaker(self,mission,party,includeBusy,onlyBest) if #scores > 0 then --@debug@ if (dbg) then +---@diagnostic disable-next-line: redundant-parameter scroller:addRow("Cap Res Cha Xp T Vra Ran") for i=1,#scores do local score,followerID=strsplit('@',scores[i]) local t=score .. " " .. addon:GetAnyData(mission.followerTypeID,followerID,'fullname') .. " " .. tostring(G.GetFollowerStatus(followerID)) +---@diagnostic disable-next-line: redundant-parameter scroller:addRow(t) end else @@ -278,6 +282,7 @@ local function MatchMaker(self,mission,party,includeBusy,onlyBest) if firstmember then if P:AddFollower(firstmember) and dbg then --@debug@ +---@diagnostic disable-next-line: redundant-parameter scroller:addRow(C("Slot 1:","Green").. " " .. addon:GetAnyData(0,firstmember,'fullname')) --@end-debug@ end @@ -299,6 +304,7 @@ local function MatchMaker(self,mission,party,includeBusy,onlyBest) end --@debug@ if dbg then +---@diagnostic disable-next-line: redundant-parameter scroller:addRow("Final score: " .. self:MissionScore(mission)) end --@end-debug@ @@ -318,7 +324,9 @@ local function MatchMaker(self,mission,party,includeBusy,onlyBest) end P:StoreFollowers(party.members) P:Close(party) +---@diagnostic disable-next-line: undefined-global del(scores) +---@diagnostic disable-next-line: undefined-global del(troops) end function addon:MCMatchMaker(missionID,party,skipEpic,cap) @@ -328,7 +336,7 @@ function addon:MCMatchMaker(missionID,party,skipEpic,cap) --@debug@ print("Using cap data:",cap) --@end-debug@ - MatchMaker(self,mission,party,false,true,cap) + MatchMaker(self,mission,party,false,true) if (skipEpic) then if (self:GetMissionData(missionID,'class')=='xp') then for i=1,#party.members do @@ -371,10 +379,13 @@ function addon:TestMission(missionID,includeBusy) local mission=type(missionID)=="table" and missionID or self:GetMissionData(missionID) missionID=mission.missionID dbg=true +---@diagnostic disable-next-line: undefined-global, undefined-global local party=new() party.members=new() self:MatchMaker(mission,party,includeBusy) +---@diagnostic disable-next-line: undefined-global del(party.members) +---@diagnostic disable-next-line: undefined-global del(party) scroller=nop dbg=false diff --git a/OrderHall.lua b/OrderHall.lua index 97402c2..205ea7e 100644 --- a/OrderHall.lua +++ b/OrderHall.lua @@ -31,7 +31,7 @@ local pool={} function module:OnInitialize(...) if not ns.GHF then return end -- Waiting to be late initialized by init routine OHFFollowerTab=OrderHallMissionFrame.FollowerTab -- Contains model view - if GetAddOnEnableState(UnitName("player"),"OrderHallCommander") > 0 then + if C_AddOns.GetAddOnEnableState(UnitName("player"),"OrderHallCommander") > 0 then ns.ignoreHall=true return end diff --git a/ShipYard.lua b/ShipYard.lua index 65838a7..d038118 100644 --- a/ShipYard.lua +++ b/ShipYard.lua @@ -277,7 +277,7 @@ print("Doing one time initialization for",this:GetName(),...) bt:SetText(L["Garrison Comander Quick Mission Completion"]) bt:SetPoint("CENTER",0,-50) addon:ActivateButton(bt,"MissionComplete",L["Complete all missions without confirmation"]) - if IsAddOnLoaded("MasterPlanA") then + if C_AddOns.IsAddOnLoaded("MasterPlanA") then self:SafeSecureHook("GarrisonShipyardMap_UpdateMissions") -- low efficiency, but survives MasterPlan end self:SafeSecureHook("GarrisonShipyardMap_SetupBonus") diff --git a/Widgets.lua b/Widgets.lua index 6de2b79..4186b9c 100644 --- a/Widgets.lua +++ b/Widgets.lua @@ -1,6 +1,6 @@ local me, ns = ... ns.Configure() -local addon=addon +local addon=ns.addon local _G=_G local wipe=wipe local format=format diff --git a/minimap.lua b/minimap.lua index 5a37ec1..dac6203 100644 --- a/minimap.lua +++ b/minimap.lua @@ -1,5 +1,5 @@ local me, ns = ... -local print,hooksecurefunc,IsAddOnLoaded=print,hooksecurefunc,IsAddOnLoaded +local print=print local gc,gb="GarrisonCommander","GarrisonCommander-Broker" local garrison,orderhall,champion,sanctum= MINIMAP_GARRISON_LANDING_PAGE_TOOLTIP, @@ -10,6 +10,7 @@ local LE_GARRISON_TYPE_6_0=Enum.GarrisonType.Type_6_0_Garrison local LE_GARRISON_TYPE_7_0=Enum.GarrisonType.Type_7_0_Garrison local LE_GARRISON_TYPE_8_0=Enum.GarrisonType.Type_8_0_Garrison local LE_GARRISON_TYPE_9_0=Enum.GarrisonType.Type_9_0_Garrison +local IsAddOnLoaded=C_AddOns.IsAddOnLoaded local descriptions={ [LE_GARRISON_TYPE_6_0] = "Garrison", [LE_GARRISON_TYPE_7_0]= "Order Hall", From 034116c8aaff41c8a1ce5e26ae8a30405e0c2979 Mon Sep 17 00:00:00 2001 From: Alar of Runetotem Date: Mon, 2 Sep 2024 21:21:27 +0200 Subject: [PATCH 2/2] version release 3.9.2 --- RelNotes.lua | 3 +++ 1 file changed, 3 insertions(+) diff --git a/RelNotes.lua b/RelNotes.lua index 8a38232..078c7f7 100644 --- a/RelNotes.lua +++ b/RelNotes.lua @@ -23,6 +23,9 @@ self:Wiki([[ typing /gac silent in chat will eliminate every chat message from GarrisonCommander ]]) self:HF_Paragraph('Release Notes') +self:RelNotes(3,9,2,[[ +Fix: Was still using removed function +]]) self:RelNotes(3,9,1,[[ Rebuild: Libraries update ]])