Change RGB32k to a union of BYTE[32][32][32] and BYTE[32*32*32]

- Clang's optional runtime array bounds checking doesn't understand when we
  intentionally "overflow" by doing this:
    RGB32k[0][0][colorval]
  It will warn that it was accessed at an index will past the bounds
  of type 'BYTE [32]', which makes it less than useful for catching real
  array bounds overflows. So now do this:
    RGB32k.All[colorval]
  And if you want this:
    RGB32k[r][g][b]
  Now do this:
    RGB32k.RGB[r][g][b]
This commit is contained in:
Randy Heit 2015-03-08 18:05:02 -05:00
commit e259087c19
13 changed files with 88 additions and 77 deletions

View file

@ -551,7 +551,7 @@ void FDDSTexture::ReadRGB (FWadLump &lump, BYTE *tcbuf)
DWORD r = (c & RMask) << RShiftL; r |= r >> RShiftR;
DWORD g = (c & GMask) << GShiftL; g |= g >> GShiftR;
DWORD b = (c & BMask) << BShiftL; b |= b >> BShiftR;
*pixelp = RGB32k[r >> 27][g >> 27][b >> 27];
*pixelp = RGB32k.RGB[r >> 27][g >> 27][b >> 27];
}
else
{
@ -637,7 +637,7 @@ void FDDSTexture::DecompressDXT1 (FWadLump &lump, BYTE *tcbuf)
// Pick colors from the palette for each of the four colors.
/*if (!tcbuf)*/ for (i = 3; i >= 0; --i)
{
palcol[i] = color[i].a ? RGB32k[color[i].r >> 3][color[i].g >> 3][color[i].b >> 3] : 0;
palcol[i] = color[i].a ? RGB32k.RGB[color[i].r >> 3][color[i].g >> 3][color[i].b >> 3] : 0;
}
// Now decode this 4x4 block to the pixel buffer.
for (y = 0; y < 4; ++y)
@ -717,7 +717,7 @@ void FDDSTexture::DecompressDXT3 (FWadLump &lump, bool premultiplied, BYTE *tcbu
// Pick colors from the palette for each of the four colors.
if (!tcbuf) for (i = 3; i >= 0; --i)
{
palcol[i] = RGB32k[color[i].r >> 3][color[i].g >> 3][color[i].b >> 3];
palcol[i] = RGB32k.RGB[color[i].r >> 3][color[i].g >> 3][color[i].b >> 3];
}
// Now decode this 4x4 block to the pixel buffer.
for (y = 0; y < 4; ++y)
@ -822,7 +822,7 @@ void FDDSTexture::DecompressDXT5 (FWadLump &lump, bool premultiplied, BYTE *tcbu
// Pick colors from the palette for each of the four colors.
if (!tcbuf) for (i = 3; i >= 0; --i)
{
palcol[i] = RGB32k[color[i].r >> 3][color[i].g >> 3][color[i].b >> 3];
palcol[i] = RGB32k.RGB[color[i].r >> 3][color[i].g >> 3][color[i].b >> 3];
}
// Now decode this 4x4 block to the pixel buffer.
for (y = 0; y < 4; ++y)