diff --git a/GarrisonCommander.lua b/GarrisonCommander.lua index 12b4d2a..1f155b3 100644 --- a/GarrisonCommander.lua +++ b/GarrisonCommander.lua @@ -364,6 +364,7 @@ _G.Garrison_SortMissions= function(missionsList) end --]] function addon:SortMissions(missionsList) + self:Print(C("SortMissions","Orange")) MyGarrison_SortMissions(missionsList) end function addon.Garrison_SortMissions_Chance(missionsList) @@ -2556,13 +2557,13 @@ function addon:AddRewards(frame, rewards, numRewards) local bestItemID=self:GetMissionData(missionID,'bestItemID') local pseudoGold local extraItem - local rw=self:NewTable() + local rw=new() for _, reward in pairs(rewards) do tinsert(rw,reward) end if bestItemID then numRewards=numRewards+1 - extraItem=self:NewTable() + extraItem=new() extraItem.itemID=bestItemID extraItem.best=true extraItem.quantity=1 @@ -2571,7 +2572,7 @@ function addon:AddRewards(frame, rewards, numRewards) end if moreClasses and moreClasses.gold then numRewards=numRewards+1 - pseudoGold=self:NewTable() + pseudoGold=new() pseudoGold.quantity=self:GetMissionData(missionID,'gold') pseudoGold.currencyID=0 pseudoGold.pseudogold=true @@ -2674,12 +2675,12 @@ function addon:AddRewards(frame, rewards, numRewards) index = index + 1; end if pseudoGold then - self:DelTable(pseudoGold) + del(pseudoGold) end if extraItem then - self:DelTable(extraItem) + del(extraItem) end - self:DelTable(rw) + del(rw) end for i = (numRewards + 1), #frame.Rewards do frame.Rewards[i]:Hide(); @@ -3312,7 +3313,8 @@ function addon:OnUpdateMissions() if UpdateShow then self:Unhook("Garrison_SortMissions","SortMissions") end --@debug@ addon:Print(C("OnPostUpdateMissions","RED"),debugprofilestop()-start) ---@end-debug@ +--@end-debug@ + collectgarbage("collect") end --addon:SafeRawHook(GMF.MissionTab.MissionList.listScroll,"update","HookedGMFMissionsListScroll_update") diff --git a/Init.lua b/Init.lua index 01d7d60..e3cae0f 100644 --- a/Init.lua +++ b/Init.lua @@ -30,8 +30,8 @@ local addon=ns.addon --#addon ns.toc=select(4,GetBuildInfo()) ns.AceGUI=LibStub("AceGUI-3.0") ns.D=LibStub("LibDeformat-3.0") -ns.C=ns.addon:GetColorTable() -ns.L=ns.addon:GetLocale() +ns.C=addon:GetColorTable() +ns.L=addon:GetLocale() ns.G=C_Garrison ns.GMF=_G.GarrisonMissionFrame ns.blacklist=false @@ -59,8 +59,8 @@ GetQuestsCompleted(ns.quests) function addon:EventQUEST_TURNED_IN(event,quest,item,gold) ns.quests[quest]=true end -ns.new=function() return addon:NewTable() end -ns.del=function(t) return addon:NewTable(t) end +ns.new=addon:Wrap("NewTable") +ns.del=addon:Wrap("DelTable") --@debug@ local t =ns.new() if type(t)~="table" then diff --git a/MissionCache.lua b/MissionCache.lua index 36d3dad..bb5c2e6 100644 --- a/MissionCache.lua +++ b/MissionCache.lua @@ -28,6 +28,8 @@ local empty={} local index={} local classes={} local _G=_G +local new, del, copy =ns.new,ns.del,ns.copy + -- Mission caching is a bit different fron follower caching mission appears and disappears on a regular basis local module=addon:NewSubClass('MissionCache') --#module @@ -258,8 +260,8 @@ end function module:OnAllGarrisonMissions(func,inProgress,missionType) local m=(missionType and missionType==LE_FOLLOWER_TYPE_GARRISON_7_0) and GHFMissions or GMFMissions local list=inProgress and m.inProgressMissions or m.availableMissions - local tmp=addon:NewTable() if type(list)=='table' then + local tmp=new() for i=1,#list do tinsert(tmp,list[i].missionID) end @@ -267,8 +269,8 @@ function module:OnAllGarrisonMissions(func,inProgress,missionType) for i=1,#tmp do func(tmp[i]) end + del(tmp) end - addon:DelTable(tmp) end -- Old cache to be removed diff --git a/MissionControl.lua b/MissionControl.lua index 9a5c903..422a8e6 100644 --- a/MissionControl.lua +++ b/MissionControl.lua @@ -39,6 +39,8 @@ end local classlist ---#table local reference to settings.rewardList local class2order={} ---#table maps a classname to its priority local settings ---#table Pointer to settings in saved var +local new, del, copy =ns.new,ns.del,ns.copy + local module=addon:NewSubClass("MissionControl") --#module local function chooseBestClass(class,moreClasses) local i=class2order[class] or 999 @@ -123,7 +125,7 @@ function module:CreateMissionList(workList) end local parties=self:GetParty() table.sort(choosenby) - local used=self:NewTable() + local used=new() for i=1,#choosenby do local _1,_2,missionId,_=strsplit('@',choosenby[i]) if not used[missionId] then @@ -131,7 +133,7 @@ function module:CreateMissionList(workList) used[missionId]=true end end - self:DelTable(used) + self:del() end --- -- This routine can be called both as coroutin and as a standard one diff --git a/ShipControl.lua b/ShipControl.lua index e1d136e..33c2007 100644 --- a/ShipControl.lua +++ b/ShipControl.lua @@ -22,6 +22,8 @@ local pairs=pairs local tinsert=tinsert local tremove=tremove local dbg +local new, del, copy =ns.new,ns.del,ns.copy + local tItems ={} for _,data in ipairs(addon:GetRewardClasses(LE_FOLLOWER_TYPE_SHIPYARD_6_2)) do tItems[data.key]=data @@ -150,7 +152,7 @@ function module:CreateMissionList(workList) --@debug@ print("Final worklist") --@end-debug@ - local used=self:NewTable() + local used=new() for i=1,#choosenby do local _1,_2,missionId,_=strsplit('@',choosenby[i]) if not used[missionId] then @@ -161,7 +163,7 @@ function module:CreateMissionList(workList) --@end-debug@ end end - self:DelTable(used) + del(used) end --- -- This routine can be called both as coroutin and as a standard one