From b4a83f650cf6f109f9c0fe61cdec6d3dc3649664 Mon Sep 17 00:00:00 2001 From: Farie82 Date: Fri, 29 Apr 2022 14:08:13 +0200 Subject: [PATCH] Fixes the captains medal being deleted when cryoing (#17667) --- .../traitor/contractor/datums/syndicate_contract.dm | 3 +-- code/modules/clothing/clothing.dm | 11 ++++++++--- code/modules/clothing/under/accessories/accessory.dm | 8 ++++++-- code/modules/mob/living/carbon/human/human.dm | 4 +--- 4 files changed, 16 insertions(+), 10 deletions(-) diff --git a/code/modules/antagonists/traitor/contractor/datums/syndicate_contract.dm b/code/modules/antagonists/traitor/contractor/datums/syndicate_contract.dm index 914f65010ba..fbaa66a88b5 100644 --- a/code/modules/antagonists/traitor/contractor/datums/syndicate_contract.dm +++ b/code/modules/antagonists/traitor/contractor/datums/syndicate_contract.dm @@ -412,8 +412,7 @@ // Remove accessories from the suit if present if(length(H.w_uniform?.accessories)) for(var/obj/item/clothing/accessory/A in H.w_uniform.accessories) - A.on_removed(H) - H.w_uniform.accessories -= A + H.w_uniform.detach_accessory(A, null) H.unEquip(A) stuff_to_transfer += A diff --git a/code/modules/clothing/clothing.dm b/code/modules/clothing/clothing.dm index d9d29aeca93..2c375099b78 100644 --- a/code/modules/clothing/clothing.dm +++ b/code/modules/clothing/clothing.dm @@ -737,6 +737,13 @@ BLIND // can't see anything return FALSE +/obj/item/clothing/under/proc/detach_accessory(obj/item/clothing/accessory/A, mob/user) + accessories -= A + A.on_removed(user) + if(ishuman(loc)) + var/mob/living/carbon/human/H = loc + H.update_inv_w_uniform() + /obj/item/clothing/under/examine(mob/user) . = ..() switch(sensor_mode) @@ -802,10 +809,8 @@ BLIND // can't see anything return if(!Adjacent(user)) return - A.on_removed(user) - accessories -= A + detach_accessory(A, user) to_chat(user, "You remove [A] from [src].") - usr.update_inv_w_uniform() /obj/item/clothing/under/emp_act(severity) if(accessories.len) diff --git a/code/modules/clothing/under/accessories/accessory.dm b/code/modules/clothing/under/accessories/accessory.dm index a46727168a6..0e4a4b110d0 100644 --- a/code/modules/clothing/under/accessories/accessory.dm +++ b/code/modules/clothing/under/accessories/accessory.dm @@ -16,10 +16,14 @@ ..() inv_overlay = image("icon" = 'icons/obj/clothing/ties_overlay.dmi', "icon_state" = "[item_color? "[item_color]" : "[icon_state]"]") +/obj/item/clothing/accessory/Moved(atom/OldLoc, Dir, Forced) + . = ..() + if(has_suit) + has_suit.detach_accessory(src, null) + /obj/item/clothing/accessory/Destroy() if(has_suit) - has_suit.accessories -= src - on_removed(null) + has_suit.detach_accessory(src, null) return ..() //when user attached an accessory to S diff --git a/code/modules/mob/living/carbon/human/human.dm b/code/modules/mob/living/carbon/human/human.dm index 5ddd2c3100a..6d03b1b2592 100644 --- a/code/modules/mob/living/carbon/human/human.dm +++ b/code/modules/mob/living/carbon/human/human.dm @@ -702,9 +702,7 @@ if(!thief_mode) usr.visible_message("\The [usr] takes \the [A] off of \the [src]'s [U]!", \ "You take \the [A] off of \the [src]'s [U]!") - A.on_removed(usr) - U.accessories -= A - update_inv_w_uniform() + U.detach_accessory(A, usr) if(href_list["criminal"]) if(hasHUD(usr, EXAMINE_HUD_SECURITY_WRITE))