Fixed potential divide-by-zero in the custom counter module.

This commit is contained in:
Parnic
2015-03-22 21:44:23 -05:00
parent 6daa9ea927
commit 84577ae5e9

View File

@ -548,9 +548,10 @@ function IceCustomCount.prototype:SetCustomColor()
end end
function IceCustomCount.prototype:GetGradientColor(curr) function IceCustomCount.prototype:GetGradientColor(curr)
local max = self:GetMaxCount()
local r, g, b = self:GetCustomColor() local r, g, b = self:GetCustomColor()
local mr, mg, mb = self:GetCustomMinColor() local mr, mg, mb = self:GetCustomMinColor()
local scale = (curr-1)/(self:GetMaxCount()-1) local scale = max > 1 and ((curr-1)/(max-1)) or 1
r = r * scale + mr * (1-scale) r = r * scale + mr * (1-scale)
g = g * scale + mg * (1-scale) g = g * scale + mg * (1-scale)