diff --git a/src/p_setup.c b/src/p_setup.c index f652e2031..c03dea812 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -434,12 +434,12 @@ static inline float P_SegLengthFloat(seg_t *seg) void P_UpdateSegLightOffset(seg_t *li) { const UINT8 contrast = 8; + const fixed_t contrastFixed = ((fixed_t)contrast) * FRACUNIT; + fixed_t light = FRACUNIT; fixed_t extralight = 0; - extralight = -((fixed_t)contrast*FRACUNIT) + - FixedDiv(AngleFixed(R_PointToAngle2(0, 0, - abs(li->v1->x - li->v2->x), - abs(li->v1->y - li->v2->y))), 90*FRACUNIT) * ((fixed_t)contrast * 2); + light = FixedDiv(R_PointToAngle2(0, 0, abs(li->v1->x - li->v2->x), abs(li->v1->y - li->v2->y)), ANGLE_90); + extralight = -contrastFixed + FixedMul(light, contrastFixed * 2); // Between -2 and 2 for software, -8 and 8 for hardware li->lightOffset = FixedFloor((extralight / contrast) + (FRACUNIT / 2)) / FRACUNIT; diff --git a/src/p_slopes.c b/src/p_slopes.c index 52bb914ec..2b52d6153 100644 --- a/src/p_slopes.c +++ b/src/p_slopes.c @@ -52,7 +52,7 @@ static void P_UpdateSlopeLightOffset(pslope_t *slope) zMul = min(FRACUNIT, abs(slope->zdelta)*3/2); // *3/2, to make 60 degree slopes match walls. contrastFixed = FixedMul(contrastFixed, zMul); - extralight = -contrastFixed + FixedMul(FixedDiv(AngleFixed(slopeDir), 90*FRACUNIT), (contrastFixed * 2)); + extralight = -contrastFixed + FixedMul(FixedDiv(AngleFixed(slopeDir), ANGLE_90), (contrastFixed * 2)); // Between -2 and 2 for software, -8 and 8 for hardware slope->lightOffset = FixedFloor((extralight / 8) + (FRACUNIT / 2)) / FRACUNIT; diff --git a/src/r_plane.c b/src/r_plane.c index 8e98d9c32..3e202993a 100644 --- a/src/r_plane.c +++ b/src/r_plane.c @@ -421,7 +421,7 @@ visplane_t *R_FindPlane(fixed_t height, INT32 picnum, INT32 lightlevel, if (slope != NULL) { - lightlevel += (slope->lightOffset / 8); + lightlevel += slope->lightOffset * 8; } // This appears to fix the Nimbus Ruins sky bug.