[TM prolly] Some init optimisationss (#23800)

* [TM prolly] Some init optimisationss

* Do this as well

* Sod it some runtime optimisations as well
This commit is contained in:
AffectedArc07
2024-02-04 21:17:50 +00:00
committed by GitHub
parent d10e1adcae
commit 3ab2a08d86
9 changed files with 54 additions and 23 deletions
@@ -21,6 +21,23 @@
"darkred", "darkredcorners", "darkredfull", "darkblue", "darkbluecorners", "darkbluefull", "darkgreen", "darkgreencorners",
"darkgreenfull", "darkyellow", "darkyellowcorners", "darkyellowfull", "darkbrown", "darkbrowncorners", "darkbrownfull")
// This is a double-list. First entry is the type key, second is the direction, with the final value being the b64 of the icon
var/static/list/lookup_cache = list()
/datum/painter/floor/New(obj/item/painter/parent_painter)
. = ..()
if(!length(lookup_cache))
for(var/style in allowed_states)
if(!(style in lookup_cache))
lookup_cache += style
lookup_cache[style] = list()
for(var/dir in GLOB.alldirs)
var/icon/floor_icon = icon('icons/turf/floors.dmi', style, dir)
// These indexes have to be strings otherwise it treats it as a list index not a map lookup index
lookup_cache[style] += "[dir]"
lookup_cache[style]["[dir]"] = icon2base64(floor_icon)
/datum/painter/floor/paint_atom(atom/target, mob/user)
if(!istype(target, /turf/simulated/floor/plasteel))
to_chat(user, "<span class='warning'>[holder] can only be used on station flooring.</span>")
@@ -62,8 +79,7 @@
data["directionsPreview"] = list()
for(var/dir in GLOB.alldirs)
var/icon/floor_icon = icon('icons/turf/floors.dmi', floor_state, dir)
data["directionsPreview"][dir2text(dir)] = icon2base64(floor_icon)
data["directionsPreview"][dir2text(dir)] = lookup_cache[floor_state]["[dir]"]
return data
@@ -72,8 +88,7 @@
var/list/data = list()
data["allStylesPreview"] = list()
for(var/style in allowed_states)
var/icon/floor_icon = icon('icons/turf/floors.dmi', style, SOUTH)
data["allStylesPreview"][style] = icon2base64(floor_icon)
data["allStylesPreview"][style] = lookup_cache[style]["[SOUTH]"]
return data
@@ -100,4 +115,4 @@
if(dir != 0)
floor_dir = dir
SStgui.update_uis(src)
return TRUE