/world/proc/enable_reference_tracking()
var/extools = world.GetConfig("env", "EXTOOLS_DLL") || (world.system_type == MS_WINDOWS ? "./byond-extools.dll" : "./libbyond-extools.so")
if (fexists(extools))
call(extools, "ref_tracking_initialize")()
/proc/get_back_references(datum/D)
CRASH("/proc/get_back_references not hooked by extools, reference tracking will not function!")
/proc/get_forward_references(datum/D)
CRASH("/proc/get_forward_references not hooked by extools, reference tracking will not function!")
/proc/clear_references(datum/D)
return
/client/proc/view_refs(atom/D) //it actually supports datums as well but byond no likey
set category = "Debug"
set name = "View References"
if(!check_rights(R_DEBUG))
return
var/list/backrefs = get_back_references(D)
if(isnull(backrefs))
usr << browse("Reference tracking not enabled", "window=ref_view")
return
var/list/frontrefs = get_forward_references(D)
var/list/dat = list()
dat += "
References of \ref[D] - [D]
\[Refresh\]
"
dat += "Back references - these things hold references to this object.
"
dat += ""
dat += "| Ref | Type | Variable Name | Follow | "
for(var/ref in backrefs)
var/datum/R = ref
dat += "
|---|
| [REF(R)] | [R.type] | [backrefs[R]] | \[Follow\] |
"
dat += "
"
dat += "Forward references - this object is referencing those things.
"
dat += ""
dat += "| Variable name | Ref | Type | Follow | "
for(var/ref in frontrefs)
var/datum/R = frontrefs[ref]
dat += "
|---|
| [ref] | [REF(R)] | [R.type] | \[Follow\] |
"
dat += "
"
dat = dat.Join()
usr << browse(dat, "window=ref_view") //Done this way rather than tgui to facilitate porting to other codebases or even byond games