From a65b4d0b1c1f6b720fd94accc9c616dc2b5579bf Mon Sep 17 00:00:00 2001 From: Ghommie <42542238+Ghommie@users.noreply.github.com> Date: Thu, 3 Oct 2019 19:08:11 +0200 Subject: [PATCH] hopefully a performance improvement to stop genitalia from having to update everytime. --- code/__DEFINES/inventory.dm | 3 +++ code/modules/mob/living/carbon/human/inventory.dm | 4 +++- modular_citadel/code/modules/arousal/genitals.dm | 7 +++---- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/code/__DEFINES/inventory.dm b/code/__DEFINES/inventory.dm index 24d381d1a8..7f1360d3ac 100644 --- a/code/__DEFINES/inventory.dm +++ b/code/__DEFINES/inventory.dm @@ -237,3 +237,6 @@ GLOBAL_LIST_INIT(security_wintercoat_allowed, typecacheof(list( //Internals checker #define GET_INTERNAL_SLOTS(C) list(C.head, C.wear_mask) + +//Slots that won't trigger humans' update_genitals() on equip(). +GLOBAL_LIST_INIT(no_genitals_update_slots, list(SLOT_L_STORE, SLOT_R_STORE, SLOT_S_STORE, SLOT_IN_BACKPACK, SLOT_LEGCUFFED, SLOT_HANDCUFFED, SLOT_HANDS, SLOT_GENERC_DEXTROUS_STORAGE)) diff --git a/code/modules/mob/living/carbon/human/inventory.dm b/code/modules/mob/living/carbon/human/inventory.dm index d35df6b789..084dbd83ef 100644 --- a/code/modules/mob/living/carbon/human/inventory.dm +++ b/code/modules/mob/living/carbon/human/inventory.dm @@ -79,7 +79,8 @@ //This is an UNSAFE proc. Use mob_can_equip() before calling this one! Or rather use equip_to_slot_if_possible() or advanced_equip_to_slot_if_possible() /mob/living/carbon/human/equip_to_slot(obj/item/I, slot) - if(!..()) //a check failed or the item has already found its slot + . = ..() + if(!.) //a check failed or the item has already found its slot return var/not_handled = FALSE //Added in case we make this type path deeper one day @@ -136,6 +137,7 @@ update_inv_s_store() else to_chat(src, "You are trying to equip this item to an unsupported inventory slot. Report this to a coder!") + not_handled = TRUE //Item is handled and in slot, valid to call callback, for this proc should always be true if(!not_handled) diff --git a/modular_citadel/code/modules/arousal/genitals.dm b/modular_citadel/code/modules/arousal/genitals.dm index d94f70ecef..68759218c7 100644 --- a/modular_citadel/code/modules/arousal/genitals.dm +++ b/modular_citadel/code/modules/arousal/genitals.dm @@ -209,11 +209,10 @@ //procs to handle sprite overlays being applied to humans -/obj/item/equipped(mob/user, slot) - if(ishuman(user)) - var/mob/living/carbon/human/H = user - H.update_genitals() +/mob/living/carbon/human/equip_to_slot(obj/item/I, slot) . = ..() + if(!. && !(slot in GLOB.no_genitals_update_slots)) //the item was successfully equipped, and the chosen slot wasn't merely storage or hands. + update_genitals() /mob/living/carbon/human/doUnEquip(obj/item/I, force) . = ..()