Merge pull request #14936 from ItsSelis/selis-weakrefs

Little Weakref Refactor
This commit is contained in:
Heroman3003
2023-06-03 19:21:17 +10:00
committed by GitHub
41 changed files with 283 additions and 177 deletions
+2 -2
View File
@@ -88,14 +88,14 @@
for(var/mob/living/L in living_mobs(0)) //add everyone on the tile to the do-not-eat list for a while
if(!(LAZYFIND(prey_excludes, L))) // Unless they're already on it, just to avoid fuckery.
LAZYSET(prey_excludes, L, world.time)
addtimer(CALLBACK(src, .proc/removeMobFromPreyExcludes, weakref(L)), 5 MINUTES)
addtimer(CALLBACK(src, .proc/removeMobFromPreyExcludes, WEAKREF(L)), 5 MINUTES)
else if(istype(O, /obj/item/device/healthanalyzer))
var/healthpercent = health/maxHealth*100
to_chat(user, "<span class='notice'>[src] seems to be [healthpercent]% healthy.</span>")
else
..()
/mob/living/simple_mob/proc/removeMobFromPreyExcludes(weakref/target)
/mob/living/simple_mob/proc/removeMobFromPreyExcludes(datum/weakref/target)
if(isweakref(target))
var/mob/living/L = target.resolve()
LAZYREMOVE(prey_excludes, L) // It's fine to remove a null from the list if we couldn't resolve L