Clothing fallback (#18258)

* Clothing fallback

Makes clothing have a fallback in the event of a custom species file not having the appropriate icon state.

* some logging

* testing

* swap all unit tests to use icon_exists

* Update poster_tests.dm

* Update clothing_tests.dm

* Update cosmetic_tests.dm

* Update robot_tests.dm

* whoop

* upgrades people, upgrades

* port these

* Update _atom.dm

* adjust all these

* Update clothing.dm

* TRUEFALSE
This commit is contained in:
Cameron Lennox
2025-08-19 20:42:42 -04:00
committed by GitHub
parent e5f9c80628
commit 9856c64443
20 changed files with 119 additions and 74 deletions
+5 -1
View File
@@ -946,13 +946,17 @@ modules/mob/living/carbon/human/life.dm if you die, you will be zoomed out.
//2: species-specific sprite sheets (skipped for inhands)
if(LAZYLEN(sprite_sheets) && !inhands)
var/sheet = sprite_sheets[body_type]
if(sheet)
if(sheet && icon_exists(sheet, icon_state)) //Checks to make sure our custom sheet actually HAS the icon_state
return sheet
//3: slot-specific sprite sheets
if(LAZYLEN(item_icons))
var/sheet = item_icons[slot_name]
if(sheet)
/* //Alerts that we are equipping an item that has no item_state for the slot-specific icon sheet. Commented out because it's not really too important.
if(!icon_exists(sheet, icon_state))
log_debug("Item [src] is equippable on the [slot_name] but has no sprite for it!")
*/
return sheet
//4: item's default icon
@@ -71,7 +71,7 @@
cut_overlays()
if(front_id)
var/tiny_state = "id-generic"
if("id-[front_id.icon_state]" in cached_icon_states(icon))
if(icon_exists(icon, "id-[front_id.icon_state]"))
tiny_state = "id-"+front_id.icon_state
var/image/tiny_image = new/image(icon, icon_state = tiny_state)
tiny_image.appearance_flags = RESET_COLOR
+1 -1
View File
@@ -129,7 +129,7 @@ two tiles on initialization, and which way a cliff is facing may change during m
var/subtraction_icon_state = "[icon_state]-subtract"
var/cache_string = "[icon_state]_[T.icon]_[T.icon_state]"
if(T && (subtraction_icon_state in cached_icon_states(icon)))
if(T && icon_exists(icon, subtraction_icon_state))
cut_overlays()
// If we've made the same icon before, just recycle it.
if(cache_string in GLOB.cliff_icon_cache)