diff --git a/code/__HELPERS/icons.dm b/code/__HELPERS/icons.dm index e2ae09e89e8..9cfff1dac29 100644 --- a/code/__HELPERS/icons.dm +++ b/code/__HELPERS/icons.dm @@ -1099,11 +1099,6 @@ GLOBAL_LIST_INIT(freon_color_matrix, list("#2E5E69", "#60A2A8", "#A1AFB1", rgb(0 alpha += 25 obj_flags &= ~FROZEN - -/// Save file used in icon2base64. Used for converting icons to base64. -GLOBAL_DATUM_INIT(dummySave, /savefile, new("tmp/dummySave.sav")) //Cache of icons for the browser output - - /// Generate a filename for this asset /// The same asset will always lead to the same asset name /// (Generated names do not include file extention.) @@ -1119,10 +1114,14 @@ GLOBAL_DATUM_INIT(dummySave, /savefile, new("tmp/dummySave.sav")) //Cache of ico /proc/icon2base64(icon/icon) if (!isicon(icon)) return FALSE - WRITE_FILE(GLOB.dummySave["dummy"], icon) - var/iconData = GLOB.dummySave.ExportText("dummy") + var/savefile/dummySave = new("tmp/dummySave.sav") + WRITE_FILE(dummySave["dummy"], icon) + var/iconData = dummySave.ExportText("dummy") var/list/partial = splittext(iconData, "{") - return replacetext(copytext_char(partial[2], 3, -5), "\n", "") + . = replacetext(copytext_char(partial[2], 3, -5), "\n", "") //if cleanup fails we want to still return the correct base64 + dummySave.Unlock() + dummySave = null + fdel("tmp/dummySave.sav") //if you get the idea to try and make this more optimized, make sure to still call unlock on the savefile after every write to unlock it. /proc/icon2html(thing, target, icon_state, dir = SOUTH, frame = 1, moving = FALSE, sourceonly = FALSE) if (!thing)