From 2d4b83f6d492c46d4ae64dc68c14d5d97d0cd4af Mon Sep 17 00:00:00 2001
From: SkyratBot <59378654+SkyratBot@users.noreply.github.com>
Date: Sat, 24 Apr 2021 01:22:56 +0200
Subject: [PATCH] [MIRROR] Dummies equipping outfits no longer call equipped
(#5140)
* Dummies equipping outfits no longer call equipped (#58597)
* Dummies equipping outfits no longer call equipped
Co-authored-by: Trigg <36010999+TriggeredBoi@users.noreply.github.com>
---
code/game/objects/items.dm | 11 +++++++++++
code/modules/clothing/glasses/_glasses.dm | 2 +-
code/modules/clothing/head/helmet.dm | 2 --
code/modules/clothing/head/misc_special.dm | 4 ++--
code/modules/clothing/shoes/_shoes.dm | 7 +++++--
code/modules/clothing/suits/reactive_armour.dm | 4 ++--
code/modules/clothing/under/_under.dm | 12 +++++++-----
code/modules/mob/living/carbon/human/dummy.dm | 3 +++
code/modules/mob/living/carbon/human/inventory.dm | 2 +-
code/modules/mob/living/carbon/inventory.dm | 6 +++++-
code/modules/zombie/items.dm | 2 +-
11 files changed, 38 insertions(+), 17 deletions(-)
diff --git a/code/game/objects/items.dm b/code/game/objects/items.dm
index 9d71a46243d..3f6fca7a48c 100644
--- a/code/game/objects/items.dm
+++ b/code/game/objects/items.dm
@@ -488,6 +488,16 @@ GLOBAL_VAR_INIT(embedpocalypse, FALSE) // if true, all items will be able to emb
/obj/item/proc/on_found(mob/finder)
return
+/**
+ * To be overwritten to only perform visual tasks;
+ * this is directly called instead of `equipped` on visual-only features like human dummies equipping outfits.
+ *
+ * This separation exists to prevent things like the monkey sentience helmet from
+ * polling ghosts while it's just being equipped as a visual preview for a dummy.
+ */
+/obj/item/proc/visual_equipped(mob/user, slot, initial = FALSE)
+ return
+
/**
* Called after an item is placed in an equipment slot.
*
@@ -500,6 +510,7 @@ GLOBAL_VAR_INIT(embedpocalypse, FALSE) // if true, all items will be able to emb
*/
/obj/item/proc/equipped(mob/user, slot, initial = FALSE)
SHOULD_CALL_PARENT(TRUE)
+ visual_equipped(user, slot, initial)
SEND_SIGNAL(src, COMSIG_ITEM_EQUIPPED, user, slot)
for(var/X in actions)
var/datum/action/A = X
diff --git a/code/modules/clothing/glasses/_glasses.dm b/code/modules/clothing/glasses/_glasses.dm
index 1fbad928195..c913574d046 100644
--- a/code/modules/clothing/glasses/_glasses.dm
+++ b/code/modules/clothing/glasses/_glasses.dm
@@ -339,7 +339,7 @@
inhand_icon_state = "blindfoldwhite"
var/colored_before = FALSE
-/obj/item/clothing/glasses/blindfold/white/equipped(mob/living/carbon/human/user, slot)
+/obj/item/clothing/glasses/blindfold/white/visual_equipped(mob/living/carbon/human/user, slot)
if(ishuman(user) && slot == ITEM_SLOT_EYES)
update_icon(ALL, user)
user.update_inv_glasses() //Color might have been changed by update_icon.
diff --git a/code/modules/clothing/head/helmet.dm b/code/modules/clothing/head/helmet.dm
index ba7ac93ec03..c96a23bae85 100644
--- a/code/modules/clothing/head/helmet.dm
+++ b/code/modules/clothing/head/helmet.dm
@@ -420,8 +420,6 @@
. = ..()
if(slot != ITEM_SLOT_HEAD)
return
- if(istype(user, /mob/living/carbon/human/dummy)) //Prevents ghosts from being polled when the helmet is put on a dummy.
- return
if(!ismonkey(user) || user.ckey)
var/mob/living/something = user
to_chat(something, "You feel a stabbing pain in the back of your head for a moment.")
diff --git a/code/modules/clothing/head/misc_special.dm b/code/modules/clothing/head/misc_special.dm
index 99875fb4823..c62bd41ec1a 100644
--- a/code/modules/clothing/head/misc_special.dm
+++ b/code/modules/clothing/head/misc_special.dm
@@ -165,7 +165,7 @@
dog_fashion = /datum/dog_fashion/head/kitty
-/obj/item/clothing/head/kitty/equipped(mob/living/carbon/human/user, slot)
+/obj/item/clothing/head/kitty/visual_equipped(mob/living/carbon/human/user, slot)
if(ishuman(user) && slot == ITEM_SLOT_HEAD)
update_icon(ALL, user)
user.update_inv_head() //Color might have been changed by update_appearance.
@@ -294,7 +294,7 @@
hairstyle = pick(GLOB.hairstyles_list - "Bald")
. = ..()
-/obj/item/clothing/head/wig/natural/equipped(mob/living/carbon/human/user, slot)
+/obj/item/clothing/head/wig/natural/visual_equipped(mob/living/carbon/human/user, slot)
. = ..()
if(ishuman(user) && slot == ITEM_SLOT_HEAD)
if (color != "#[user.hair_color]") // only update if necessary
diff --git a/code/modules/clothing/shoes/_shoes.dm b/code/modules/clothing/shoes/_shoes.dm
index c6cedc4fb65..25646751bd6 100644
--- a/code/modules/clothing/shoes/_shoes.dm
+++ b/code/modules/clothing/shoes/_shoes.dm
@@ -63,13 +63,16 @@
else if(tied == SHOES_KNOTTED)
. += "The shoelaces are all knotted together."
-/obj/item/clothing/shoes/equipped(mob/user, slot)
- . = ..()
+/obj/item/clothing/shoes/visual_equipped(mob/user, slot)
+ ..()
if(offset && (slot_flags & slot))
user.pixel_y += offset
worn_y_dimension -= (offset * 2)
user.update_inv_shoes()
equipped_before_drop = TRUE
+
+/obj/item/clothing/shoes/equipped(mob/user, slot)
+ . = ..()
if(can_be_tied && tied == SHOES_UNTIED)
our_alert = user.throw_alert("shoealert", /atom/movable/screen/alert/shoes/untied)
RegisterSignal(src, COMSIG_SHOES_STEP_ACTION, .proc/check_trip, override=TRUE)
diff --git a/code/modules/clothing/suits/reactive_armour.dm b/code/modules/clothing/suits/reactive_armour.dm
index 835349add6a..acbee266407 100644
--- a/code/modules/clothing/suits/reactive_armour.dm
+++ b/code/modules/clothing/suits/reactive_armour.dm
@@ -225,12 +225,12 @@
/obj/item/clothing/suit/armor/reactive/tesla/dropped(mob/user)
..()
if(istype(user))
- ADD_TRAIT(user, TRAIT_TESLA_SHOCKIMMUNE, "reactive_tesla_armor")
+ REMOVE_TRAIT(user, TRAIT_TESLA_SHOCKIMMUNE, "reactive_tesla_armor")
/obj/item/clothing/suit/armor/reactive/tesla/equipped(mob/user, slot)
..()
if(slot_flags & slot) //Was equipped to a valid slot for this item?
- REMOVE_TRAIT(user, TRAIT_TESLA_SHOCKIMMUNE, "reactive_tesla_armor")
+ ADD_TRAIT(user, TRAIT_TESLA_SHOCKIMMUNE, "reactive_tesla_armor")
/obj/item/clothing/suit/armor/reactive/tesla/cooldown_activation(mob/living/carbon/human/owner)
var/datum/effect_system/spark_spread/sparks = new /datum/effect_system/spark_spread
diff --git a/code/modules/clothing/under/_under.dm b/code/modules/clothing/under/_under.dm
index 7eed9eae8e3..86d41e69a35 100644
--- a/code/modules/clothing/under/_under.dm
+++ b/code/modules/clothing/under/_under.dm
@@ -70,7 +70,7 @@
var/mob/M = loc
to_chat(M,"The sensors on the [src] change rapidly!")
-/obj/item/clothing/under/equipped(mob/user, slot)
+/obj/item/clothing/under/visual_equipped(mob/user, slot)
..()
if(adjusted)
adjusted = NORMAL_STYLE
@@ -84,10 +84,6 @@
adjusted = DIGITIGRADE_STYLE
H.update_inv_w_uniform()
- if(slot == ITEM_SLOT_ICLOTHING && freshly_laundered)
- freshly_laundered = FALSE
- SEND_SIGNAL(user, COMSIG_ADD_MOOD_EVENT, "fresh_laundry", /datum/mood_event/fresh_laundry)
-
if(attached_accessory && slot != ITEM_SLOT_HANDS && ishuman(user))
var/mob/living/carbon/human/H = user
attached_accessory.on_uniform_equip(src, user)
@@ -95,6 +91,12 @@
if(attached_accessory.above_suit)
H.update_inv_wear_suit()
+/obj/item/clothing/under/equipped(mob/user, slot)
+ ..()
+ if(slot == ITEM_SLOT_ICLOTHING && freshly_laundered)
+ freshly_laundered = FALSE
+ SEND_SIGNAL(user, COMSIG_ADD_MOOD_EVENT, "fresh_laundry", /datum/mood_event/fresh_laundry)
+
/obj/item/clothing/under/dropped(mob/user)
if(attached_accessory)
attached_accessory.on_uniform_dropped(src, user)
diff --git a/code/modules/mob/living/carbon/human/dummy.dm b/code/modules/mob/living/carbon/human/dummy.dm
index c668624a897..f11d0d76436 100644
--- a/code/modules/mob/living/carbon/human/dummy.dm
+++ b/code/modules/mob/living/carbon/human/dummy.dm
@@ -17,6 +17,9 @@ INITIALIZE_IMMEDIATE(/mob/living/carbon/human/dummy)
/mob/living/carbon/human/dummy/attach_rot(mapload)
return
+/mob/living/carbon/human/dummy/has_equipped(obj/item/item, slot, initial = FALSE)
+ return item.visual_equipped(src, slot, initial)
+
/mob/living/carbon/human/dummy/proc/wipe_state()
delete_equipment()
cut_overlays(TRUE)
diff --git a/code/modules/mob/living/carbon/human/inventory.dm b/code/modules/mob/living/carbon/human/inventory.dm
index 5e0b0b1c16e..394dd5f2813 100644
--- a/code/modules/mob/living/carbon/human/inventory.dm
+++ b/code/modules/mob/living/carbon/human/inventory.dm
@@ -160,7 +160,7 @@
//Item is handled and in slot, valid to call callback, for this proc should always be true
if(!not_handled)
- I.equipped(src, slot, initial)
+ has_equipped(I, slot, initial)
// Send a signal for when we equip an item that used to cover our feet/shoes. Used for bloody feet
if((I.body_parts_covered & FEET) || (I.flags_inv | I.transparent_protection) & HIDESHOES)
diff --git a/code/modules/mob/living/carbon/inventory.dm b/code/modules/mob/living/carbon/inventory.dm
index 3434737f091..06df7f8d10f 100644
--- a/code/modules/mob/living/carbon/inventory.dm
+++ b/code/modules/mob/living/carbon/inventory.dm
@@ -90,10 +90,14 @@
//We cannot call it for items that have not been handled as they are not yet correctly
//in a slot (handled further down inheritance chain, probably living/carbon/human/equip_to_slot
if(!not_handled)
- I.equipped(src, slot)
+ has_equipped(I, slot, initial)
return not_handled
+/// This proc is called after an item has been successfully handled and equipped to a slot.
+/mob/living/carbon/proc/has_equipped(obj/item/item, slot, initial = FALSE)
+ return item.equipped(src, slot, initial)
+
/mob/living/carbon/doUnEquip(obj/item/I, force, newloc, no_move, invdrop = TRUE, silent = FALSE)
. = ..() //Sets the default return value to what the parent returns.
if(!. || !I) //We don't want to set anything to null if the parent returned 0.
diff --git a/code/modules/zombie/items.dm b/code/modules/zombie/items.dm
index c5172f025fb..cf9dbeece47 100644
--- a/code/modules/zombie/items.dm
+++ b/code/modules/zombie/items.dm
@@ -21,7 +21,7 @@
. = ..()
ADD_TRAIT(src, TRAIT_NODROP, HAND_REPLACEMENT_TRAIT)
-/obj/item/zombie_hand/equipped(mob/user, slot)
+/obj/item/zombie_hand/visual_equipped(mob/user, slot)
. = ..()
//these are intentionally inverted
var/i = user.get_held_index_of_item(src)