I wonder if that code can be improved. It takes up quite some cpu time. Nothing extremely bad, but COMBAT_LOG_EVENT_UNFILTERED is called very often and mostly at bad times.
Thanks in advance for looking through it.
Code:
function addon:COMBAT_LOG_EVENT_UNFILTERED( event, ... )
--timestamp, eventType, srcGUID, srcName, srcFlags, dstGUID, dstName, dstFlags
local _, event = ...
if addon[event] then
addon[event]( self, ... )
end
end
function addon:SPELL_AURA_APPLIED( ... )
--timestamp, eventType, srcGUID, srcName, srcFlags, dstGUID, dstName, dstFlags
local timestamp, eventType, srcGUID, srcName, srcFlags, dstGUID, dstName, dstFlags = select( 1, ... )
local spellId, spellName, spellSchool, auraType, amount = select( 9, ... )
if playerGUID==dstGUID or playerTargetGUID==dstGUID then return end -- No auras from player wanted.
local fromPlayer = srcGUID==playerGUID and 1
if auraType=="DEBUFF" then
auraType = "HARMFUL"
elseif auraType=="BUFF" then
auraType = "HELPFUL"
end
local priority = checkFilter( strlower( spellName ), fromPlayer, auraType )
if priority then
if global.spellList[spellId] then
local time = GetTime()
table[dstGUID] = table[dstGUID] or {}
tinsert( guidBuffs[dstGUID], { stuff = stuff, priority = priority, and so on } )
else
-- Almost the same
end
end
update( dstGUID )
end
local function checkFilter( spellName, fromPlayer, auraType ) -- Filter aura
local list
if auraType=="HELPFUL" then
list = db.buffFilter.buffs
elseif auraType=="HARMFUL" then
list = db.buffFilter.debuffs
else
return nil
end
if list.never[spellName] then
return nil
elseif fromPlayer and list.my[spellName] then
return list.my[spellName]
elseif list.any[spellName] then
return list.any[spellName]
elseif fromPlayer and list.allMy then
return 1
elseif list.allAny then
return 1
else
return nil
end
end
There are more like SPELL_AURA_REMOVED and the other SPELL_AURA changes on units, but they're far smaller and have no further checks or filtering.