mirror of
https://github.com/brues-code/SuperCleveRoidMacros.git
synced 2026-09-16 03:38:00 +00:00
Filter UNIT_AURA by unit token and drop the unit streams in realtime mode
Two handlers opened by testing arg1 against a fixed set of unit tokens, so every other unit's copy of UNIT_AURA reached Lua only to be compared away -- in a raid that is the bulk of them. ClassicAPI's RegisterUnitEvent pushes that filter into the client, so the handler only runs for the units named. Filtering is per (frame, event), so the other events sharing the libdebuff frame are unaffected. Utility.lua UNIT_AURA -> "target" (libdebuff seeding) ComboPointTracker UNIT_AURA -> "target", "player" Extensions register through CleveRoids.RegisterEvent, so ExtensionsManager gains a RegisterUnitEvent alongside it. Separately, the main frame's unit state streams (UNIT_AURA / UNIT_HEALTH / UNIT_POWER, or the _GUID variants under Nampower v2.39+) are now registered only in event-driven mode. Their handlers are wholly wrapped in `realtime == 0`, so with realtime on every one of them crossed into Lua and returned immediately while the OnUpdate did the refreshing. Registration is applied at load, again at VARIABLES_LOADED once the saved setting is readable, and whenever /cleveroid realtime flips it. Those three stay plain RegisterEvent calls: their handlers ignore the unit and refresh every macro, and a conditional may name any unit ([@party3,hp:<50], @focus, @mouseover), so narrowing the token set would leave those icons stale. The _GUID variants could not be filtered anyway -- their first argument is a GUID, not a unit token.
This commit is contained in:
@@ -66,6 +66,10 @@ function CleveRoids.RegisterExtension(name)
|
||||
CleveRoids.RegisterEvent(name, eventName, callbackName)
|
||||
end
|
||||
|
||||
extension.RegisterUnitEvent = function(eventName, callbackName, ...)
|
||||
CleveRoids.RegisterUnitEvent(name, eventName, callbackName, unpack(arg))
|
||||
end
|
||||
|
||||
extension.Hook = function(functionName, callbackName, dontCallOriginal)
|
||||
CleveRoids.RegisterHook(name, functionName, callbackName, dontCallOriginal)
|
||||
end
|
||||
@@ -146,6 +150,20 @@ function CleveRoids.RegisterEvent(extensionName, eventName, callbackName)
|
||||
extension.internal.frame:RegisterEvent(eventName)
|
||||
end
|
||||
|
||||
-- Registers a callback for a UNIT_* event, filtered to the given unit tokens.
|
||||
-- The callback then only runs for those units: the client drops every other
|
||||
-- unit's copy, instead of all of them reaching Lua to be compared away. Use
|
||||
-- this over RegisterEvent whenever the handler starts by testing arg1.
|
||||
-- extensionName: The name of the extension trying to register the callback
|
||||
-- eventName: The UNIT_* event to register
|
||||
-- callbackName: The name of the callback that gets called when the event fires
|
||||
-- ...: the unit tokens to accept (e.g. "player", "target")
|
||||
function CleveRoids.RegisterUnitEvent(extensionName, eventName, callbackName, ...)
|
||||
local extension = CleveRoids.Extensions[extensionName]
|
||||
extension.internal.eventHandlers[eventName] = callbackName
|
||||
extension.internal.frame:RegisterUnitEvent(eventName, unpack(arg))
|
||||
end
|
||||
|
||||
-- Hooks the given function by it's name
|
||||
-- extensionName: The name of the extension trying to register the callback
|
||||
-- functionName: The name of the function that'll be hooked
|
||||
|
||||
Reference in New Issue
Block a user