Skip to content

Commit

Permalink
Fix: was using deprecated functions
Browse files Browse the repository at this point in the history
  • Loading branch information
Alar of Runetotem committed Sep 2, 2024
1 parent 050e187 commit 2b36013
Show file tree
Hide file tree
Showing 9 changed files with 45 additions and 36 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/_build/
.buildpath
.project
.vscode
4 changes: 2 additions & 2 deletions Debug.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 3 additions & 4 deletions GarrisonCommander.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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={
Expand Down
19 changes: 8 additions & 11 deletions Init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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@
Expand All @@ -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
Expand All @@ -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,
Expand Down Expand Up @@ -313,7 +309,6 @@ ns.traitTable={
[231]="Bodyguard",
[56]="Enchanting",
[57]="Engineering",
[62]="Evergreen",
[53]="Herbalism",
[52]="Mining",
[58]="Inscription",
Expand Down Expand Up @@ -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
}
Expand All @@ -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
41 changes: 26 additions & 15 deletions MatchMaker.lua
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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@
Expand All @@ -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)
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion OrderHall.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion ShipYard.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
2 changes: 1 addition & 1 deletion Widgets.lua
Original file line number Diff line number Diff line change
@@ -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
Expand Down
3 changes: 2 additions & 1 deletion minimap.lua
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -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",
Expand Down

0 comments on commit 2b36013

Please sign in to comment.