mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2025-12-09 16:05:07 +00:00
Converts a shitload of istypes to their more concise macros Co-authored-by: Seth Scherer <supernovaa41@gmx.com> Co-authored-by: GoldenAlpharex <jerego1234@hotmail.com>
46 lines
1.0 KiB
Plaintext
46 lines
1.0 KiB
Plaintext
/// Checks if potential_weakref is a weakref of thing.
|
|
#define IS_WEAKREF_OF(thing, potential_weakref) (isdatum(thing) && !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
|