mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-01-18 21:15:21 +00:00
Refactors hand tele code with better variable names, splitting procs, fixing C&P code, etc. Adds pre_attack_secondary, the right click version of pre_attack. Adds a new alternate function to hand teles, which will reopen the last location you opened. Works based off locations, not turfs. For example, right clicking after locking in "None (Dangerous)" will not teleport you to the same place.
31 lines
750 B
Plaintext
31 lines
750 B
Plaintext
/proc/WEAKREF(datum/input)
|
|
if(istype(input) && !QDELETED(input))
|
|
if(istype(input, /datum/weakref))
|
|
return input
|
|
|
|
if(!input.weak_reference)
|
|
input.weak_reference = new /datum/weakref(input)
|
|
return input.weak_reference
|
|
|
|
/datum/proc/create_weakref() //Forced creation for admin proccalls
|
|
return WEAKREF(src)
|
|
|
|
/datum/weakref
|
|
var/reference
|
|
|
|
/datum/weakref/New(datum/thing)
|
|
reference = REF(thing)
|
|
|
|
/datum/weakref/Destroy(force)
|
|
var/datum/target = resolve()
|
|
qdel(target)
|
|
|
|
if(!force)
|
|
return QDEL_HINT_LETMELIVE //Let BYOND autoGC thiswhen nothing is using it anymore.
|
|
target?.weak_reference = null
|
|
return ..()
|
|
|
|
/datum/weakref/proc/resolve()
|
|
var/datum/D = locate(reference)
|
|
return (!QDELETED(D) && D.weak_reference == src) ? D : null
|