From 71f3977dbf1ea3ea3cb5808bb341c2b43f66c7b0 Mon Sep 17 00:00:00 2001 From: "Johnny C. Lam" Date: Tue, 16 Oct 2012 02:21:13 +0000 Subject: [PATCH] Don't compile the script so often during combat. The UPDATE_SHAPESHIFT_FORM event fires far more often than it should according to the documentation. It will fire even when the player's shapeshift form or stance doesn't change. Modify the OvaleAura to catch UPDATE_SHAPESHIFT_FORM(S) and verify that the stance actually changed before raising a new event Ovale_UpdateShapeshiftForm that may caught by other Ovale modules that care about stances. This should fix the problem where the script was compiling very often during combat for some classes. git-svn-id: svn://svn.curseforge.net/wow/ovale/mainline/trunk@600 d5049fe3-3747-40f7-a4b5-f36d6801af5f --- Ovale.lua | 28 ++++++++-------------------- OvaleAura.lua | 12 ++++++++++-- 2 files changed, 18 insertions(+), 22 deletions(-) diff --git a/Ovale.lua b/Ovale.lua index 2f4c2c6..047fcd0 100644 --- a/Ovale.lua +++ b/Ovale.lua @@ -61,16 +61,6 @@ BINDING_NAME_OVALE_CHECKBOX2 = L["Inverser la boîte à cocher "].."(3)" BINDING_NAME_OVALE_CHECKBOX3 = L["Inverser la boîte à cocher "].."(4)" BINDING_NAME_OVALE_CHECKBOX4 = L["Inverser la boîte à cocher "].."(5)" --- -local function ShapeshiftEventHandler() - if Ovale.compileOnStances then - Ovale.needCompile = true - else - Ovale.refreshNeeded.player = true - end -end --- - -- function Ovale:Debug() self:Print(OvaleCompile:DebugNode(self.masterNodes[1])) @@ -128,8 +118,7 @@ function Ovale:OnEnable() self:RegisterEvent("GLYPH_UPDATED") self:RegisterEvent("GLYPH_ADDED") self:RegisterEvent("UNIT_INVENTORY_CHANGED") - self:RegisterEvent("UPDATE_SHAPESHIFT_FORM") - self:RegisterEvent("UPDATE_SHAPESHIFT_FORMS") + self:RegisterMessage("Ovale_UpdateShapeshiftForm") self:UpdateVisibility() end @@ -143,8 +132,7 @@ function Ovale:OnDisable() self:UnregisterEvent("GLYPH_UPDATED") self:UnregisterEvent("GLYPH_ADDED") self:UnregisterEvent("UNIT_INVENTORY_CHANGED") - self:UnregisterEvent("UPDATE_SHAPESHIFT_FORM") - self:UnregisterEvent("UPDATE_SHAPESHIFT_FORMS") + self:UnregisterMessage("Ovale_UpdateShapeshiftForm") self.frame:Hide() end @@ -156,12 +144,12 @@ function Ovale:UNIT_INVENTORY_CHANGED() end end -function Ovale:UPDATE_SHAPESHIFT_FORM() - ShapeshiftEventHandler() -end - -function Ovale:UPDATE_SHAPESHIFT_FORMS() - ShapeshiftEventHandler() +function Ovale:Ovale_UpdateShapeshiftForm() + if Ovale.compileOnStances then + Ovale.needCompile = true + else + Ovale.refreshNeeded.player = true + end end --Called when the player target change diff --git a/OvaleAura.lua b/OvaleAura.lua index 188b2ec..a664f0c 100644 --- a/OvaleAura.lua +++ b/OvaleAura.lua @@ -87,11 +87,11 @@ function OvaleAura:PLAYER_ENTERING_WORLD(event) end function OvaleAura:UPDATE_SHAPESHIFT_FORM(event) - self.stance = GetShapeshiftForm() + self:ShapeshiftEventHandler() end function OvaleAura:UPDATE_SHAPESHIFT_FORMS(event) - self.stance = GetShapeshiftForm() + self:ShapeshiftEventHandler() end function OvaleAura:AddAura(unitGUID, spellId, unitCaster, icon, count, debuffType, duration, expirationTime, isStealable, name) @@ -141,6 +141,14 @@ function OvaleAura:AddAura(unitGUID, spellId, unitCaster, icon, count, debuffTyp end -- Private methods +function OvaleAura:ShapeshiftEventHandler() + local newStance = GetShapeshiftForm() + if self.stance ~= newStance then + self.stance = newStance + self:SendMessage("Ovale_UpdateShapeshiftForm") + end +end + function OvaleAura:UpdateAuras(unitId, unitGUID) self.serial = self.serial + 1 -- 1.7.9.5