optimize apply/remove_lum

Light sources no longer track applied lumcounts in an assocative list,
using shared-indices with the applied turf list instead.

Signed-off-by: Mloc <colmohici@gmail.com>
This commit is contained in:
Mloc
2015-07-09 19:50:19 +01:00
parent 291f0b8556
commit bd705fb7e0

View File

@@ -143,15 +143,19 @@
if(!strength) //Don't add turfs that aren't affected to the affected turfs.
continue
effect_r[T.lighting_overlay] = round(lum_r * strength, LIGHTING_ROUND_VALUE)
effect_g[T.lighting_overlay] = round(lum_g * strength, LIGHTING_ROUND_VALUE)
effect_b[T.lighting_overlay] = round(lum_b * strength, LIGHTING_ROUND_VALUE)
effect_r += round(lum_r * strength, LIGHTING_ROUND_VALUE)
effect_g += round(lum_g * strength, LIGHTING_ROUND_VALUE)
effect_b += round(lum_b * strength, LIGHTING_ROUND_VALUE)
T.lighting_overlay.update_lumcount(
round(lum_r * strength, LIGHTING_ROUND_VALUE),
round(lum_g * strength, LIGHTING_ROUND_VALUE),
round(lum_b * strength, LIGHTING_ROUND_VALUE)
)
else
effect_r += 0
effect_g += 0
effect_b += 0
if(!T.affecting_lights)
T.affecting_lights = list()
@@ -161,12 +165,15 @@
/datum/light_source/proc/remove_lum()
applied = 0
var/i = 1
for(var/turf/T in effect_turf)
if(T.affecting_lights)
T.affecting_lights -= src
if(T.lighting_overlay)
T.lighting_overlay.update_lumcount(-effect_r[T.lighting_overlay], -effect_g[T.lighting_overlay], -effect_b[T.lighting_overlay])
T.lighting_overlay.update_lumcount(-effect_r[i], -effect_g[i], -effect_b[i])
i++
effect_r.Cut()
effect_g.Cut()