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.
This commit is contained in:
Lucy
2026-03-29 18:23:23 +02:00
committed by GitHub
parent 49f7198c91
commit 60de8a5db8
+8 -2
View File
@@ -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)