diff options
author | Andrei Karas <akaras@inbox.ru> | 2011-03-16 14:28:45 +0200 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2011-03-16 14:28:45 +0200 |
commit | 59dc0bffc0f754de8daed29bce3a48e90ea6b4fb (patch) | |
tree | 7cd423679a60e25b29318d7a87f367729f8d5fdf /src/resources/dye.cpp | |
parent | fbf665912933d10d9132b17802949149d9094fdd (diff) | |
download | manaplus-59dc0bffc0f754de8daed29bce3a48e90ea6b4fb.tar.gz manaplus-59dc0bffc0f754de8daed29bce3a48e90ea6b4fb.tar.bz2 manaplus-59dc0bffc0f754de8daed29bce3a48e90ea6b4fb.tar.xz manaplus-59dc0bffc0f754de8daed29bce3a48e90ea6b4fb.zip |
Add checks and fix some code style.
Diffstat (limited to 'src/resources/dye.cpp')
-rw-r--r-- | src/resources/dye.cpp | 5 |
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]; |