Modclothes null user fix

Adds if to check if the clothes' user exists, to avoid null user errors
This commit is contained in:
Alphas00
2024-01-25 16:18:01 +01:00
parent 6dc302bb33
commit 585b6435c9
@@ -85,62 +85,63 @@
worn_overlays()
/obj/item/clothing/under/color/grey/modular/worn_overlays(isinhands = FALSE)
if(!isinhands) //make sure the clothes are being worn and aren't in someone's hands
. = list()
var/obj/item/organ/O
var/obj/item/organ/genital/G
for(O in U.internal_organs) //check the user for the organs they have
if(istype(O, /obj/item/organ/genital/belly)) //if that organ is a belly
G = O //treat that organ as a genital
if(!adjusted) //check the style, if it needs to be the adjusted variants
if(G.size <= 9) //check that the size is within accepted values, NOTE: these need to be removed later, better to cap organ sizes to begin with
. += mutable_appearance(icon_location, "belly_[G.size]", GENITALS_UNDER_LAYER) //add, from the clothes' icon file the overlay corresponding to that genital at that size and draw it onto the layer
else //if not an expected size value, bigger than the max, default to max size
. += mutable_appearance(icon_location, "belly_9", GENITALS_UNDER_LAYER)
else //use the alternative adjusted sprites
if(G.size <= 9)
. += mutable_appearance(icon_location, "belly_[G.size]_d", GENITALS_UNDER_LAYER)
else
. += mutable_appearance(icon_location, "belly_9_d", GENITALS_UNDER_LAYER)
if(istype(O, /obj/item/organ/genital/anus)) //if that organ is the butt
G = O
if(suit_style == DIGITIGRADE_SUIT_STYLE) //check if the suit needs to use sprites for digitigrade characters
if(G.size <= 10)
. += mutable_appearance(icon_location, "butt_[G.size]_l", GENITALS_FRONT_LAYER)
. += mutable_appearance(icon_location, "butt_[G.size]_l_NORTH", GENITALS_FRONT_LAYER) //to not adjust overlays every time a character turns, north-facing breasts and bellies are drawn separately, with individual icons
else //they'll have blank north-facing sprites in the main icon state and the north-facing will be blank on all other sides, and are drawn on different layers
. += mutable_appearance(icon_location, "butt_10_l", GENITALS_FRONT_LAYER)
. += mutable_appearance(icon_location, "butt_10_l_NORTH", GENITALS_FRONT_LAYER)
else //if the character is not digitigrade
if(G.size <= 10)
. += mutable_appearance(icon_location, "butt_[G.size]", GENITALS_FRONT_LAYER)
. += mutable_appearance(icon_location, "butt_[G.size]_NORTH", GENITALS_FRONT_LAYER)
else
. += mutable_appearance(icon_location, "butt_10", GENITALS_FRONT_LAYER)
. += mutable_appearance(icon_location, "butt_10_NORTH", GENITALS_FRONT_LAYER)
if(istype(O, /obj/item/organ/genital/breasts)) //if the organ is the breasts
G = O
if(G.size <= "o")
. += mutable_appearance(icon_location, "breasts_[G.size]", GENITALS_BEHIND_LAYER)
. += mutable_appearance(icon_location, "breasts_[G.size]_NORTH", BODY_FRONT_LAYER)
else
if(G.size == "huge")
. += mutable_appearance(icon_location, "breasts_huge", GENITALS_BEHIND_LAYER)
. += mutable_appearance(icon_location, "breasts_huge_NORTH", BODY_FRONT_LAYER)
else
if(G.size == "massive")
. += mutable_appearance(icon_location, "breasts_massive", GENITALS_BEHIND_LAYER)
. += mutable_appearance(icon_location, "breasts_massive_NORTH", BODY_FRONT_LAYER)
if(U)
if(!isinhands) //make sure the clothes are being worn and aren't in someone's hands
. = list()
var/obj/item/organ/O
var/obj/item/organ/genital/G
for(O in U.internal_organs) //check the user for the organs they have
if(istype(O, /obj/item/organ/genital/belly)) //if that organ is a belly
G = O //treat that organ as a genital
if(!adjusted) //check the style, if it needs to be the adjusted variants
if(G.size <= 9) //check that the size is within accepted values, NOTE: these need to be removed later, better to cap organ sizes to begin with
. += mutable_appearance(icon_location, "belly_[G.size]", GENITALS_UNDER_LAYER) //add, from the clothes' icon file the overlay corresponding to that genital at that size and draw it onto the layer
else //if not an expected size value, bigger than the max, default to max size
. += mutable_appearance(icon_location, "belly_9", GENITALS_UNDER_LAYER)
else //use the alternative adjusted sprites
if(G.size <= 9)
. += mutable_appearance(icon_location, "belly_[G.size]_d", GENITALS_UNDER_LAYER)
else
if(G.size == "giga")
. += mutable_appearance(icon_location, "breasts_giga", GENITALS_BEHIND_LAYER)
. += mutable_appearance(icon_location, "breasts_giga_NORTH", BODY_FRONT_LAYER)
. += mutable_appearance(icon_location, "belly_9_d", GENITALS_UNDER_LAYER)
if(istype(O, /obj/item/organ/genital/anus)) //if that organ is the butt
G = O
if(suit_style == DIGITIGRADE_SUIT_STYLE) //check if the suit needs to use sprites for digitigrade characters
if(G.size <= 10)
. += mutable_appearance(icon_location, "butt_[G.size]_l", GENITALS_FRONT_LAYER)
. += mutable_appearance(icon_location, "butt_[G.size]_l_NORTH", GENITALS_FRONT_LAYER) //to not adjust overlays every time a character turns, north-facing breasts and bellies are drawn separately, with individual icons
else //they'll have blank north-facing sprites in the main icon state and the north-facing will be blank on all other sides, and are drawn on different layers
. += mutable_appearance(icon_location, "butt_10_l", GENITALS_FRONT_LAYER)
. += mutable_appearance(icon_location, "butt_10_l_NORTH", GENITALS_FRONT_LAYER)
else //if the character is not digitigrade
if(G.size <= 10)
. += mutable_appearance(icon_location, "butt_[G.size]", GENITALS_FRONT_LAYER)
. += mutable_appearance(icon_location, "butt_[G.size]_NORTH", GENITALS_FRONT_LAYER)
else
. += mutable_appearance(icon_location, "butt_10", GENITALS_FRONT_LAYER)
. += mutable_appearance(icon_location, "butt_10_NORTH", GENITALS_FRONT_LAYER)
if(istype(O, /obj/item/organ/genital/breasts)) //if the organ is the breasts
G = O
if(G.size <= "o")
. += mutable_appearance(icon_location, "breasts_[G.size]", GENITALS_BEHIND_LAYER)
. += mutable_appearance(icon_location, "breasts_[G.size]_NORTH", BODY_FRONT_LAYER)
else
if(G.size == "huge")
. += mutable_appearance(icon_location, "breasts_huge", GENITALS_BEHIND_LAYER)
. += mutable_appearance(icon_location, "breasts_huge_NORTH", BODY_FRONT_LAYER)
else
if(G.size == "massive")
. += mutable_appearance(icon_location, "breasts_massive", GENITALS_BEHIND_LAYER)
. += mutable_appearance(icon_location, "breasts_massive_NORTH", BODY_FRONT_LAYER)
else
. += mutable_appearance(icon_location, "breasts_impossible", GENITALS_BEHIND_LAYER)
. += mutable_appearance(icon_location, "breasts_impossible_NORTH", BODY_FRONT_LAYER)
if(damaged_clothes)
. += mutable_appearance('icons/effects/item_damage.dmi', "damageduniform")
if(blood_DNA)
. += mutable_appearance('icons/effects/blood.dmi', "uniformblood", color = blood_DNA_to_color())
if(accessory_overlay)
. += accessory_overlay
if(G.size == "giga")
. += mutable_appearance(icon_location, "breasts_giga", GENITALS_BEHIND_LAYER)
. += mutable_appearance(icon_location, "breasts_giga_NORTH", BODY_FRONT_LAYER)
else
. += mutable_appearance(icon_location, "breasts_impossible", GENITALS_BEHIND_LAYER)
. += mutable_appearance(icon_location, "breasts_impossible_NORTH", BODY_FRONT_LAYER)
if(damaged_clothes)
. += mutable_appearance('icons/effects/item_damage.dmi', "damageduniform")
if(blood_DNA)
. += mutable_appearance('icons/effects/blood.dmi', "uniformblood", color = blood_DNA_to_color())
if(accessory_overlay)
. += accessory_overlay