Skip to content

Commit

Permalink
[MIRROR] Removes weakref in forensics datum (#2220)
Browse files Browse the repository at this point in the history
* Removes weakref in forensics datum (#81751)

## About The Pull Request

This doesn't need to use weakrefs, it's a fairly easy to manage
relationship, when the atom goes the forensics goes

* Removes weakref in forensics datum

---------

Co-authored-by: NovaBot <[email protected]>
Co-authored-by: MrMelbert <[email protected]>
  • Loading branch information
3 people authored Mar 2, 2024
1 parent e27bc2c commit bd4d309
Showing 1 changed file with 9 additions and 22 deletions.
31 changes: 9 additions & 22 deletions code/modules/forensics/_forensics.dm
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
* * List of clothing fibers on the atom
*/
/datum/forensics
/// Weakref to the parent owning this datum
var/datum/weakref/parent
/// Ref to the parent owning this datum
var/atom/parent
/**
* List of fingerprints on this atom
*
Expand Down Expand Up @@ -39,15 +39,15 @@
*/
var/list/fibers

/datum/forensics/New(atom/parent, fingerprints, hiddenprints, blood_DNA, fibers)
/datum/forensics/New(atom/parent, list/fingerprints, list/hiddenprints, list/blood_DNA, list/fibers)
if(!isatom(parent))
stack_trace("We tried adding a forensics datum to something that isnt an atom. What the hell are you doing?")
qdel(src)
return

RegisterSignal(parent, COMSIG_COMPONENT_CLEAN_ACT, PROC_REF(clean_act))

src.parent = WEAKREF(parent)
src.parent = parent
src.fingerprints = fingerprints
src.hiddenprints = hiddenprints
src.blood_DNA = blood_DNA
Expand All @@ -67,9 +67,7 @@
check_blood()

/datum/forensics/Destroy(force)
var/atom/parent_atom = parent.resolve()
if (!isnull(parent_atom))
UnregisterSignal(parent_atom, list(COMSIG_COMPONENT_CLEAN_ACT))
UnregisterSignal(parent, COMSIG_COMPONENT_CLEAN_ACT)
parent = null
return ..()

Expand Down Expand Up @@ -148,10 +146,7 @@
/// Adds a single fiber
/datum/forensics/proc/add_fibers(mob/living/carbon/human/suspect)
var/fibertext
var/atom/actual_parent = parent?.resolve()
if(isnull(actual_parent))
parent = null
var/item_multiplier = isitem(actual_parent) ? ITEM_FIBER_MULTIPLIER : NON_ITEM_FIBER_MULTIPLIER
var/item_multiplier = isitem(parent) ? ITEM_FIBER_MULTIPLIER : NON_ITEM_FIBER_MULTIPLIER
if(suspect.wear_suit)
fibertext = "Material from \a [suspect.wear_suit]."
if(prob(10 * item_multiplier) && !LAZYACCESS(fibers, fibertext))
Expand Down Expand Up @@ -217,11 +212,7 @@
if(last_stamp_pos)
LAZYSET(hiddenprints, suspect.key, copytext(hiddenprints[suspect.key], 1, last_stamp_pos))
hiddenprints[suspect.key] += "\nLast: \[[current_time]\] \"[suspect.real_name]\"[has_gloves]. Ckey: [suspect.ckey]" //made sure to be existing by if(!LAZYACCESS);else
var/atom/parent_atom = parent?.resolve()
if(!isnull(parent_atom))
parent_atom.fingerprintslast = suspect.ckey
else
parent = null
parent.fingerprintslast = suspect.ckey
return TRUE

/// Adds the given list into blood_DNA
Expand All @@ -236,12 +227,8 @@

/// Updates the blood displayed on parent
/datum/forensics/proc/check_blood()
var/obj/item/the_thing = parent?.resolve()
if(isnull(the_thing))
parent = null
return
if(!istype(the_thing) || isorgan(the_thing)) // organs don't spawn with blood decals by default
if(!isitem(parent) || isorgan(parent)) // organs don't spawn with blood decals by default
return
if(!length(blood_DNA))
return
the_thing.AddElement(/datum/element/decal/blood)
parent.AddElement(/datum/element/decal/blood)

0 comments on commit bd4d309

Please sign in to comment.