add assertions to avoid crash with wrongly indexed graphics

This commit is contained in:
Tim Felgentreff 2022-05-02 21:40:39 +02:00
parent 654a2409ef
commit 2d27c0a764

View file

@ -1287,6 +1287,8 @@ void GraphicPlayerPixels(int colorIndex, const CGraphic &sprite)
Assert(SDL_MUSTLOCK(sprite.Surface) == 0);
std::vector<SDL_Color> sdlColors = std::vector<SDL_Color>(PlayerColorsRGB[colorIndex].begin(), PlayerColorsRGB[colorIndex].end());
Assert(sprite.Surface->format->palette);
Assert(sprite.Surface->format->palette->ncolors > PlayerColorIndexStart + PlayerColorIndexCount);
SDL_SetPaletteColors(sprite.Surface->format->palette, &sdlColors[0], PlayerColorIndexStart, PlayerColorIndexCount);
if (sprite.SurfaceFlip) {
SDL_SetPaletteColors(sprite.SurfaceFlip->format->palette, &sdlColors[0], PlayerColorIndexStart, PlayerColorIndexCount);