From 88de781c1c3a16c5cdd614a7892f9762f552fec5 Mon Sep 17 00:00:00 2001 From: "Johnny C. Lam" Date: Sat, 23 Mar 2013 21:37:59 +0000 Subject: [PATCH] OvaleAura's UpdateAuras() should never be called outside of the module. git-svn-id: svn://svn.curseforge.net/wow/ovale/mainline/trunk@813 d5049fe3-3747-40f7-a4b5-f36d6801af5f --- OvaleAura.lua | 133 ++++++++++++++++++++++++++++----------------------------- 1 file changed, 66 insertions(+), 67 deletions(-) diff --git a/OvaleAura.lua b/OvaleAura.lua index aeb41fe..44557ad 100644 --- a/OvaleAura.lua +++ b/OvaleAura.lua @@ -122,71 +122,8 @@ function RemoveAurasForMissingUnits() end end end --- - --- -function OvaleAura:OnEnable() - self:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED") - self:RegisterEvent("PLAYER_ENTERING_WORLD") - self:RegisterEvent("UNIT_AURA") - self:RegisterMessage("Ovale_GroupChanged", RemoveAurasForMissingUnits) - self:RegisterMessage("Ovale_InactiveUnit") -end - -function OvaleAura:OnDisable() - self:UnregisterEvent("COMBAT_LOG_EVENT_UNFILTERED") - self:UnregisterEvent("PLAYER_ENTERING_WORLD") - self:UnregisterEvent("UNIT_AURA") - self:UnregisterMessage("Ovale_GroupChanged") - self:UnregisterMessage("Ovale_InactiveUnit") -end - -function OvaleAura:COMBAT_LOG_EVENT_UNFILTERED(event, ...) - local timestamp, event, hideCaster, sourceGUID, sourceName, sourceFlags, sourceRaidFlags, destGUID, destName, destFlags, destRaidFlags = select(1, ...) - - if event == "UNIT_DIED" then - RemoveAurasForGUID(destGUID) - elseif strfind(event, "SPELL_AURA_") == 1 then - -- KNOWN BUG: an aura refreshed by a spell other than then one that applies it won't cause the CLEU event to fire. - local spellId, spellName, spellSchool, auraType = select(12, ...) - - -- Only update for "*target" unit IDs. All others are handled by UNIT_AURA event handler. - local unitId = OvaleGUID:GetUnitId(destGUID) - if unitId and unitId ~= "target" and strfind(unitId, "target") then - self:UpdateAuras(unitId, destGUID) - end - - if sourceGUID == OvaleGUID:GetGUID("player") and (event == "SPELL_AURA_APPLIED" or event == "SPELL_AURA_REFRESH" or event == "SPELL_AURA_APPLIED_DOSE") then - local filter = "HELPFUL" - if API_IsHarmfulSpell(spellName) then - filter = "HARMFUL" - end - if self:GetAuraByGUID(destGUID, spellId, filter, true) then - local aura = self_aura[destGUID][filter][spellId].mine - aura.spellHasteMultiplier = OvalePaperDoll:GetSpellHasteMultiplier() - end - end - end -end - -function OvaleAura:PLAYER_ENTERING_WORLD(event) - RemoveAurasForMissingUnits() - self_pool:Drain() -end - -function OvaleAura:UNIT_AURA(event, unitId) - if unitId == "player" then - self:UpdateAuras("player", OvaleGUID:GetGUID("player")) - elseif unitId then - self:UpdateAuras(unitId) - end -end - -function OvaleAura:Ovale_InactiveUnit(event, guid) - RemoveAurasForGUID(guid) -end -function OvaleAura:UpdateAuras(unitId, unitGUID) +function UpdateAuras(unitId, unitGUID) self_serial = self_serial + 1 local damageMultiplier @@ -269,8 +206,70 @@ function OvaleAura:UpdateAuras(unitId, unitGUID) Ovale.refreshNeeded[unitId] = true end +-- + +-- +function OvaleAura:OnEnable() + self:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED") + self:RegisterEvent("PLAYER_ENTERING_WORLD") + self:RegisterEvent("UNIT_AURA") + self:RegisterMessage("Ovale_GroupChanged", RemoveAurasForMissingUnits) + self:RegisterMessage("Ovale_InactiveUnit") +end + +function OvaleAura:OnDisable() + self:UnregisterEvent("COMBAT_LOG_EVENT_UNFILTERED") + self:UnregisterEvent("PLAYER_ENTERING_WORLD") + self:UnregisterEvent("UNIT_AURA") + self:UnregisterMessage("Ovale_GroupChanged") + self:UnregisterMessage("Ovale_InactiveUnit") +end + +function OvaleAura:COMBAT_LOG_EVENT_UNFILTERED(event, ...) + local timestamp, event, hideCaster, sourceGUID, sourceName, sourceFlags, sourceRaidFlags, destGUID, destName, destFlags, destRaidFlags = select(1, ...) + + if event == "UNIT_DIED" then + RemoveAurasForGUID(destGUID) + elseif strfind(event, "SPELL_AURA_") == 1 then + -- KNOWN BUG: an aura refreshed by a spell other than then one that applies it won't cause the CLEU event to fire. + local spellId, spellName, spellSchool, auraType = select(12, ...) + + -- Only update for "*target" unit IDs. All others are handled by UNIT_AURA event handler. + local unitId = OvaleGUID:GetUnitId(destGUID) + if unitId and unitId ~= "target" and strfind(unitId, "target") then + UpdateAuras(unitId, destGUID) + end + + if sourceGUID == OvaleGUID:GetGUID("player") and (event == "SPELL_AURA_APPLIED" or event == "SPELL_AURA_REFRESH" or event == "SPELL_AURA_APPLIED_DOSE") then + local filter = "HELPFUL" + if API_IsHarmfulSpell(spellName) then + filter = "HARMFUL" + end + if self:GetAuraByGUID(destGUID, spellId, filter, true) then + local aura = self_aura[destGUID][filter][spellId].mine + aura.spellHasteMultiplier = OvalePaperDoll:GetSpellHasteMultiplier() + end + end + end +end + +function OvaleAura:PLAYER_ENTERING_WORLD(event) + RemoveAurasForMissingUnits() + self_pool:Drain() +end + +function OvaleAura:UNIT_AURA(event, unitId) + if unitId == "player" then + UpdateAuras("player", OvaleGUID:GetGUID("player")) + elseif unitId then + UpdateAuras(unitId) + end +end + +function OvaleAura:Ovale_InactiveUnit(event, guid) + RemoveAurasForGUID(guid) +end --- Public methods function OvaleAura:GetAuraByGUID(guid, spellId, filter, mine, unitId) if not guid then Ovale:Log(tostring(guid) .. " does not exists in OvaleAura") @@ -286,7 +285,7 @@ function OvaleAura:GetAuraByGUID(guid, spellId, filter, mine, unitId) Ovale:Log("Unable to get unitId from " .. tostring(guid)) return nil end - self:UpdateAuras(unitId, guid) + UpdateAuras(unitId, guid) auraTable = self_aura[guid] if not auraTable then -- no aura on target @@ -389,7 +388,7 @@ function OvaleAura:GetDamageMultiplier(spellId) local si = OvaleData.spellInfo[spellId] if si and si.damageAura then local guid = OvaleGUID:GetGUID("player") - self:UpdateAuras("player", guid) + UpdateAuras("player", guid) local auraTable = self_aura[guid] if auraTable then for filter, filterInfo in pairs(si.damageAura) do -- 1.7.9.5