Little Weakref Refactor

This commit is contained in:
Heroman3003
2023-06-03 19:21:17 +10:00
committed by CHOMPStation2
parent 515d0e49ba
commit 3d53d2bb62
41 changed files with 295 additions and 172 deletions

View File

@@ -382,15 +382,15 @@ GLOBAL_LIST_EMPTY(icon_state_lists)
GLOBAL_LIST_EMPTY(cached_examine_icons)
/proc/set_cached_examine_icon(var/atom/A, var/icon/I, var/expiry = 12000)
GLOB.cached_examine_icons[weakref(A)] = I
GLOB.cached_examine_icons[WEAKREF(A)] = I
if(expiry)
addtimer(CALLBACK(GLOBAL_PROC, .proc/uncache_examine_icon, weakref(A)), expiry, TIMER_UNIQUE)
addtimer(CALLBACK(GLOBAL_PROC, .proc/uncache_examine_icon, WEAKREF(A)), expiry, TIMER_UNIQUE)
/proc/get_cached_examine_icon(var/atom/A)
var/weakref/WR = weakref(A)
var/datum/weakref/WR = WEAKREF(A)
return GLOB.cached_examine_icons[WR]
/proc/uncache_examine_icon(var/weakref/WR)
/proc/uncache_examine_icon(var/datum/weakref/WR)
GLOB.cached_examine_icons -= WR
/proc/adjust_brightness(var/color, var/value)