From 723ced5d7b36ff72440d6588f94d0c251ef6cab8 Mon Sep 17 00:00:00 2001 From: Mothblocks <35135081+Mothblocks@users.noreply.github.com> Date: Sun, 24 Dec 2023 06:46:00 -0800 Subject: [PATCH] Make spritesheets cacheable by default, killing a lot of overtime in the round start spike (#80522) ## About The Pull Request Makes all spritesheets cache by default. This wasn't the case originally because some spritesheets like vending machines relied on in world state, but none of them do anymore because that's whack. Also fixes a bug that would cause half completed caches to break other stuff. This didn't happen in real gameplay, but would've happened if you tried to change cachable on anything while you already had a tmp folder. ## Changelog :cl: fix: Cut down a significant amount of time that caused the start of rounds to lag. /:cl: --- code/game/objects/items/airlock_painter.dm | 1 - code/modules/asset_cache/asset_list.dm | 8 +++++--- code/modules/asset_cache/assets/emojipedia.dm | 2 -- code/modules/client/preferences/assets.dm | 1 - code/modules/client/preferences/middleware/antags.dm | 1 - code/modules/client/preferences/middleware/species.dm | 1 - 6 files changed, 5 insertions(+), 9 deletions(-) diff --git a/code/game/objects/items/airlock_painter.dm b/code/game/objects/items/airlock_painter.dm index 7ec89b2846a..6a6fc5fc51c 100644 --- a/code/game/objects/items/airlock_painter.dm +++ b/code/game/objects/items/airlock_painter.dm @@ -327,7 +327,6 @@ /datum/asset/spritesheet/decals name = "floor_decals" - cross_round_cachable = TRUE /// The floor icon used for blend_preview_floor() var/preview_floor_icon = 'icons/turf/floors.dmi' diff --git a/code/modules/asset_cache/asset_list.dm b/code/modules/asset_cache/asset_list.dm index 45f09a9e3c0..7e5785250a5 100644 --- a/code/modules/asset_cache/asset_list.dm +++ b/code/modules/asset_cache/asset_list.dm @@ -26,6 +26,7 @@ GLOBAL_LIST_EMPTY(asset_datums) /// Whether or not this asset can be cached across rounds of the same commit under the `CACHE_ASSETS` config. /// This is not a *guarantee* the asset will be cached. Not all asset subtypes respect this field, and the /// config can, of course, be disabled. + /// Disable this if your asset can change between rounds on the same exact version of the code. var/cross_round_cachable = FALSE /datum/asset/New() @@ -133,6 +134,7 @@ GLOBAL_LIST_EMPTY(asset_datums) /datum/asset/spritesheet _abstract = /datum/asset/spritesheet + cross_round_cachable = TRUE var/name /// List of arguments to pass into queuedInsert /// Exists so we can queue icon insertion, mostly for stuff like preferences @@ -145,6 +147,9 @@ GLOBAL_LIST_EMPTY(asset_datums) /// If this asset should be fully loaded on new /// Defaults to false so we can process this stuff nicely var/load_immediately = FALSE + VAR_PRIVATE + // Kept in state so that the result is the same, even when the files are created, for this run + should_refresh = null /datum/asset/spritesheet/proc/should_load_immediately() #ifdef DO_NOT_DEFER_ASSETS @@ -158,9 +163,6 @@ GLOBAL_LIST_EMPTY(asset_datums) if (..()) return TRUE - // Static so that the result is the same, even when the files are created, for this run - var/static/should_refresh = null - if (isnull(should_refresh)) // `fexists` seems to always fail on static-time should_refresh = !fexists("[ASSET_CROSS_ROUND_CACHE_DIRECTORY]/spritesheet.[name].css") diff --git a/code/modules/asset_cache/assets/emojipedia.dm b/code/modules/asset_cache/assets/emojipedia.dm index 2197f1bff22..200e3770ff4 100644 --- a/code/modules/asset_cache/assets/emojipedia.dm +++ b/code/modules/asset_cache/assets/emojipedia.dm @@ -1,7 +1,5 @@ /datum/asset/spritesheet/emojipedia name = "emojipedia" - cross_round_cachable = TRUE // The Emoji DMI is static and doesn't change without a commit mis-match. /datum/asset/spritesheet/emojipedia/create_spritesheets() InsertAll("", EMOJI_SET) - diff --git a/code/modules/client/preferences/assets.dm b/code/modules/client/preferences/assets.dm index 6fa29b9f90f..a75178cc3e1 100644 --- a/code/modules/client/preferences/assets.dm +++ b/code/modules/client/preferences/assets.dm @@ -2,7 +2,6 @@ /datum/asset/spritesheet/preferences name = "preferences" early = TRUE - cross_round_cachable = TRUE /datum/asset/spritesheet/preferences/create_spritesheets() var/list/to_insert = list() diff --git a/code/modules/client/preferences/middleware/antags.dm b/code/modules/client/preferences/middleware/antags.dm index 44cb0017e16..13e3bfa718f 100644 --- a/code/modules/client/preferences/middleware/antags.dm +++ b/code/modules/client/preferences/middleware/antags.dm @@ -108,7 +108,6 @@ /datum/asset/spritesheet/antagonists name = "antagonists" early = TRUE - cross_round_cachable = TRUE /// Mapping of spritesheet keys -> icons var/list/antag_icons = list() diff --git a/code/modules/client/preferences/middleware/species.dm b/code/modules/client/preferences/middleware/species.dm index a87dc16a792..80c78d25640 100644 --- a/code/modules/client/preferences/middleware/species.dm +++ b/code/modules/client/preferences/middleware/species.dm @@ -9,7 +9,6 @@ /datum/asset/spritesheet/species name = "species" early = TRUE - cross_round_cachable = TRUE /datum/asset/spritesheet/species/create_spritesheets() var/list/to_insert = list()