diff --git a/code/modules/clothing/_clothing.dm b/code/modules/clothing/_clothing.dm index 3df45d8577b..09032cb840b 100644 --- a/code/modules/clothing/_clothing.dm +++ b/code/modules/clothing/_clothing.dm @@ -386,10 +386,3 @@ . = ..() LAZYADD(., /decl/interaction_handler/clothing_set_sensors) -// This stub is so the linter stops yelling about sleeping during Initialize() -// due to corpse props equipping themselves, which calls equip_to_slot, which -// calls attackby(), which sometimes sleeps due to input(). Yeah. -// Remove this if a better fix presents itself. -/obj/item/clothing/proc/try_attach_accessory(var/obj/item/accessory, var/mob/user) - set waitfor = FALSE - attackby(accessory, user) diff --git a/code/modules/clothing/_clothing_accessories.dm b/code/modules/clothing/_clothing_accessories.dm index 0152b67c97f..f7a1c9d7b76 100644 --- a/code/modules/clothing/_clothing_accessories.dm +++ b/code/modules/clothing/_clothing_accessories.dm @@ -10,15 +10,19 @@ /obj/item/clothing/proc/get_initial_accessory_hide_on_states() return null -/obj/item/clothing/proc/can_attach_accessory(obj/item/clothing/accessory) - if(valid_accessory_slots && istype(accessory) && !isnull(accessory.accessory_slot) && (accessory.accessory_slot in valid_accessory_slots)) - . = 1 - else - return 0 +/obj/item/clothing/proc/can_attach_accessory(obj/item/clothing/accessory, mob/user) + if(!length(valid_accessory_slots)) + to_chat(user, SPAN_WARNING("You cannot attach accessories of any kind to \the [src].")) + return FALSE + if(!istype(accessory) || isnull(accessory.accessory_slot) || !(accessory.accessory_slot in valid_accessory_slots)) + to_chat(user, SPAN_WARNING("You cannot attach accessories of this kind to \the [src].")) + return FALSE if(LAZYLEN(accessories) && restricted_accessory_slots && (accessory.accessory_slot in restricted_accessory_slots)) for(var/obj/item/clothing/other_accessory in accessories) if (other_accessory.accessory_slot == accessory.accessory_slot) - return 0 + to_chat(user, SPAN_WARNING("You cannot attach more accessories of this kind to \the [src].")) + return FALSE + return TRUE // Override for action buttons. /obj/item/clothing/attack_self(mob/user) @@ -43,20 +47,16 @@ return ..() /obj/item/clothing/attackby(var/obj/item/I, var/mob/user) + if(istype(I, /obj/item/clothing)) var/obj/item/clothing/accessory = I if(!isnull(accessory.accessory_slot)) - - if(!valid_accessory_slots || !valid_accessory_slots.len) - to_chat(usr, SPAN_WARNING("You cannot attach accessories of any kind to \the [src].")) - return TRUE - - if(can_attach_accessory(accessory)) + if(can_attach_accessory(accessory, user)) if(user.try_unequip(accessory)) attach_accessory(user, accessory) else - to_chat(user, SPAN_WARNING("You cannot attach more accessories of this type to [src].")) + to_chat(user, SPAN_WARNING("You cannot attach \the [I] to \the [src].")) return TRUE if(length(accessories)) diff --git a/code/modules/mob/inventory.dm b/code/modules/mob/inventory.dm index 14f6ea380d1..87b2e3e4aa0 100644 --- a/code/modules/mob/inventory.dm +++ b/code/modules/mob/inventory.dm @@ -47,12 +47,24 @@ return TRUE if(slot == slot_tie_str) - var/try_equip_slot = W.get_fallback_slot() - if(!try_equip_slot || try_equip_slot == slot_tie_str) - try_equip_slot = slot_w_uniform_str - var/obj/item/clothing/uniform = get_equipped_item(try_equip_slot) - if(istype(uniform)) - uniform.try_attach_accessory(W, src) + + var/list/check_slots = get_inventory_slots() + if(islist(check_slots)) + + check_slots = check_slots.Copy() + check_slots -= global.all_hand_slots + + var/try_equip_slot = W.get_fallback_slot() + if(try_equip_slot) + check_slots -= try_equip_slot + check_slots.Insert(1, try_equip_slot) + + for(var/slot_string in check_slots) + var/obj/item/clothing/clothes = get_equipped_item(slot_string) + if(istype(clothes) && clothes.can_attach_accessory(W, src)) + clothes.attach_accessory(src, W) + break + return TRUE unequip(W) diff --git a/code/modules/mob/stripping.dm b/code/modules/mob/stripping.dm index 15c1332ebf0..c8b92e21b7f 100644 --- a/code/modules/mob/stripping.dm +++ b/code/modules/mob/stripping.dm @@ -106,7 +106,7 @@ admin_attack_log(user, src, "Attempted to strip \a [target_slot]", "Target of a failed strip of \a [target_slot].", "attempted to strip \a [target_slot] from") else if(user.try_unequip(held)) var/obj/item/clothing/C = get_equipped_item(slot_to_strip_text) - if(istype(C) && C.can_attach_accessory(held)) + if(istype(C) && C.can_attach_accessory(held, user)) C.attach_accessory(user, held) else if(!equip_to_slot_if_possible(held, slot_to_strip_text, del_on_fail=0, disable_warning=1, redraw_mob=1)) user.put_in_active_hand(held)