Merge branch 'release' of https://github.com/VOREStation/VOREStation into izac-voreupdate

This commit is contained in:
izac112
2020-05-11 18:20:43 +02:00
295 changed files with 6398 additions and 3317 deletions

View File

@@ -266,31 +266,45 @@ GLOBAL_DATUM_INIT(iconCache, /savefile, new("data/iconCache.sav")) //Cache of ic
var/list/partial = splittext(iconData, "{")
return replacetext(copytext(partial[2], 3, -5), "\n", "")
/proc/expire_bicon_cache(key)
if(GLOB.bicon_cache[key])
GLOB.bicon_cache -= key
return TRUE
return FALSE
GLOBAL_LIST_EMPTY(bicon_cache) // Cache of the <img> tag results, not the icons
/proc/bicon(var/obj, var/use_class = 1, var/custom_classes = "")
var/class = use_class ? "class='icon misc [custom_classes]'" : null
if (!obj)
if(!obj)
return
var/static/list/bicon_cache = list()
if (isicon(obj))
//Icon refs get reused all the time especially on temporarily made ones like chat tags, too difficult to cache.
//if (!bicon_cache["\ref[obj]"]) // Doesn't exist yet, make it.
//bicon_cache["\ref[obj]"] = icon2base64(obj)
// Try to avoid passing bicon an /icon directly. It is better to pass it an atom so it can cache.
if(isicon(obj)) // Passed an icon directly, nothing to cache-key on, as icon refs get reused *often*
return "<img [class] src='data:image/png;base64,[icon2base64(obj)]'>"
// Either an atom or somebody fucked up and is gonna get a runtime, which I'm fine with.
var/atom/A = obj
var/key = "[istype(A.icon, /icon) ? "\ref[A.icon]" : A.icon]:[A.icon_state]"
if (!bicon_cache[key]) // Doesn't exist, make it.
var/icon/I = icon(A.icon, A.icon_state, SOUTH, 1)
if (ishuman(obj))
I = getFlatIcon(obj) //Ugly
bicon_cache[key] = icon2base64(I, key)
var/key
var/changes_often = ishuman(A) || isobserver(A) // If this ends up with more, move it into a proc or var on atom.
if(changes_often)
key = "\ref[A]"
else
key = "[istype(A.icon, /icon) ? "\ref[A.icon]" : A.icon]:[A.icon_state]"
var/base64 = GLOB.bicon_cache[key]
// Non-human atom, no cache
if(!base64) // Doesn't exist, make it.
base64 = icon2base64(A.examine_icon(), key)
GLOB.bicon_cache[key] = base64
if(changes_often)
addtimer(CALLBACK(GLOBAL_PROC, .proc/expire_bicon_cache, key), 50 SECONDS, TIMER_UNIQUE)
// May add a class to the img tag created by bicon
if(use_class)
class = "class='icon [A.icon_state] [custom_classes]'"
return "<img [class] src='data:image/png;base64,[bicon_cache[key]]'>"
return "<img [class] src='data:image/png;base64,[base64]'>"
//Checks if the message content is a valid to_chat message
/proc/is_valid_tochat_message(message)