Files
fulpstation/code/__HELPERS/weakref.dm
FernandoJ8 8261383d49 [MDB IGNORE] TGU: A new and improved paperwork economy AKA second august TGU (#796)
* Okay I think it's fine this time

* Forgot that I had changed the var name

* Weird console var

* and pubby

* strongdmm moment

* Screenshot tests

* Gives pubby paperwork and other misc. fixes

* faxes and fixes

* forgot to change the area

* Forcefully updating the branch, question mark?

* uh... yea

* why's the path like that

* a bunch of shit

* and pubby

* Part 1

* Final fix

* Mapping & co

* fix

* God this commit history is a mess

* kill kill murder kill murder

* areas

* and the one wire
2022-08-27 16:22:33 -04:00

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