summaryrefslogtreecommitdiff
path: root/src/resources/dye.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2011-03-16 14:28:45 +0200
committerAndrei Karas <akaras@inbox.ru>2011-03-16 14:28:45 +0200
commit59dc0bffc0f754de8daed29bce3a48e90ea6b4fb (patch)
tree7cd423679a60e25b29318d7a87f367729f8d5fdf /src/resources/dye.cpp
parentfbf665912933d10d9132b17802949149d9094fdd (diff)
downloadmv-59dc0bffc0f754de8daed29bce3a48e90ea6b4fb.tar.gz
mv-59dc0bffc0f754de8daed29bce3a48e90ea6b4fb.tar.bz2
mv-59dc0bffc0f754de8daed29bce3a48e90ea6b4fb.tar.xz
mv-59dc0bffc0f754de8daed29bce3a48e90ea6b4fb.zip
Add checks and fix some code style.
Diffstat (limited to 'src/resources/dye.cpp')
-rw-r--r--src/resources/dye.cpp5
1 files changed, 3 insertions, 2 deletions
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<int>(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];