Fixed GCD occasionally showing when it shouldn't

Ticket #199 - thanks nandchan!
This commit is contained in:
Parnic
2015-12-22 00:39:39 -06:00
parent 30f3210d30
commit 45686f5a36

View File

@ -22,14 +22,17 @@ function GlobalCoolDown.prototype:Enable(core)
self.moduleSettings.inverse = "NORMAL" self.moduleSettings.inverse = "NORMAL"
end end
self:RegisterEvent("UNIT_SPELLCAST_SENT","SpellCastSent")
--self:RegisterEvent("ACTIONBAR_UPDATE_COOLDOWN", "CooldownStateChanged") --self:RegisterEvent("ACTIONBAR_UPDATE_COOLDOWN", "CooldownStateChanged")
self:RegisterEvent("UNIT_SPELLCAST_START","CooldownStateChanged") self:RegisterEvent("UNIT_SPELLCAST_START","CooldownStateChanged")
self:RegisterEvent("UNIT_SPELLCAST_CHANNEL_START","CooldownStateChanged") self:RegisterEvent("UNIT_SPELLCAST_CHANNEL_START","CooldownStateChanged")
self:RegisterEvent("UNIT_SPELLCAST_SUCCEEDED","CooldownStateChanged") self:RegisterEvent("UNIT_SPELLCAST_SUCCEEDED","CooldownStateChanged")
self:RegisterEvent("UNIT_SPELLCAST_SENT","SpellCastSent")
self:RegisterEvent("UNIT_SPELLCAST_INTERRUPTED","CooldownAborted") self:RegisterEvent("UNIT_SPELLCAST_CHANNEL_STOP","SpellCastStop")
self:RegisterEvent("UNIT_SPELLCAST_FAILED","CooldownAborted") self:RegisterEvent("UNIT_SPELLCAST_INTERRUPTED","SpellCastStop")
self:RegisterEvent("UNIT_SPELLCAST_FAILED","SpellCastStop")
self:RegisterEvent("UNIT_SPELLCAST_STOP","SpellCastStop")
self:RegisterEvent("CVAR_UPDATE", "CVarUpdate") self:RegisterEvent("CVAR_UPDATE", "CVarUpdate")
@ -47,15 +50,6 @@ function GlobalCoolDown.prototype:CVarUpdate()
self.fixedLatency = tonumber(GetCVar("maxSpellStartRecoveryoffset")) / 1000.0 self.fixedLatency = tonumber(GetCVar("maxSpellStartRecoveryoffset")) / 1000.0
end end
function GlobalCoolDown.prototype:CooldownAborted(event, unit, spell)
if unit ~= "player" or not spell or not self.CurrSpell or self.CurrSpell ~= spell then
return
end
self.CurrLerpTime = self.moduleSettings.desiredLerpTime
self.CurrSpell = nil
end
-- OVERRIDE -- OVERRIDE
function GlobalCoolDown.prototype:GetDefaultSettings() function GlobalCoolDown.prototype:GetDefaultSettings()
local settings = GlobalCoolDown.super.prototype.GetDefaultSettings(self) local settings = GlobalCoolDown.super.prototype.GetDefaultSettings(self)
@ -137,6 +131,18 @@ function GlobalCoolDown.prototype:SpellCastSent(event, unit, spell)
self.spellCastSent = GetTime() self.spellCastSent = GetTime()
end end
function GlobalCoolDown.prototype:SpellCastStop(event, unit, spell, _, _, spellId)
if unit ~= "player" or not spellId or not self.CurrSpellId or self.CurrSpellId ~= spellId then
return
end
self.CurrSpellId = nil
if event == "UNIT_SPELLCAST_INTERRUPTED" or event == "UNIT_SPELLCAST_FAILED" then
self.CurrLerpTime = self.moduleSettings.desiredLerpTime
end
end
function GlobalCoolDown.prototype:GetSpellCastTime(spell) function GlobalCoolDown.prototype:GetSpellCastTime(spell)
if not spell then if not spell then
return nil, nil return nil, nil
@ -161,6 +167,16 @@ function GlobalCoolDown.prototype:CooldownStateChanged(event, unit, spell, _, _,
return return
end end
-- Ignore all events unrelated to the spell currently being cast
if self.CurrSpellId and self.CurrSpellId ~= spellId then
return
end
-- Update the current spell ID for all events indicating a spellcast is starting
if event ~= "UNIT_SPELLCAST_SUCCEEDED" then
self.CurrSpellId = spellId
end
if not self.moduleSettings.showDuringCast then if not self.moduleSettings.showDuringCast then
local castTime = self:GetSpellCastTime(spellId) local castTime = self:GetSpellCastTime(spellId)
local channeledSpellName = UnitChannelInfo(unit) local channeledSpellName = UnitChannelInfo(unit)
@ -183,7 +199,6 @@ function GlobalCoolDown.prototype:CooldownStateChanged(event, unit, spell, _, _,
self.CurrLerpTime = 0 self.CurrLerpTime = 0
self.lastLerpTime = GetTime() self.lastLerpTime = GetTime()
self.moduleSettings.desiredLerpTime = dur or 1 self.moduleSettings.desiredLerpTime = dur or 1
self.CurrSpell = spell
self:UpdateBar(0, "GlobalCoolDown") self:UpdateBar(0, "GlobalCoolDown")
self:Show(true) self:Show(true)
@ -202,10 +217,6 @@ function GlobalCoolDown.prototype:CooldownStateChanged(event, unit, spell, _, _,
self.spellCastSent = nil self.spellCastSent = nil
end end
end end
if event == "UNIT_SPELLCAST_SUCCEEDED" then
self.CurrSpell = nil
end
end end
function GlobalCoolDown.prototype:MyOnUpdate() function GlobalCoolDown.prototype:MyOnUpdate()