From 46093cad14dd18ba2fb22f126afd5bb6ad01a803 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 1 Jan 2017 17:50:13 +0100 Subject: [PATCH] - fixed: FLightDefaults::ApplyProperties must always validate the light's radius. --- src/gl/dynlights/gl_dynlight.cpp | 34 +++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/src/gl/dynlights/gl_dynlight.cpp b/src/gl/dynlights/gl_dynlight.cpp index de05bb19f..b55862719 100644 --- a/src/gl/dynlights/gl_dynlight.cpp +++ b/src/gl/dynlights/gl_dynlight.cpp @@ -181,7 +181,9 @@ void FLightDefaults::ApplyProperties(ADynamicLight * light) const if (m_additive) light->flags4 |= MF4_ADDITIVE; if (m_dontlightself) light->flags4 |= MF4_DONTLIGHTSELF; light->m_tickCount = 0; - if (m_type == PulseLight) + switch (m_type) + { + case PulseLight: { float pulseTime = float(m_Param / TICRATE); @@ -190,6 +192,36 @@ void FLightDefaults::ApplyProperties(ADynamicLight * light) const light->m_cycler.ShouldCycle(true); light->m_cycler.SetCycleType(CYCLE_Sin); light->m_currentRadius = light->m_cycler.GetVal(); + break; + } + + case FlickerLight: + case RandomFlickerLight: + { + float minrad = float(MIN(light->m_Radius[0], light->m_Radius[1])); + float maxrad = float(MAX(light->m_Radius[0], light->m_Radius[1])); + light->m_currentRadius = clamp(light->m_currentRadius, minrad, maxrad); + break; + } + + case PointLight: + light->m_currentRadius = float(light->m_Radius[0]); + break; + + case SectorLight: + { + float intensity; + float scale = light->args[LIGHT_SCALE] / 8.f; + + if (scale == 0.f) scale = 1.f; + + intensity = light->Sector->lightlevel * scale; + intensity = clamp(intensity, 0.f, 255.f); + + light->m_currentRadius = intensity; + break; + } + } switch (m_attenuate)