summaryrefslogtreecommitdiff
path: root/src/resources/dye.cpp
diff options
context:
space:
mode:
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];