From b46ea825116c79f112b53f03d0fa8df99c990aef Mon Sep 17 00:00:00 2001 From: Parnic Date: Thu, 1 Dec 2011 23:00:56 +0000 Subject: [PATCH] - cooldown bar fixes submitted by JontomXire (thanks!) --- modules/CustomCDBar.lua | 35 +++++++++++++---------------------- 1 file changed, 13 insertions(+), 22 deletions(-) diff --git a/modules/CustomCDBar.lua b/modules/CustomCDBar.lua index a456c2b..d8e5f72 100644 --- a/modules/CustomCDBar.lua +++ b/modules/CustomCDBar.lua @@ -478,35 +478,26 @@ function IceCustomCDBar.prototype:GetCooldownDuration(buffName) buffName = self:GetSpellNameOrId(buffName) local now = GetTime() - local localDuration = nil - local localStart, localRemaining, hasCooldown = GetSpellCooldown(buffName) + local localRemaining = nil + local localStart, localDuration, hasCooldown = GetSpellCooldown(buffName) if (hasCooldown == 1 and localRemaining > 1.5) then -- the item has a potential cooldown - if localStart == 0 and localRemaining == 0 then - return nil, nil - elseif (localStart > now) then - localRemaining = localRemaining + (localStart - now) - localDuration = localRemaining - else - localRemaining = localRemaining + (localStart - now) - localDuration = (now - localStart) + localRemaining - end - - if self.moduleSettings.maxDuration and tonumber(self.moduleSettings.maxDuration) ~= 0 and localDuration > 1.5 then - localDuration = tonumber(self.moduleSettings.maxDuration) - end - - if localDuration > 1.5 then - return localDuration, localRemaining - else - localRemaining = (self.cooldownEndTime or now) - now - if localRemaining > 0 then - return self.cooldownDuration, localRemaining + if (localDuration <= 1.5) then + if (self.cooldownEndTime > now) then + return self.cooldownDuration, (self.cooldownEndTime - now) else return nil, nil end end + + localRemaining = localDuration + (localStart - now) + + if self.moduleSettings.maxDuration and tonumber(self.moduleSettings.maxDuration) ~= 0 then + localDuration = tonumber(self.moduleSettings.maxDuration) + end + + return localDuration, localRemaining else return nil, nil end