mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-01-03 21:42:06 +00:00
Fix out of bounds in lighting subsystem (#75018)
## About The Pull Request Fixes #74697 Look at this for loopbfba2c5934/code/controllers/subsystem/lighting.dm (L34-L39)Now look at update cornersbfba2c5934/code/modules/lighting/lighting_source.dm (L428-L430)Now look at refresh values. this proc has a chance to delete itself herebfba2c5934/code/modules/lighting/lighting_source.dm (L315-L318)And herebfba2c5934/code/modules/lighting/lighting_source.dm (L331-L334)Now look at the Destroy proc, specifically focus on the needs_update conditionbfba2c5934/code/modules/lighting/lighting_source.dm (L66-L67)We are removing the light from the subsystem source queue while the subsystem is still iterating through them causing big problems for this for loopbfba2c5934/code/controllers/subsystem/lighting.dm (L33-L37)which causes the out of bounds exception because loop variable `i` is not updated accordingly when this list size is reduced mid iteration. The solution? we have to move the loop variable `i` back whenever the source is deleted i.e. removed from the list so we don't overflow ## Changelog 🆑 fix: out of bounds when updating lights in lighting subsystem /🆑 --------- Co-authored-by: LemonInTheDark <58055496+LemonInTheDark@users.noreply.github.com>
This commit is contained in:
@@ -434,28 +434,20 @@
|
||||
|
||||
var/list/datum/lighting_corner/new_corners = (corners - src.effect_str)
|
||||
LAZYINITLIST(src.effect_str)
|
||||
var/list/effect_str = src.effect_str
|
||||
if (needs_update == LIGHTING_VIS_UPDATE)
|
||||
for (var/datum/lighting_corner/corner as anything in new_corners)
|
||||
for (var/datum/lighting_corner/corner as anything in new_corners)
|
||||
APPLY_CORNER(corner)
|
||||
if (. != 0)
|
||||
LAZYADD(corner.affecting, src)
|
||||
effect_str[corner] = .
|
||||
// New corners are a subset of corners. so if they're both the same length, there are NO old corners!
|
||||
if(needs_update != LIGHTING_VIS_UPDATE && length(corners) != length(new_corners))
|
||||
for (var/datum/lighting_corner/corner as anything in corners - new_corners) // Existing corners
|
||||
APPLY_CORNER(corner)
|
||||
if (. != 0)
|
||||
LAZYADD(corner.affecting, src)
|
||||
effect_str[corner] = .
|
||||
else
|
||||
for (var/datum/lighting_corner/corner as anything in new_corners)
|
||||
APPLY_CORNER(corner)
|
||||
if (. != 0)
|
||||
LAZYADD(corner.affecting, src)
|
||||
effect_str[corner] = .
|
||||
// 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
|
||||
APPLY_CORNER(corner)
|
||||
if (. != 0)
|
||||
effect_str[corner] = .
|
||||
else
|
||||
LAZYREMOVE(corner.affecting, src)
|
||||
effect_str -= corner
|
||||
else
|
||||
LAZYREMOVE(corner.affecting, src)
|
||||
effect_str -= corner
|
||||
|
||||
var/list/datum/lighting_corner/gone_corners = effect_str - corners
|
||||
for (var/datum/lighting_corner/corner as anything in gone_corners)
|
||||
|
||||
Reference in New Issue
Block a user