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