- fixed crash in slope drawing: Several overlooked occurences of fixed point math in R_CalcTiltedLighting. Slopes are still completely broken, though.

This commit is contained in:
Christoph Oelckers 2016-04-27 04:08:06 +02:00
parent a26d81e060
commit 8bda356412

View file

@ -287,21 +287,21 @@ void R_CalcTiltedLighting (double lval, double lend, int width)
}
if (width > 0)
{
lval = planeshade - lval;
lend = planeshade - lend;
lval = FIXED2DBL(planeshade) - lval;
lend = FIXED2DBL(planeshade) - lend;
lstep = (lend - lval) / width;
if (lstep < 0)
{ // Going from dark to light
if (lval < FRACUNIT)
if (lval < 1.)
{ // All bright
lightfiller = basecolormapdata;
}
else
{
if (lval >= NUMCOLORMAPS*FRACUNIT)
if (lval >= NUMCOLORMAPS)
{ // Starts beyond the dark end
BYTE *clight = basecolormapdata + ((NUMCOLORMAPS-1) << COLORMAPSHIFT);
while (lval >= NUMCOLORMAPS*FRACUNIT && i <= width)
while (lval >= NUMCOLORMAPS && i <= width)
{
tiltlighting[i++] = clight;
lval += lstep;
@ -319,7 +319,7 @@ void R_CalcTiltedLighting (double lval, double lend, int width)
}
else
{ // Going from light to dark
if (lval >= (NUMCOLORMAPS-1)*FRACUNIT)
if (lval >= (NUMCOLORMAPS-1))
{ // All dark
lightfiller = basecolormapdata + ((NUMCOLORMAPS-1) << COLORMAPSHIFT);
}
@ -332,7 +332,7 @@ void R_CalcTiltedLighting (double lval, double lend, int width)
}
if (i > width)
return;
while (i <= width && lval < (NUMCOLORMAPS-1)*FRACUNIT)
while (i <= width && lval < (NUMCOLORMAPS-1))
{
tiltlighting[i++] = basecolormapdata + (xs_ToInt(lval) << COLORMAPSHIFT);
lval += lstep;