From a8d805626d53e9cf7e4027bfe8e2ab02ed763f8e Mon Sep 17 00:00:00 2001 From: Brues <5278969+brues-code@users.noreply.github.com> Date: Sat, 31 Oct 2026 01:56:47 -0500 Subject: [PATCH] Replace QueueFunction and RunOOC with RunNextFrame RunOOC never waited for combat to end; it ran its function on the next frame. QueueFunction ran one function every 0.2 seconds. Each caller now defers with ClassicAPI's RunNextFrame. The loot roll announcement sends its name lists and the roll directly. The 0.2 second spacing did not help with the server's chat flood limit (10 messages less than a second apart), and an announcement is at most four messages. --- api/api.lua | 50 -------------------------------------------- api/ui-widgets.lua | 2 +- modules/loot.lua | 8 +++---- modules/minimap.lua | 2 +- modules/superwow.lua | 2 +- modules/unlock.lua | 4 ++-- 6 files changed, 9 insertions(+), 59 deletions(-) diff --git a/api/api.lua b/api/api.lua index cdeca109..cbf240e3 100644 --- a/api/api.lua +++ b/api/api.lua @@ -175,26 +175,6 @@ function pfUI.api.UnitInRange(unit) return nil end --- [ RunOOC ] --- Runs a function once, as soon as the combat lockdown fades. --- func [function] The function that shall run ooc. --- return: [bool] true if the function was added, --- nil if the function already exists in queue -local queue, frame = {} -function pfUI.api.RunOOC(func) - if not frame then - frame = CreateFrame("Frame") - frame:SetScript("OnUpdate", function() - for key, func in pairs(queue) do func(); queue[key] = nil end - end) - end - - if not queue[tostring(func)] then - queue[tostring(func)] = func - return true - end -end - -- [ UnitHasBuff ] -- Returns whether a unit has the named buff or not. -- unit [string] A unit to query (string, unitID) @@ -668,36 +648,6 @@ function pfUI.api.HookAddon(addon, func) end) end --- [ QueueFunction ] --- Add functions to a FIFO queue for execution after a short delay. --- '...' [vararg] function, [arguments] -local timer -function pfUI.api.QueueFunction(a1,a2,a3,a4,a5,a6,a7,a8,a9) - if not timer then - timer = CreateFrame("Frame") - timer.queue = {} - timer.interval = TOOLTIP_UPDATE_TIME - timer.DeQueue = function() - local item = table.remove(timer.queue,1) - if item then - item[1](item[2],item[3],item[4],item[5],item[6],item[7],item[8],item[9]) - end - if table.getn(timer.queue) == 0 then - timer:Hide() -- no need to run the OnUpdate when the queue is empty - end - end - timer:SetScript("OnUpdate",function() - this.sinceLast = (this.sinceLast or 0) + arg1 - while (this.sinceLast > this.interval) do - this.DeQueue() - this.sinceLast = this.sinceLast - this.interval - end - end) - end - table.insert(timer.queue,{a1,a2,a3,a4,a5,a6,a7,a8,a9}) - timer:Show() -- start the OnUpdate -end - -- [ Create Gold String ] -- Transforms a amount of copper into a fully fledged gold string -- 'money' [int] the amount of coppy (GetMoney()) diff --git a/api/ui-widgets.lua b/api/ui-widgets.lua index 1c5f4bf9..472427a9 100644 --- a/api/ui-widgets.lua +++ b/api/ui-widgets.lua @@ -524,7 +524,7 @@ function pfUI.api.SkinScrollbar(frame, always) -- always show parent frame if always then - RunOOC(function() + RunNextFrame(function() parent:HookScript("OnHide", function() this:Show() end) end) end diff --git a/modules/loot.lua b/modules/loot.lua index 4c3cf365..f9cc37c3 100644 --- a/modules/loot.lua +++ b/modules/loot.lua @@ -49,7 +49,7 @@ pfUI:RegisterModule("loot", function () names = (k==1) and (i..":"..pfUI.loot.index_to_name[candidates[i]]) or (names..", "..i..":"..pfUI.loot.index_to_name[candidates[i]]) -- fit the maximum names in a single 255 char message (15) if i == to or k == 15 then - QueueFunction(SendChatMessageWide,names) + SendChatMessageWide(names) names = "" end k = k<15 and k+1 or 1 @@ -58,7 +58,7 @@ pfUI:RegisterModule("loot", function () end pfUI.loot:RegisterEvent("CHAT_MSG_SYSTEM") pfUI.loot.randomRolling = true - QueueFunction(RandomRoll,"1",tostring(to)) + RandomRoll("1",tostring(to)) end end @@ -450,7 +450,7 @@ pfUI:RegisterModule("loot", function () LootSlot(this:GetID()) -- workaround for bugged disenchant / container loot on some servers if numItems == 1 then - QueueFunction(CloseOnClick) + RunNextFrame(CloseOnClick) end end) @@ -604,7 +604,7 @@ pfUI:RegisterModule("loot", function () if C.loot.autopickup == "1" and GetNumPartyMembers() == 0 and GetNumRaidMembers() == 0 then if event == "LOOT_BIND_CONFIRM" then local slot = arg1 - QueueFunction(function() + RunNextFrame(function() LootSlot(slot) StaticPopup_Hide("LOOT_BIND") end) diff --git a/modules/minimap.lua b/modules/minimap.lua index 9beb988a..6f337517 100644 --- a/modules/minimap.lua +++ b/modules/minimap.lua @@ -18,7 +18,7 @@ pfUI:RegisterModule("minimap", function () pfUI.minimap:SetPoint("TOPRIGHT", UIParent, -border*2, -border*2) UpdateMovable(pfUI.minimap) pfUI.minimap:SetScript("OnShow", function() - QueueFunction(ShowUIPanel, Minimap) + RunNextFrame(function() ShowUIPanel(Minimap) end) end) Minimap:SetParent(pfUI.minimap) diff --git a/modules/superwow.lua b/modules/superwow.lua index a3eb69e6..72cfcfe3 100644 --- a/modules/superwow.lua +++ b/modules/superwow.lua @@ -79,7 +79,7 @@ pfUI:RegisterModule("superwow", function () -- SuperWoW release past 1.5 local swVersion = tonumber(SUPERWOW_VERSION) if swVersion and swVersion >= 1.5 then - QueueFunction(function() + RunNextFrame(function() local pfCombatText_AddMessage = _G.CombatText_AddMessage _G.CombatText_AddMessage = function(message, a, b, c, d, e, f) local match, _, hex = string.find(message, ".+ %[(0x.+)%]") diff --git a/modules/unlock.lua b/modules/unlock.lua index dc1ceeda..043233b3 100644 --- a/modules/unlock.lua +++ b/modules/unlock.lua @@ -303,7 +303,7 @@ pfUI:RegisterModule("unlock", function () end if frame.OnMove then frame:OnMove() end - QueueFunction(UpdateDockValues) + RunNextFrame(UpdateDockValues) end local function DraggerOnDragStart() @@ -654,7 +654,7 @@ pfUI:RegisterModule("unlock", function () if frame.OnMove then frame:OnMove() end - QueueFunction(SetDockToFrame, pfUI.unlock.dock.parent) + RunNextFrame(function() SetDockToFrame(pfUI.unlock.dock.parent) end) end) SkinButton(pfUI.unlock.dock.reset,.2,1,.8)