diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index f8c55965..91ce389e 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -401,6 +401,12 @@ UINT32 HWR_Lighting(INT32 light, UINT32 color, UINT32 fadecolor, boolean fogbloc (void)fogblockpoly; + // Don't go out of bounds + if (light < 0) + light = 0; + else if (light > 255) + light = 255; + realcolor.rgba = color; fogcolor.rgba = fadecolor; @@ -488,6 +494,12 @@ static UINT8 HWR_FogBlockAlpha(INT32 light, UINT32 color, UINT32 fadecolor) // L RGBA_t realcolor, fogcolor, surfcolor; INT32 alpha, fogalpha; + // Don't go out of bounds + if (light < 0) + light = 0; + else if (light > 255) + light = 255; + realcolor.rgba = color; fogcolor.rgba = fadecolor;