Fixes some cases which references are used in trait sources, potentially causing hard deletes (#67974)

About The Pull Request

Fixes some cases in which actual references were used in trait sources instead of keys (or ref() keys).

This can cause some rare and difficult to find hard deletes.

Trait sources should be a string key relating to the source of it, not an actual reference to what added it. References within trait sources are never handled in Destroy(), because it's not expected behavior, meaning it can cause hanging references.

So, I went through with a regex to find some cases and replaced them.
I used the following and just picked through the few by hand to find erroneous ones.
ADD_TRAIT\(.+, .+, [a-z]+\)
REMOVE_TRAIT_TRAIT\(.+, .+, [a-z]+\)
Why It's Good For The Game

Less hard deletes, probably.
Changelog

cl Melbert
code: Some traits which mistakenly were sourced from a hard reference are no longer.
/cl
This commit is contained in:
MrMelbert
2022-07-03 19:02:17 -05:00
committed by GitHub
parent 8b05531f76
commit cdc50e27eb
15 changed files with 37 additions and 38 deletions
@@ -164,9 +164,9 @@
. = ..()
if(HAS_TRAIT(add_to, TRAIT_COMPONENT_MMI))
return FALSE
ADD_TRAIT(add_to, TRAIT_COMPONENT_MMI, src)
ADD_TRAIT(add_to, TRAIT_COMPONENT_MMI, REF(src))
/obj/item/circuit_component/mmi/removed_from(obj/item/integrated_circuit/removed_from)
REMOVE_TRAIT(removed_from, TRAIT_COMPONENT_MMI, src)
REMOVE_TRAIT(removed_from, TRAIT_COMPONENT_MMI, REF(src))
remove_current_brain()
return ..()
@@ -55,10 +55,10 @@
. = ..()
if(HAS_TRAIT(add_to, TRAIT_COMPONENT_PRINTER))
return FALSE
ADD_TRAIT(add_to, TRAIT_COMPONENT_PRINTER, src)
ADD_TRAIT(add_to, TRAIT_COMPONENT_PRINTER, REF(src))
/obj/item/circuit_component/printer/removed_from(obj/item/integrated_circuit/removed_from)
REMOVE_TRAIT(removed_from, TRAIT_COMPONENT_PRINTER, src)
REMOVE_TRAIT(removed_from, TRAIT_COMPONENT_PRINTER, REF(src))
return ..()
/obj/item/circuit_component/printer/register_shell(atom/movable/shell)