From fbebb04c2cdb6c4c72247f46000f9701259b36bc Mon Sep 17 00:00:00 2001 From: A miscellaneous Fern <80640114+FernandoJ8@users.noreply.github.com> Date: Tue, 15 Aug 2023 00:17:20 +0200 Subject: [PATCH] Putting mobs into evidence bags no longer causes harddels (#77583) ## About The Pull Request Fun interaction. Since evidence bags make you drop held items to the floor and then forcemove the item into the bag, mob holders would dump the mob on the floor, be qdeleted and have their references cleared and then be put inside the bag's contents, bugging the fuck out and staying in the bag (`put_in_hands()` fails if the item in question is qdeleted) until it's eventually harddeleted because the reference to it in the evidence bag never gets cleared. ![image](https://github.com/tgstation/tgstation/assets/80640114/42cc4748-653f-4ed7-98fa-4c9cd39615e9)
Harddel logs ``` [2023-08-13 12:05:25.908] RUNTIME: ## REF SEARCH Beginning search for references to a /obj/item/clothing/head/mob_holder. [2023-08-13 12:05:26.089] RUNTIME: ## REF SEARCH Finished searching globals [2023-08-13 12:05:26.353] RUNTIME: ## REF SEARCH Finished searching native globals [2023-08-13 12:05:59.099] RUNTIME: ## REF SEARCH Found /obj/item/clothing/head/mob_holder [0x2001ffb] in list World -> /obj/item/evidencebag [0x20140e8] -> contents (list). [2023-08-13 12:09:22.401] RUNTIME: ## REF SEARCH Finished searching atoms [2023-08-13 12:09:50.415] RUNTIME: ## REF SEARCH Finished searching datums [2023-08-13 12:09:50.419] RUNTIME: ## REF SEARCH Finished searching clients [2023-08-13 12:09:50.421] RUNTIME: ## REF SEARCH Completed search for references to a /obj/item/clothing/head/mob_holder. [2023-08-13 12:09:50.427] RUNTIME: ## TESTING: GC: -- [0x2001ffb] | /obj/item/clothing/head/mob_holder was unable to be GC'd ```
My solution was to change the checks of the evidence bag. Rather than making you drop the item, they will check that the item is in your hands and that it doesn't have `TRAIT_NODROP`. If either isn't true, it will fail, which I think covers all the relevant cases for this. It should avoid any similar issues in the future with items that dissapear when dropped. (Hand gestures would have also suffered from this if they weren't excluded in an earlier check, for example). As an additional fallback, it will also check if the item is qdeleted before trying to forcemove it. ## Why It's Good For The Game Closes #77197. Hard deletes are bad, real bad. ## Changelog :cl: fix: mob holders no longer bug out and harddel when put into evidence bags. /:cl: --- code/modules/detectivework/evidence.dm | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/code/modules/detectivework/evidence.dm b/code/modules/detectivework/evidence.dm index 1f9f572ce42..176a9c29f92 100644 --- a/code/modules/detectivework/evidence.dm +++ b/code/modules/detectivework/evidence.dm @@ -56,9 +56,12 @@ if(!isturf(I.loc)) //If it isn't on the floor. Do some checks to see if it's in our hands or a box. Otherwise give up. if(I.loc.atom_storage) //in a container. I.loc.atom_storage.remove_single(user, I, src) - if(!user.dropItemToGround(I)) + if(!user.is_holding(I) || HAS_TRAIT(I, TRAIT_NODROP)) return + if(QDELETED(I)) + return + user.visible_message(span_notice("[user] puts [I] into [src]."), span_notice("You put [I] inside [src]."),\ span_hear("You hear a rustle as someone puts something into a plastic bag."))