Release Candidate 1
This commit is contained in:
@@ -802,50 +802,52 @@ do
|
||||
--make new namespace
|
||||
openRaidLib.AuraTracker = {}
|
||||
|
||||
function openRaidLib.AuraTracker.ScanCallback(aura)
|
||||
local unitId = openRaidLib.AuraTracker.CurrentUnitId
|
||||
local thisUnitAuras = openRaidLib.AuraTracker.CurrentAuras[unitId]
|
||||
|
||||
local auraInfo = C_UnitAuras.GetAuraDataByAuraInstanceID(unitId, aura.auraInstanceID)
|
||||
if (auraInfo) then
|
||||
local spellId = auraInfo.spellId
|
||||
if (spellId) then
|
||||
thisUnitAuras[spellId] = true
|
||||
openRaidLib.AuraTracker.AurasFoundOnScan[spellId] = true
|
||||
do if (false) then --do not load this section as it isn't in use
|
||||
function openRaidLib.AuraTracker.ScanCallback(auraInfo)
|
||||
if (auraInfo) then
|
||||
local spellId = auraInfo.spellId
|
||||
if (spellId) then
|
||||
local unitId = openRaidLib.AuraTracker.CurrentUnitId
|
||||
local thisUnitAuras = openRaidLib.AuraTracker.CurrentAuras[unitId]
|
||||
thisUnitAuras[spellId] = true
|
||||
openRaidLib.AuraTracker.AurasFoundOnScan[spellId] = true
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function openRaidLib.AuraTracker.ScanUnitAuras(unitId)
|
||||
local batchCount = nil
|
||||
local usePackedAura = true
|
||||
openRaidLib.AuraTracker.CurrentUnitId = unitId
|
||||
function openRaidLib.AuraTracker.ScanUnitAuras(unitId)
|
||||
local maxCount = nil
|
||||
local bUsePackedAura = true
|
||||
openRaidLib.AuraTracker.CurrentUnitId = unitId
|
||||
|
||||
openRaidLib.AuraTracker.AurasFoundOnScan = {}
|
||||
AuraUtil.ForEachAura(unitId, "HELPFUL", batchCount, openRaidLib.AuraTracker.ScanCallback, usePackedAura)
|
||||
openRaidLib.AuraTracker.AurasFoundOnScan = {}
|
||||
|
||||
local thisUnitAuras = openRaidLib.AuraTracker.CurrentAuras[unitId]
|
||||
for spellId in pairs(thisUnitAuras) do
|
||||
if (not openRaidLib.AuraTracker.AurasFoundOnScan[spellId]) then
|
||||
--aura removed
|
||||
openRaidLib.internalCallback.TriggerEvent("unitAuraRemoved", unitId, spellId)
|
||||
--code of 'ForEachAura' has been updated to use the latest API available
|
||||
AuraUtil.ForEachAura(unitId, "HELPFUL", maxCount, openRaidLib.AuraTracker.ScanCallback, bUsePackedAura)
|
||||
|
||||
local thisUnitAuras = openRaidLib.AuraTracker.CurrentAuras[unitId]
|
||||
for spellId in pairs(thisUnitAuras) do
|
||||
if (not openRaidLib.AuraTracker.AurasFoundOnScan[spellId]) then
|
||||
--aura removed
|
||||
openRaidLib.internalCallback.TriggerEvent("unitAuraRemoved", unitId, spellId)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
--run when the open raid lib loads
|
||||
function openRaidLib.AuraTracker.StartScanUnitAuras(unitId)
|
||||
openRaidLib.AuraTracker.CurrentAuras = {
|
||||
[unitId] = {}
|
||||
}
|
||||
--run when the open raid lib loads
|
||||
function openRaidLib.AuraTracker.StartScanUnitAuras(unitId) --this function isn't getting called (was called from Entering World event)
|
||||
openRaidLib.AuraTracker.CurrentAuras = {
|
||||
[unitId] = {} --storing using the unitId as key, won't work for any other unit other than the "player"
|
||||
}
|
||||
|
||||
local auraFrameEvent = CreateFrame("frame")
|
||||
auraFrameEvent:RegisterUnitEvent("UNIT_AURA", unitId)
|
||||
local auraFrameEvent = CreateFrame("frame")
|
||||
auraFrameEvent:RegisterUnitEvent("UNIT_AURA", unitId)
|
||||
|
||||
auraFrameEvent:SetScript("OnEvent", function()
|
||||
openRaidLib.AuraTracker.ScanUnitAuras(unitId)
|
||||
end)
|
||||
end
|
||||
auraFrameEvent:SetScript("OnEvent", function()
|
||||
openRaidLib.AuraTracker.ScanUnitAuras(unitId)
|
||||
end)
|
||||
end
|
||||
end end
|
||||
|
||||
--test case:
|
||||
local debugModule = {}
|
||||
@@ -854,7 +856,6 @@ do
|
||||
--print("aura removed:", unitId, spellId, spellName)
|
||||
end
|
||||
openRaidLib.internalCallback.RegisterCallback("unitAuraRemoved", debugModule.AuraRemoved)
|
||||
|
||||
end
|
||||
|
||||
|
||||
@@ -899,7 +900,6 @@ do
|
||||
local casterName = Ambiguate(casterString, "none")
|
||||
return openRaidLib.AuraTracker.FindBuffDuration(targetName, casterName, spellId)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
||||
|
||||
@@ -43,7 +43,8 @@ if (WOW_PROJECT_ID ~= WOW_PROJECT_MAINLINE and not isExpansion_Dragonflight()) t
|
||||
end
|
||||
|
||||
local major = "LibOpenRaid-1.0"
|
||||
local CONST_LIB_VERSION = 122
|
||||
|
||||
local CONST_LIB_VERSION = 124
|
||||
|
||||
if (LIB_OPEN_RAID_MAX_VERSION) then
|
||||
if (CONST_LIB_VERSION <= LIB_OPEN_RAID_MAX_VERSION) then
|
||||
@@ -132,6 +133,9 @@ end
|
||||
|
||||
local CONST_USE_DEFAULT_SCHEDULE_TIME = true
|
||||
|
||||
-- Real throttle is 10 messages per 1 second, but we want to be safe due to fact we dont know when it actually resets
|
||||
local CONST_COMM_BURST_BUFFER_COUNT = 9
|
||||
|
||||
local GetContainerNumSlots = GetContainerNumSlots or C_Container.GetContainerNumSlots
|
||||
local GetContainerItemID = GetContainerItemID or C_Container.GetContainerItemID
|
||||
local GetContainerItemLink = GetContainerItemLink or C_Container.GetContainerItemLink
|
||||
@@ -485,25 +489,33 @@ end
|
||||
---@field channel string
|
||||
|
||||
---@type {}[]
|
||||
local commScheduler = {}
|
||||
local commScheduler = {};
|
||||
|
||||
local commBurstBufferCount = CONST_COMM_BURST_BUFFER_COUNT;
|
||||
local commServerTimeLastThrottleUpdate = GetServerTime();
|
||||
|
||||
do
|
||||
--if there's an old version that already registered the comm ticker, cancel it
|
||||
if (LIB_OPEN_RAID_COMM_SCHEDULER) then
|
||||
LIB_OPEN_RAID_COMM_SCHEDULER:Cancel()
|
||||
LIB_OPEN_RAID_COMM_SCHEDULER:Cancel();
|
||||
end
|
||||
|
||||
--make the lib throttle the comms to one per second
|
||||
local newTickerHandle = C_Timer.NewTicker(1, function()
|
||||
for i = #commScheduler, 1, -1 do
|
||||
local commData = commScheduler[i]
|
||||
if (commData) then
|
||||
sendData(commData.data, commData.channel)
|
||||
table.remove(commScheduler, i)
|
||||
return
|
||||
end
|
||||
local newTickerHandle = C_Timer.NewTicker(0.05, function()
|
||||
local serverTime = GetServerTime();
|
||||
|
||||
-- Replenish the counter if last server time is not the same as the last throttle update
|
||||
-- Clamp it to CONST_COMM_BURST_BUFFER_COUNT
|
||||
commBurstBufferCount = math.min((serverTime ~= commServerTimeLastThrottleUpdate) and commBurstBufferCount + 1 or commBurstBufferCount, CONST_COMM_BURST_BUFFER_COUNT);
|
||||
commServerTimeLastThrottleUpdate = serverTime;
|
||||
|
||||
-- while (anything in queue) and (throttle allows it)
|
||||
while(#commScheduler > 0 and commBurstBufferCount > 0) do
|
||||
-- FIFO queue
|
||||
local commData = table.remove(commScheduler, 1);
|
||||
sendData(commData.data, commData.channel);
|
||||
commBurstBufferCount = commBurstBufferCount - 1;
|
||||
end
|
||||
end)
|
||||
end);
|
||||
|
||||
LIB_OPEN_RAID_COMM_SCHEDULER = newTickerHandle
|
||||
end
|
||||
@@ -531,8 +543,8 @@ end
|
||||
|
||||
if (bit.band(flags, CONST_COMM_SENDTO_GUILD)) then --send to guild
|
||||
if (IsInGuild()) then
|
||||
local commData = {data = dataEncoded, channel = "GUILD"}
|
||||
table.insert(commScheduler, commData)
|
||||
--Guild has no 10 msg restriction so send it directly
|
||||
sendData(dataEncoded, "GUILD");
|
||||
end
|
||||
end
|
||||
else
|
||||
@@ -588,9 +600,9 @@ end
|
||||
end
|
||||
|
||||
local result, errortext = xpcall(callback, geterrorhandler(), unpack(payload))
|
||||
if (not result) then
|
||||
sendChatMessage("openRaidLib: error on scheduler:", tickerObject.scheduleName, tickerObject.stack)
|
||||
end
|
||||
--if (not result) then
|
||||
-- sendChatMessage("openRaidLib: error on scheduler:", tickerObject.scheduleName, tickerObject.stack)
|
||||
--end
|
||||
|
||||
return result
|
||||
end
|
||||
@@ -601,7 +613,7 @@ end
|
||||
local newTimer = C_Timer.NewTimer(time, triggerScheduledTick)
|
||||
newTimer.payload = payload
|
||||
newTimer.callback = callback
|
||||
newTimer.stack = debugstack()
|
||||
--newTimer.stack = debugstack()
|
||||
return newTimer
|
||||
end
|
||||
|
||||
@@ -621,7 +633,7 @@ end
|
||||
local newTimer = openRaidLib.Schedules.NewTimer(time, callback, ...)
|
||||
newTimer.namespace = namespace
|
||||
newTimer.scheduleName = scheduleName
|
||||
newTimer.stack = debugstack()
|
||||
--newTimer.stack = debugstack()
|
||||
newTimer.isUnique = true
|
||||
|
||||
local registeredUniqueTimers = openRaidLib.Schedules.registeredUniqueTimers
|
||||
|
||||
Reference in New Issue
Block a user