Skip to content

Fix lights sometimes not properly updating when turned on/off #6048

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 27, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion code/modules/lighting/lighting_atom.dm
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
else
. = loc

if (light) // Update the light or create it if it does not exist.
if (!QDELETED(light)) // Update the light or create it if it does not exist.
light.update(.)
else
light = new/datum/light_source(src, .)
Expand Down
12 changes: 8 additions & 4 deletions code/modules/power/lighting/light.dm
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,7 @@
if(LIGHT_BROKEN,LIGHT_BURNED,LIGHT_EMPTY)
on = FALSE
low_power_mode = FALSE
var/should_update_light = !isnull(set_light_on(on))
if(on)
var/IR = bulb_inner_range
var/brightness_set = bulb_outer_range
Expand All @@ -228,7 +229,7 @@
else if (major_emergency)
color_set = bulb_low_power_colour
brightness_set = bulb_outer_range * bulb_major_emergency_brightness_mul
var/matching = light && brightness_set == light.light_outer_range && power_set == light.light_power && color_set == light.light_color && FC == light.light_falloff_curve && IR == light.light_inner_range
var/matching = !QDELETED(light) && brightness_set == light.light_outer_range && power_set == light.light_power && color_set == light.light_color && FC == light.light_falloff_curve && IR == light.light_inner_range
if(!matching)
var/should_set = TRUE
if(!dont_burn_out)
Expand All @@ -238,20 +239,23 @@
should_set = FALSE
if(should_set)
use_power = ACTIVE_POWER_USE
should_update_light = TRUE
set_light(
l_outer_range = brightness_set,
l_inner_range = IR,
l_power = power_set,
l_falloff_curve = FC,
l_color = color_set
l_color = color_set,
update = FALSE
)
else if(has_emergency_power(LIGHT_EMERGENCY_POWER_USE) && !turned_off())
use_power = IDLE_POWER_USE
low_power_mode = TRUE
START_PROCESSING(SSmachines, src)
else
use_power = IDLE_POWER_USE
set_light(0)
if(should_update_light)
update_light()
update_appearance()
update_current_power_usage()
broken_sparks(start_only=TRUE)
Expand Down Expand Up @@ -306,7 +310,7 @@
status = LIGHT_BURNED
icon_state = "[base_state]-burned"
on = FALSE
set_light(l_outer_range = 0)
set_light(l_outer_range = 0, l_on = FALSE)

// attempt to set the light's on/off status
// will not switch on if broken/burned/empty
Expand Down
Loading