mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-01-04 05:51:54 +00:00
It occured to me, we didn't have a good way to "see" what turfs were actually being updated Figured I'd fix that I've also added some debug vars on SSlighting to make testing with/without some checks easier Speaking of which, I've added a second check to lighting corner updating Basically, if our past and current cached rgb values are the same, there's no point updating This is possible because static lighting is relative. If you've got a TON of blue, it'll outweight the red and green you have in smaller amounts We also do some rounding to ensure values look right Similarly, if you've got roughly the same lighting, and a bit of something you already have a lot of is added, you're not likely to actually enter a new "bracket" of color Anyway uh, it's hard to profile this, but I've seen it help quite a bit, mostly with things like emergency lighting that updates lighting in small amounts often, and in constricted spaces. To some extent just comes down to map design
91 lines
1.9 KiB
Plaintext
91 lines
1.9 KiB
Plaintext
SUBSYSTEM_DEF(lighting)
|
|
name = "Lighting"
|
|
wait = 2
|
|
init_order = INIT_ORDER_LIGHTING
|
|
flags = SS_TICKER
|
|
var/static/list/sources_queue = list() // List of lighting sources queued for update.
|
|
var/static/list/corners_queue = list() // List of lighting corners queued for update.
|
|
var/static/list/objects_queue = list() // List of lighting objects queued for update.
|
|
#ifdef VISUALIZE_LIGHT_UPDATES
|
|
var/allow_duped_values = FALSE
|
|
var/allow_duped_corners = FALSE
|
|
#endif
|
|
|
|
/datum/controller/subsystem/lighting/stat_entry(msg)
|
|
msg = "L:[length(sources_queue)]|C:[length(corners_queue)]|O:[length(objects_queue)]"
|
|
return ..()
|
|
|
|
|
|
/datum/controller/subsystem/lighting/Initialize(timeofday)
|
|
if(!initialized)
|
|
create_all_lighting_objects()
|
|
initialized = TRUE
|
|
|
|
fire(FALSE, TRUE)
|
|
|
|
return ..()
|
|
|
|
/datum/controller/subsystem/lighting/fire(resumed, init_tick_checks)
|
|
MC_SPLIT_TICK_INIT(3)
|
|
if(!init_tick_checks)
|
|
MC_SPLIT_TICK
|
|
var/list/queue = sources_queue
|
|
var/i = 0
|
|
for (i in 1 to length(queue))
|
|
var/datum/light_source/L = queue[i]
|
|
|
|
L.update_corners()
|
|
|
|
L.needs_update = LIGHTING_NO_UPDATE
|
|
|
|
if(init_tick_checks)
|
|
CHECK_TICK
|
|
else if (MC_TICK_CHECK)
|
|
break
|
|
if (i)
|
|
queue.Cut(1, i+1)
|
|
i = 0
|
|
|
|
if(!init_tick_checks)
|
|
MC_SPLIT_TICK
|
|
|
|
queue = corners_queue
|
|
for (i in 1 to length(queue))
|
|
var/datum/lighting_corner/C = queue[i]
|
|
|
|
C.needs_update = FALSE //update_objects() can call qdel if the corner is storing no data
|
|
C.update_objects()
|
|
|
|
if(init_tick_checks)
|
|
CHECK_TICK
|
|
else if (MC_TICK_CHECK)
|
|
break
|
|
if (i)
|
|
queue.Cut(1, i+1)
|
|
i = 0
|
|
|
|
|
|
if(!init_tick_checks)
|
|
MC_SPLIT_TICK
|
|
|
|
queue = objects_queue
|
|
for (i in 1 to length(queue))
|
|
var/datum/lighting_object/O = queue[i]
|
|
|
|
if (QDELETED(O))
|
|
continue
|
|
|
|
O.update()
|
|
O.needs_update = FALSE
|
|
if(init_tick_checks)
|
|
CHECK_TICK
|
|
else if (MC_TICK_CHECK)
|
|
break
|
|
if (i)
|
|
queue.Cut(1, i+1)
|
|
|
|
|
|
/datum/controller/subsystem/lighting/Recover()
|
|
initialized = SSlighting.initialized
|
|
..()
|