mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-07-09 23:27:56 +01:00
21b4095dfd
Upstream 04/17/2026 fixes https://github.com/Bubberstation/Bubberstation/issues/5549 --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: tgstation-ci[bot] <179393467+tgstation-ci[bot]@users.noreply.github.com> Co-authored-by: ArcaneMusic <41715314+ArcaneMusic@users.noreply.github.com> Co-authored-by: MrMelbert <51863163+MrMelbert@users.noreply.github.com> Co-authored-by: Rhials <28870487+Rhials@users.noreply.github.com> Co-authored-by: rageguy505 <54517726+rageguy505@users.noreply.github.com> Co-authored-by: LemonInTheDark <58055496+LemonInTheDark@users.noreply.github.com> Co-authored-by: John Willard <53777086+JohnFulpWillard@users.noreply.github.com> Co-authored-by: Aliceee2ch <160794176+Aliceee2ch@users.noreply.github.com> Co-authored-by: Time-Green <7501474+Time-Green@users.noreply.github.com> Co-authored-by: Tsar-Salat <62388554+Tsar-Salat@users.noreply.github.com> Co-authored-by: SmArtKar <44720187+SmArtKar@users.noreply.github.com> Co-authored-by: Maxipat <108554989+Maxipat112@users.noreply.github.com> Co-authored-by: SyncIt21 <110812394+SyncIt21@users.noreply.github.com> Co-authored-by: deltanedas <39013340+deltanedas@users.noreply.github.com> Co-authored-by: SimplyLogan <47579821+loganuk@users.noreply.github.com> Co-authored-by: loganuk <fakeemail123@aol.com> Co-authored-by: Leland Kemble <70413276+lelandkemble@users.noreply.github.com> Co-authored-by: FalloutFalcon <86381784+FalloutFalcon@users.noreply.github.com> Co-authored-by: Roxy <75404941+TealSeer@users.noreply.github.com> Co-authored-by: Lucy <lucy@absolucy.moe> Co-authored-by: siliconOpossum <138069572+siliconOpossum@users.noreply.github.com> Co-authored-by: Isratosh <Isratosh@hotmail.com> Co-authored-by: TheRyeGuyWhoWillNowDie <70169560+TheRyeGuyWhoWillNowDie@users.noreply.github.com> Co-authored-by: Neocloudy <88008002+Neocloudy@users.noreply.github.com> Co-authored-by: Alexander V. <volas@ya.ru> Co-authored-by: ElGitificador <168473461+ElGitificador@users.noreply.github.com> Co-authored-by: Twaticus <46540570+Twaticus@users.noreply.github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Bloop <13398309+vinylspiders@users.noreply.github.com> Co-authored-by: Cameron Lennox <killer65311@gmail.com> Co-authored-by: Tim <timothymtorres@gmail.com> Co-authored-by: Iamgoofball <iamgoofball@gmail.com> Co-authored-by: Layzu666 <121319428+Layzu666@users.noreply.github.com> Co-authored-by: Arturlang <24881678+Arturlang@users.noreply.github.com> Co-authored-by: _0Steven <42909981+00-Steven@users.noreply.github.com> Co-authored-by: mrmanlikesbt <99309552+mrmanlikesbt@users.noreply.github.com> Co-authored-by: Ben10Omintrix <138636438+Ben10Omintrix@users.noreply.github.com> Co-authored-by: John F. Kennedy <54908920+MacaroniCritter@users.noreply.github.com> Co-authored-by: Cursor <102828457+theselfish@users.noreply.github.com> Co-authored-by: Josh <josh.adam.powell@gmail.com> Co-authored-by: Josh Powell <josh.powell@softwire.com> Co-authored-by: Yobrocharlie <Charliemiller5617@gmail.com> Co-authored-by: Hardly3D <66234359+Hardly3D@users.noreply.github.com> Co-authored-by: shayoki <96078776+shayoki@users.noreply.github.com> Co-authored-by: LT3 <83487515+lessthnthree@users.noreply.github.com>
146 lines
3.9 KiB
Plaintext
146 lines
3.9 KiB
Plaintext
SUBSYSTEM_DEF(lighting)
|
|
name = "Lighting"
|
|
dependencies = list(
|
|
/datum/controller/subsystem/atoms,
|
|
/datum/controller/subsystem/mapping,
|
|
)
|
|
wait = 1
|
|
ss_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.
|
|
var/static/list/current_sources = list()
|
|
#ifdef VISUALIZE_LIGHT_UPDATES
|
|
var/allow_duped_values = FALSE
|
|
var/allow_duped_corners = FALSE
|
|
#endif
|
|
|
|
/datum/controller/subsystem/lighting/stat_entry(msg)
|
|
msg = "\n Sources:[length(sources_queue)]|Corners:[length(corners_queue)]|Objects:[length(objects_queue)]"
|
|
return ..()
|
|
|
|
|
|
/datum/controller/subsystem/lighting/Initialize()
|
|
if(!initialized)
|
|
create_all_lighting_objects()
|
|
initialized = TRUE
|
|
|
|
fire(FALSE, TRUE)
|
|
|
|
return SS_INIT_SUCCESS
|
|
|
|
|
|
/datum/controller/subsystem/lighting/proc/create_all_lighting_objects()
|
|
for(var/area/area as anything in GLOB.areas)
|
|
if(!area.static_lighting)
|
|
continue
|
|
for (var/list/zlevel_turfs as anything in area.get_zlevel_turf_lists())
|
|
for(var/turf/area_turf as anything in zlevel_turfs)
|
|
if(area_turf.space_lit)
|
|
continue
|
|
new /atom/movable/lighting_object(null, area_turf)
|
|
CHECK_TICK
|
|
CHECK_TICK
|
|
|
|
/datum/controller/subsystem/lighting/fire(resumed, init_tick_checks)
|
|
MC_SPLIT_TICK_INIT(3)
|
|
if(!init_tick_checks)
|
|
MC_SPLIT_TICK
|
|
|
|
if(!resumed)
|
|
current_sources = sources_queue
|
|
sources_queue = list()
|
|
|
|
// UPDATE SOURCE QUEUE
|
|
var/i = 0
|
|
// something something cache locally for sonic speed
|
|
var/list/queue = current_sources
|
|
while(i < length(queue)) //we don't use for loop here because i cannot be changed during an iteration
|
|
i += 1
|
|
|
|
var/datum/light_source/L = queue[i]
|
|
L.update_corners()
|
|
if(!QDELETED(L))
|
|
L.needs_update = LIGHTING_NO_UPDATE
|
|
else
|
|
i -= 1 // update_corners() has removed L from the list, move back so we don't overflow or skip the next element
|
|
|
|
// We unroll TICK_CHECK here so we can clear out the queue to ensure any removals/additions when sleeping don't fuck us
|
|
if(init_tick_checks)
|
|
if(!TICK_CHECK)
|
|
continue
|
|
queue.Cut(1, i + 1)
|
|
i = 0
|
|
stoplag()
|
|
else if(MC_TICK_CHECK)
|
|
break
|
|
if(i)
|
|
queue.Cut(1, i + 1)
|
|
i = 0
|
|
|
|
if(!init_tick_checks)
|
|
MC_SPLIT_TICK
|
|
|
|
// UPDATE CORNERS QUEUE
|
|
queue = corners_queue
|
|
while(i < length(queue)) //we don't use for loop here because i cannot be changed during an iteration
|
|
i += 1
|
|
|
|
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()
|
|
|
|
// We unroll TICK_CHECK here so we can clear out the queue to ensure any removals/additions when sleeping don't fuck us
|
|
if(init_tick_checks)
|
|
if(!TICK_CHECK)
|
|
continue
|
|
queue.Cut(1, i + 1)
|
|
i = 0
|
|
stoplag()
|
|
else if(MC_TICK_CHECK)
|
|
break
|
|
if(i)
|
|
queue.Cut(1, i+1)
|
|
i = 0
|
|
|
|
if(!init_tick_checks)
|
|
MC_SPLIT_TICK
|
|
|
|
// UPDATE OBJECTS QUEUE
|
|
queue = objects_queue
|
|
while(i < length(queue)) //we don't use for loop here because i cannot be changed during an iteration
|
|
i += 1
|
|
|
|
var/atom/movable/lighting_object/O = queue[i]
|
|
if(QDELETED(O))
|
|
continue
|
|
O.update()
|
|
O.needs_update = FALSE
|
|
|
|
// We unroll TICK_CHECK here so we can clear out the queue to ensure any removals/additions when sleeping don't fuck us
|
|
if(init_tick_checks)
|
|
if(!TICK_CHECK)
|
|
continue
|
|
queue.Cut(1, i + 1)
|
|
i = 0
|
|
stoplag()
|
|
else if(MC_TICK_CHECK)
|
|
break
|
|
if(i)
|
|
queue.Cut(1, i + 1)
|
|
|
|
|
|
/datum/controller/subsystem/lighting/Recover()
|
|
initialized = SSlighting.initialized
|
|
..()
|
|
|
|
/// Takes a list of turfs in, and sets up static lighting for them as needed.
|
|
/// Exactly what it says on the tin.
|
|
/datum/controller/subsystem/lighting/proc/setup_static_lighting_if_needed(list/turfs)
|
|
for(var/turf/unlit as anything in turfs)
|
|
if(unlit.space_lit)
|
|
continue
|
|
var/area/loc_area = unlit.loc
|
|
if(loc_area.static_lighting)
|
|
unlit.lighting_build_overlay()
|