Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MIRROR] Removes weakref in forensics datum #2220

Merged
merged 1 commit into from
Mar 2, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)
Loading