From 59dc0bffc0f754de8daed29bce3a48e90ea6b4fb Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Wed, 16 Mar 2011 14:28:45 +0200 Subject: Add checks and fix some code style. --- src/resources/dye.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/resources/dye.cpp') diff --git a/src/resources/dye.cpp b/src/resources/dye.cpp index f9c35c5fc..7d92e12ce 100644 --- a/src/resources/dye.cpp +++ b/src/resources/dye.cpp @@ -118,7 +118,8 @@ void DyePalette::getColor(int intensity, int color[3]) const } int last = static_cast(mColors.size()); - if (last == 0) return; + if (last == 0) + return; int i = intensity * last / 255; int t = intensity * last % 255; @@ -144,7 +145,7 @@ void DyePalette::getColor(int intensity, int color[3]) const // Get the previous color. First color is implicitly black. int r1 = 0, g1 = 0, b1 = 0; - if (i > 0) + if (i > 0 && i < last + 1) { r1 = mColors[i - 1].value[0]; g1 = mColors[i - 1].value[1]; -- cgit v1.2.3-60-g2f50