From 9e10e3278bc4bbd0b916c1fd888c96618d9845e6 Mon Sep 17 00:00:00 2001
From: Sryder13 <sryder13@gmail.com>
Date: Mon, 24 Mar 2014 17:11:45 +0000
Subject: [PATCH] Negative Light

Light no longer goes wrong when lightlevel of a sector is negative.
---
 src/hardware/hw_main.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c
index f8c55965e..91ce389e7 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;
 
-- 
GitLab