Lighting SS speedup

Best of both worlds: No colons AND no pointless typechecking!
This commit is contained in:
MrPerson
2015-06-22 04:09:33 -07:00
parent c79963f7b7
commit e507613fbe
+21 -32
View File
@@ -32,62 +32,55 @@ var/datum/subsystem/lighting/SSlighting
/datum/subsystem/lighting/fire()
changed_lights_workload = MC_AVERAGE(changed_lights_workload, changed_lights.len)
// for(var/area/A in sortedAreas)
// A.luminosity = 1
for(var/datum/light_source/thing in changed_lights)
thing.check()
for(var/thing in changed_lights)
var/datum/light_source/LS = thing
LS.check()
changed_lights.Cut()
changed_turfs_workload = MC_AVERAGE(changed_turfs_workload, changed_turfs.len)
for(var/turf/thing in changed_turfs)
if(thing && thing.lighting_changed)
thing.redraw_lighting()
for(var/thing in changed_turfs)
var/turf/T = thing
if(T.lighting_changed)
T.redraw_lighting()
changed_turfs.Cut()
// for(var/area/A in sortedAreas)
// A.luminosity = !A.lighting_use_dynamic
//same as above except it attempts to shift ALL turfs in the world regardless of lighting_changed status
//Does not loop. Should be run prior to process() being called for the first time.
//Note: if we get additional z-levels at runtime (e.g. if the gateway thin ever gets finished) we can initialize specific
//z-levels with the z_level argument
/datum/subsystem/lighting/Initialize(timeofday, z_level)
// for(var/area/A in sortedAreas)
// A.luminosity = 1
for(var/datum/light_source/thing in changed_lights)
thing.add_effect()
thing.changed = 0
for(var/thing in changed_lights)
var/datum/light_source/LS = thing
LS.check()
changed_lights.Cut()
var/z_start = 1
var/z_finish = world.maxz
if(1 <= z_level && z_level <= world.maxz)
if(z_level >= 1 && z_level <= world.maxz)
z_level = round(z_level)
z_start = z_level
z_finish = z_level
var/list/turfs_to_init = block(locate(1, 1, z_start), locate(world.maxx, world.maxy, z_finish))
for(var/turf/T in turfs_to_init)
for(var/thing in turfs_to_init)
var/turf/T = thing
T.init_lighting()
if(z_level)
//we need to loop through to clear only shifted turfs from the list. or we will cause errors
var/i=1
for(var/turf/thing in changed_turfs)
if(thing && thing.z < z_start && z_finish < thing.z)
for(var/thing in changed_turfs)
var/turf/T = thing
if(T.z in z_start to z_finish)
++i
continue
changed_turfs.Cut(i, i+1)
else
changed_turfs.Cut()
// for(var/area/A in sortedAreas)
// A.luminosity = !A.lighting_use_dynamic
..()
//Used to strip valid information from an existing instance and transfer it to the replacement. i.e. when a crash occurs
@@ -99,14 +92,13 @@ var/datum/subsystem/lighting/SSlighting
if(!istype(SSlighting.changed_lights))
SSlighting.changed_lights = list()
// for(var/area/A in sortedAreas)
// A.luminosity = 1
for(var/datum/light_source/L in SSlighting.changed_lights)
for(var/thing in SSlighting.changed_lights)
var/datum/light_source/LS = thing
spawn(-1) //so we don't crash the loop (inefficient)
L.check()
LS.check()
for(var/turf/T in changed_turfs)
for(var/thing in changed_turfs)
var/turf/T = thing
if(T.lighting_changed)
spawn(-1)
T.redraw_lighting()
@@ -123,6 +115,3 @@ var/datum/subsystem/lighting/SSlighting
varval2 = "/list([length(varval2)])"
msg += "\t [varname] = [varval1] -> [varval2]\n"
world.log << msg
// for(var/area/A in sortedAreas)
// A.luminosity = !A.lighting_use_dynamic