From 60de8a5db8fac51e5bb4f4981d142c68d528032d Mon Sep 17 00:00:00 2001 From: Lucy Date: Sun, 29 Mar 2026 12:23:23 -0400 Subject: [PATCH] Add null checks to `strip_appearance_underlays` and `copy_appearance_filter_overlays` (#95474) ## About The Pull Request This adds null checks to `strip_appearance_underlays` and `copy_appearance_filter_overlays`, because I have seen many runtimes on live from null overlays/underlays existing - and the runtimes mean that the procs will return null, potentially resulting in a strange blank icon for whatever's using it. Also added return type hints to those two procs, 'cuz why not. ## Why It's Good For The Game I'd rather have these procs consistently work. ## Changelog No user-facing changes, prolly. Might fix bugs, idk which in specific. --- code/__HELPERS/icons.dm | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/code/__HELPERS/icons.dm b/code/__HELPERS/icons.dm index 2f2f4f2d238..11b20cfb210 100644 --- a/code/__HELPERS/icons.dm +++ b/code/__HELPERS/icons.dm @@ -1335,9 +1335,11 @@ GLOBAL_LIST_EMPTY(transformation_animation_objects) /// Strips all underlays on a different plane from an appearance. /// Returns the stripped appearance. -/proc/strip_appearance_underlays(mutable_appearance/appearance) +/proc/strip_appearance_underlays(mutable_appearance/appearance) as /mutable_appearance var/base_plane = PLANE_TO_TRUE(appearance.plane) for(var/mutable_appearance/underlay as anything in appearance.underlays) + if(isnull(underlay)) + continue if(PLANE_TO_TRUE(underlay.plane) != base_plane) appearance.underlays -= underlay return appearance @@ -1348,13 +1350,15 @@ GLOBAL_LIST_EMPTY(transformation_animation_objects) * Filters out certain overlays from the copy, depending on their planes * Prevents stuff like lighting from being copied to the new appearance */ -/proc/copy_appearance_filter_overlays(appearance_to_copy) +/proc/copy_appearance_filter_overlays(appearance_to_copy) as /mutable_appearance var/mutable_appearance/copy = new(appearance_to_copy) var/static/list/plane_whitelist = list(FLOAT_PLANE, GAME_PLANE, FLOOR_PLANE) /// Ideally we'd have knowledge what we're removing but i'd have to be done on target appearance retrieval var/list/overlays_to_keep = list() for(var/mutable_appearance/special_overlay as anything in copy.overlays) + if(isnull(special_overlay)) + continue var/mutable_appearance/real = new() real.appearance = special_overlay if(PLANE_TO_TRUE(real.plane) in plane_whitelist) @@ -1363,6 +1367,8 @@ GLOBAL_LIST_EMPTY(transformation_animation_objects) var/list/underlays_to_keep = list() for(var/mutable_appearance/special_underlay as anything in copy.underlays) + if(isnull(special_underlay)) + continue var/mutable_appearance/real = new() real.appearance = special_underlay if(PLANE_TO_TRUE(real.plane) in plane_whitelist)