Files
Polaris/code/datums/weakref.dm
spookerton cb483875cd null guard qdel, better log_info_line behavior
gentle qdel refactor for readability
adds ref_name and ref_type to weakref
improves /proc/weakref initial test
corrects weakref GC hint
2022-10-15 15:06:00 +01:00

31 lines
494 B
Plaintext

/weakref
var/ref
var/ref_name
var/ref_type
/weakref/Destroy()
SHOULD_CALL_PARENT(FALSE)
return QDEL_HINT_IWILLGC
/weakref/New(datum/thing)
ref = "\ref[thing]"
ref_name = "[thing]"
ref_type = thing.type
/weakref/proc/resolve()
var/datum/thing = locate(ref)
if (thing && thing.weakref == src)
return thing
return null
/proc/weakref(datum/thing)
if (!istype(thing) || QDELING(thing))
return
if (!thing.weakref)
thing.weakref = new /weakref (thing)
return thing.weakref