Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions ContentLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -743,8 +743,11 @@ ALLEGRO_COLOR lookupMaterialColor(int matType, int matIndex, int dyeType, int dy
DFColor:
DFHack::MaterialInfo mat;
if(mat.decode(matType, matIndex)) {
auto cd = df::global::world->raws.descriptors.colors[mat.material->state_color[0]];
return al_map_rgb_f(cd->red, cd->green, cd->blue) * dyeColor;
int16_t colorIdx = mat.material->state_color[0];
if (colorIdx >= 0 && size_t(colorIdx) < df::global::world->raws.descriptors.colors.size()) {
auto cd = df::global::world->raws.descriptors.colors[colorIdx];
return al_map_rgb_f(cd->red, cd->green, cd->blue) * dyeColor;
}
}
return defaultColor * dyeColor;
}
Expand Down
1 change: 1 addition & 0 deletions docs/changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ Template for new versions:
## New Features

## Fixes
- `stonesense`: fixed a crash when rendering materials with an out-of-range color index

## Misc Improvements

Expand Down
Loading