Files
Bubberstation/code/__HELPERS/weakref.dm
SkyratBot cc93b11d23 [MIRROR] _HELPERS/unsorted.dm has been sorted [MDB IGNORE] (#8627)
* _HELPERS/unsorted.dm has been sorted

* Feexing conflicts

Co-authored-by: Ghilker <42839747+Ghilker@users.noreply.github.com>
Co-authored-by: GoldenAlpharex <jerego1234@hotmail.com>
2021-10-06 22:07:01 +01:00

46 lines
1.0 KiB
Plaintext

/// Checks if potential_weakref is a weakref of thing.
#define IS_WEAKREF_OF(thing, potential_weakref) (istype(thing, /datum) && !isnull(potential_weakref) && thing.weak_reference == potential_weakref)
//For these two procs refs MUST be ref = TRUE format like typecaches!
/proc/weakref_filter_list(list/things, list/refs)
if(!islist(things) || !islist(refs))
return
if(!refs.len)
return things
if(things.len > refs.len)
var/list/f = list()
for(var/i in refs)
var/datum/weakref/r = i
var/datum/d = r.resolve()
if(d)
f |= d
return things & f
else
. = list()
for(var/i in things)
if(!refs[WEAKREF(i)])
continue
. |= i
/proc/weakref_filter_list_reverse(list/things, list/refs)
if(!islist(things) || !islist(refs))
return
if(!refs.len)
return things
if(things.len > refs.len)
var/list/f = list()
for(var/i in refs)
var/datum/weakref/r = i
var/datum/d = r.resolve()
if(d)
f |= d
return things - f
else
. = list()
for(var/i in things)
if(refs[WEAKREF(i)])
continue
. |= i