From 70851f83cc9c1e6c9c356380b66969dc7743c61a Mon Sep 17 00:00:00 2001 From: Drathek <76988376+Drulikar@users.noreply.github.com> Date: Wed, 17 Jan 2024 06:14:39 -0800 Subject: [PATCH] Fix Detach and on_detach parameter oversights (#5470) # About the pull request This PR fixes some confusion with Detatch logic for gun attachments. The base implementation didn't seem to originally have a user variable but all other implementations did. # Explain why it's good for the game Less pitfalls for coders. # Testing Photographs and Procedure
Screenshots & Videos Put screenshots and videos here with an empty line between the screenshots and the `
` tags.
# Changelog :cl: Drathek code: Cleaned up some oversights in attachment Detatch logic /:cl: --- code/modules/projectiles/gun_attachables.dm | 3 ++- code/modules/projectiles/gun_helpers.dm | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/code/modules/projectiles/gun_attachables.dm b/code/modules/projectiles/gun_attachables.dm index 0f3fde8f3c9b..e431dbab4dab 100644 --- a/code/modules/projectiles/gun_attachables.dm +++ b/code/modules/projectiles/gun_attachables.dm @@ -168,7 +168,8 @@ Defined in conflicts.dm of the #defines folder. /obj/item/attachable/proc/Detach(mob/user, obj/item/weapon/gun/detaching_gub) if(!istype(detaching_gub)) return //Guns only - detaching_gub.on_detach(user) + if(user) + detaching_gub.on_detach(user, src) if(flags_attach_features & ATTACH_ACTIVATION) activate_attachment(detaching_gub, null, TRUE) diff --git a/code/modules/projectiles/gun_helpers.dm b/code/modules/projectiles/gun_helpers.dm index 8e73124a8b92..486e25315eef 100644 --- a/code/modules/projectiles/gun_helpers.dm +++ b/code/modules/projectiles/gun_helpers.dm @@ -395,7 +395,7 @@ DEFINES in setup.dm, referenced here. playsound(user, 'sound/handling/attachment_add.ogg', 15, 1, 4) return TRUE -/obj/item/weapon/gun/proc/on_detach(obj/item/attachable/attachment) +/obj/item/weapon/gun/proc/on_detach(mob/user, obj/item/attachable/attachment) return /obj/item/weapon/gun/proc/update_attachables() //Updates everything. You generally don't need to use this.