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.
This commit is contained in:
Brues
2026-10-31 01:57:10 -05:00
parent df13e30e08
commit a8d805626d
6 changed files with 9 additions and 59 deletions
-50
View File
@@ -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())
+1 -1
View File
@@ -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
+4 -4
View File
@@ -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)
+1 -1
View File
@@ -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)
+1 -1
View File
@@ -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.+)%]")
+2 -2
View File
@@ -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)