From 40d0ced21f0051a771971a42763e2b25ea1cd90d Mon Sep 17 00:00:00 2001 From: Mira <42539014+MiraHell@users.noreply.github.com> Date: Fri, 31 Jan 2025 18:53:35 +0300 Subject: [PATCH] fix and make use of early return (#28036) --- .../mining/lavaland/necropolis_chests.dm | 61 +++++++++++-------- 1 file changed, 35 insertions(+), 26 deletions(-) diff --git a/code/modules/mining/lavaland/necropolis_chests.dm b/code/modules/mining/lavaland/necropolis_chests.dm index 237f37897dd..db4ba936b6c 100644 --- a/code/modules/mining/lavaland/necropolis_chests.dm +++ b/code/modules/mining/lavaland/necropolis_chests.dm @@ -376,33 +376,42 @@ addtimer(CALLBACK(src, PROC_REF(try_attach_to_owner)), 0) // Do this once the drop call stack is done. The holding limb might be getting removed /obj/item/rod_of_asclepius/proc/try_attach_to_owner() - if(ishuman(owner) && !QDELETED(owner)) - if(ishuman(loc)) - var/mob/living/carbon/human/thief = loc - thief.drop_item_to_ground(src, force = TRUE, silent = TRUE) // You're not my owner! - if(owner.stat == DEAD) - qdel(src) // Oh no! Oh well a new rod will be made from the STATUS_EFFECT_HIPPOCRATIC_OATH - return - flags |= NODROP // Readd the nodrop - var/mob/living/carbon/human/H = owner - var/limb_regrown = FALSE - if(usedHand == LEFT_HAND) - limb_regrown = H.regrow_external_limb_if_missing("l_arm") - limb_regrown = H.regrow_external_limb_if_missing("l_hand") || limb_regrown - H.drop_l_hand(TRUE) - H.put_in_l_hand(src, TRUE) - else - limb_regrown = H.regrow_external_limb_if_missing("r_arm") - limb_regrown = H.regrow_external_limb_if_missing("r_hand") || limb_regrown - H.drop_r_hand(TRUE) - H.put_in_r_hand(src, TRUE) - if(!limb_regrown) - to_chat(H, "The Rod of Asclepius suddenly grows back out of your arm!") - else - H.update_body() // Update the limb sprites - to_chat(H, "Your arm suddenly grows back with the Rod of Asclepius still attached!") - else + if(!ishuman(owner) || QDELETED(owner)) deactivate() + return + + var/mob/living/carbon/human/thief = loc + + if(thief == owner) // stealing from yourself, huh? + return + + if(ishuman(thief)) + thief.drop_item_to_ground(src, force = TRUE, silent = TRUE) // You're not my owner! + + if(owner.stat == DEAD) + qdel(src) // Oh no! Oh well a new rod will be made from the STATUS_EFFECT_HIPPOCRATIC_OATH + return + + flags |= NODROP // Readd the nodrop + var/mob/living/carbon/human/H = owner + var/limb_regrown = FALSE + + if(usedHand == LEFT_HAND) + limb_regrown = H.regrow_external_limb_if_missing("l_arm") + limb_regrown = H.regrow_external_limb_if_missing("l_hand") || limb_regrown + H.drop_l_hand(TRUE) + H.put_in_l_hand(src, TRUE) + else + limb_regrown = H.regrow_external_limb_if_missing("r_arm") + limb_regrown = H.regrow_external_limb_if_missing("r_hand") || limb_regrown + H.drop_r_hand(TRUE) + H.put_in_r_hand(src, TRUE) + + if(!limb_regrown) + to_chat(H, "The Rod of Asclepius suddenly grows back out of your arm!") + else + H.update_body() // Update the limb sprites + to_chat(H, "Your arm suddenly grows back with the Rod of Asclepius still attached!") /obj/item/rod_of_asclepius/proc/activated(mob/living/carbon/new_owner) owner = new_owner