Skip to content

Commit

Permalink
Add null value checks to lighting code (#4435)
Browse files Browse the repository at this point in the history
  • Loading branch information
Absolucy authored Dec 2, 2024
1 parent 62d0f0e commit e2cbed5
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
4 changes: 2 additions & 2 deletions code/modules/lighting/lighting_corner.dm
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,11 @@

/datum/lighting_corner/proc/vis_update()
for (var/datum/light_source/light_source as anything in affecting)
light_source.vis_update()
light_source?.vis_update()

/datum/lighting_corner/proc/full_update()
for (var/datum/light_source/light_source as anything in affecting)
light_source.recalc_corner(src)
light_source?.recalc_corner(src)

// God that was a mess, now to do the rest of the corner code! Hooray!
/datum/lighting_corner/proc/update_lumcount(delta_r, delta_g, delta_b)
Expand Down
10 changes: 10 additions & 0 deletions code/modules/lighting/lighting_source.dm
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,8 @@
applied = FALSE
var/list/turfs_to_mark = list()
for (var/datum/lighting_corner/corner as anything in effect_str)
if(isnull(corner))
continue
REMOVE_CORNER(corner)
LAZYREMOVE(corner.affecting, src)

Expand Down Expand Up @@ -404,12 +406,16 @@

if (needs_update == LIGHTING_VIS_UPDATE)
for (var/datum/lighting_corner/corner as anything in new_corners)
if(isnull(corner))
continue
APPLY_CORNER(corner)
if (. != 0)
LAZYADD(corner.affecting, src)
effect_str[corner] = .
else
for (var/datum/lighting_corner/corner as anything in new_corners)
if(isnull(corner))
continue
APPLY_CORNER(corner)
if (. != 0)
LAZYADD(corner.affecting, src)
Expand All @@ -418,6 +424,8 @@
// New corners are a subset of corners. so if they're both the same length, there are NO old corners!
if(length(corners) != length(new_corners))
for (var/datum/lighting_corner/corner as anything in corners - new_corners) // Existing corners
if(isnull(corner))
continue
APPLY_CORNER(corner)
if (. != 0)
effect_str[corner] = .
Expand All @@ -428,6 +436,8 @@

var/list/datum/lighting_corner/gone_corners = effect_str - corners
for (var/datum/lighting_corner/corner as anything in gone_corners)
if(isnull(corner))
continue
REMOVE_CORNER(corner)
LAZYREMOVE(corner.affecting, src)
effect_str -= gone_corners
Expand Down

0 comments on commit e2cbed5

Please sign in to comment.