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

@ -393,7 +393,7 @@ void FTGATexture::MakeTexture ()
for(int x=0;x<Width;x++)
{
int v = LittleLong(*p);
Pixels[x*Height+y] = RGB32k[(v>>10) & 0x1f][(v>>5) & 0x1f][v & 0x1f];
Pixels[x*Height+y] = RGB32k.RGB[(v>>10) & 0x1f][(v>>5) & 0x1f][v & 0x1f];
p+=step_x;
}
}
@ -405,7 +405,7 @@ void FTGATexture::MakeTexture ()
BYTE * p = ptr + y * Pitch;
for(int x=0;x<Width;x++)
{
Pixels[x*Height+y] = RGB32k[p[2]>>3][p[1]>>3][p[0]>>3];
Pixels[x*Height+y] = RGB32k.RGB[p[2]>>3][p[1]>>3][p[0]>>3];
p+=step_x;
}
}
@ -419,7 +419,7 @@ void FTGATexture::MakeTexture ()
BYTE * p = ptr + y * Pitch;
for(int x=0;x<Width;x++)
{
Pixels[x*Height+y] = RGB32k[p[2]>>3][p[1]>>3][p[0]>>3];
Pixels[x*Height+y] = RGB32k.RGB[p[2]>>3][p[1]>>3][p[0]>>3];
p+=step_x;
}
}
@ -431,7 +431,7 @@ void FTGATexture::MakeTexture ()
BYTE * p = ptr + y * Pitch;
for(int x=0;x<Width;x++)
{
Pixels[x*Height+y] = p[3] >= 128? RGB32k[p[2]>>3][p[1]>>3][p[0]>>3] : 0;
Pixels[x*Height+y] = p[3] >= 128? RGB32k.RGB[p[2]>>3][p[1]>>3][p[0]>>3] : 0;
p+=step_x;
}
}