From 928df286a646b832f74555d2688945fe909f1bf5 Mon Sep 17 00:00:00 2001 From: mrmanlikesbt <99309552+mrmanlikesbt@users.noreply.github.com> Date: Mon, 13 Apr 2026 16:20:12 -0500 Subject: [PATCH] Kills `/datum/asset/var/_abstract`, uses `abstract_type` instead (#95756) ## About The Pull Request It's all in the title ## Why It's Good For The Game Forgotten in #92909 ## Changelog no player facing changes --- code/controllers/subsystem/assets.dm | 6 ++---- code/controllers/subsystem/early_assets.dm | 5 +---- code/modules/admin/admin_verbs.dm | 8 ++------ code/modules/asset_cache/asset_list.dm | 16 ++++++++-------- .../spritesheet/batched/batched_spritesheet.dm | 2 +- .../spritesheet/legacy/legacy_spritesheet.dm | 4 ++-- code/modules/unit_tests/asset_smart_cache.dm | 2 +- code/modules/unit_tests/spritesheets.dm | 8 ++------ 8 files changed, 19 insertions(+), 32 deletions(-) diff --git a/code/controllers/subsystem/assets.dm b/code/controllers/subsystem/assets.dm index dad696c002a..a9a979dae60 100644 --- a/code/controllers/subsystem/assets.dm +++ b/code/controllers/subsystem/assets.dm @@ -25,10 +25,8 @@ SUBSYSTEM_DEF(assets) transport.Load() /datum/controller/subsystem/assets/Initialize() - for(var/type in typesof(/datum/asset)) - var/datum/asset/A = type - if (type != initial(A._abstract)) - load_asset_datum(type) + for(var/datum/asset/asset_type as anything in valid_subtypesof(/datum/asset)) + load_asset_datum(asset_type) transport.Initialize(cache) diff --git a/code/controllers/subsystem/early_assets.dm b/code/controllers/subsystem/early_assets.dm index a480fbc49a9..9fb7674440c 100644 --- a/code/controllers/subsystem/early_assets.dm +++ b/code/controllers/subsystem/early_assets.dm @@ -20,10 +20,7 @@ SUBSYSTEM_DEF(early_assets) var/init_source = "early assets" SSatoms.set_tracked_initalized(INITIALIZATION_INNEW_REGULAR, init_source) - for (var/datum/asset/asset_type as anything in subtypesof(/datum/asset)) - if (initial(asset_type._abstract) == asset_type) - continue - + for (var/datum/asset/asset_type as anything in valid_subtypesof(/datum/asset)) if (!initial(asset_type.early)) continue diff --git a/code/modules/admin/admin_verbs.dm b/code/modules/admin/admin_verbs.dm index ab95cad4f11..77af0c72fb9 100644 --- a/code/modules/admin/admin_verbs.dm +++ b/code/modules/admin/admin_verbs.dm @@ -685,11 +685,9 @@ ADMIN_VERB(clear_legacy_asset_cache, R_DEBUG, "Clear Legacy Asset Cache", "Clear to_chat(user, span_warning("Asset caching is disabled in the config!")) return var/regenerated = 0 - for(var/datum/asset/target_spritesheet as anything in subtypesof(/datum/asset)) + for(var/datum/asset/target_spritesheet as anything in valid_subtypesof(/datum/asset)) if(!initial(target_spritesheet.cross_round_cachable)) continue - if(target_spritesheet == initial(target_spritesheet._abstract)) - continue var/datum/asset/asset_datum = GLOB.asset_datums[target_spritesheet] asset_datum.regenerate() regenerated++ @@ -700,9 +698,7 @@ ADMIN_VERB(clear_smart_asset_cache, R_DEBUG, "Clear Smart Asset Cache", "Clear t to_chat(user, span_warning("Smart asset caching is disabled in the config!")) return var/cleared = 0 - for(var/datum/asset/spritesheet_batched/target_spritesheet as anything in subtypesof(/datum/asset/spritesheet_batched)) - if(target_spritesheet == initial(target_spritesheet._abstract)) - continue + for(var/datum/asset/spritesheet_batched/target_spritesheet as anything in valid_subtypesof(/datum/asset/spritesheet_batched)) fdel("[ASSET_CROSS_ROUND_SMART_CACHE_DIRECTORY]/spritesheet_cache.[initial(target_spritesheet.name)].json") cleared++ to_chat(user, span_notice("Cleared [cleared] asset\s.")) diff --git a/code/modules/asset_cache/asset_list.dm b/code/modules/asset_cache/asset_list.dm index 033ec58a4cd..5ebc250f434 100644 --- a/code/modules/asset_cache/asset_list.dm +++ b/code/modules/asset_cache/asset_list.dm @@ -14,7 +14,7 @@ GLOBAL_LIST_EMPTY(asset_datums) return loaded_asset.ensure_ready() /datum/asset - var/_abstract = /datum/asset + abstract_type = /datum/asset var/cached_serialized_url_mappings var/cached_serialized_url_mappings_transport_type @@ -81,7 +81,7 @@ GLOBAL_LIST_EMPTY(asset_datums) /// If you don't need anything complicated. /datum/asset/simple - _abstract = /datum/asset/simple + abstract_type = /datum/asset/simple /// list of assets for this datum in the form of: /// asset_filename = asset_file. At runtime the asset_file will be /// converted into a asset_cache datum. @@ -118,7 +118,7 @@ GLOBAL_LIST_EMPTY(asset_datums) // For registering or sending multiple others at once /datum/asset/group - _abstract = /datum/asset/group + abstract_type = /datum/asset/group var/list/children /datum/asset/group/register() @@ -142,7 +142,7 @@ GLOBAL_LIST_EMPTY(asset_datums) A.unregister() /datum/asset/changelog_item - _abstract = /datum/asset/changelog_item + abstract_type = /datum/asset/changelog_item var/item_filename /datum/asset/changelog_item/New(date) @@ -166,7 +166,7 @@ GLOBAL_LIST_EMPTY(asset_datums) //Generates assets based on iconstates of a single icon /datum/asset/simple/icon_states - _abstract = /datum/asset/simple/icon_states + abstract_type = /datum/asset/simple/icon_states var/icon var/list/directions = list(SOUTH) var/frame = 1 @@ -190,7 +190,7 @@ GLOBAL_LIST_EMPTY(asset_datums) SSassets.transport.register_asset(asset_name, asset) /datum/asset/simple/icon_states/multiple_icons - _abstract = /datum/asset/simple/icon_states/multiple_icons + abstract_type = /datum/asset/simple/icon_states/multiple_icons var/list/icons /datum/asset/simple/icon_states/multiple_icons/register() @@ -203,7 +203,7 @@ GLOBAL_LIST_EMPTY(asset_datums) /// For example `blah.css` with asset `blah.png` will get loaded as `namespaces/a3d..14f/f12..d3c.css` and `namespaces/a3d..14f/blah.png`. allowing the css file to load `blah.png` by a relative url rather then compute the generated url with get_url_mappings(). /// The namespace folder's name will change if any of the assets change. (excluding parent assets) /datum/asset/simple/namespaced - _abstract = /datum/asset/simple/namespaced + abstract_type = /datum/asset/simple/namespaced /// parents - list of the parent asset or assets (in name = file assoicated format) for this namespace. /// parent assets must be referenced by their generated url, but if an update changes a parent asset, it won't change the namespace's identity. var/list/parents = list() @@ -248,7 +248,7 @@ GLOBAL_LIST_EMPTY(asset_datums) /// A subtype to generate a JSON file from a list /datum/asset/json - _abstract = /datum/asset/json + abstract_type = /datum/asset/json /// The filename, will be suffixed with ".json" var/name diff --git a/code/modules/asset_cache/spritesheet/batched/batched_spritesheet.dm b/code/modules/asset_cache/spritesheet/batched/batched_spritesheet.dm index 650c87cf680..e167705c35d 100644 --- a/code/modules/asset_cache/spritesheet/batched/batched_spritesheet.dm +++ b/code/modules/asset_cache/spritesheet/batched/batched_spritesheet.dm @@ -7,7 +7,7 @@ #define SPRITESHEET_SYSTEM_VERSION 1 /datum/asset/spritesheet_batched - _abstract = /datum/asset/spritesheet_batched + abstract_type = /datum/asset/spritesheet_batched var/name /// list("32x32") var/list/sizes = list() diff --git a/code/modules/asset_cache/spritesheet/legacy/legacy_spritesheet.dm b/code/modules/asset_cache/spritesheet/legacy/legacy_spritesheet.dm index f0d5760b9af..6468172d6aa 100644 --- a/code/modules/asset_cache/spritesheet/legacy/legacy_spritesheet.dm +++ b/code/modules/asset_cache/spritesheet/legacy/legacy_spritesheet.dm @@ -10,7 +10,7 @@ /// Deprecated: Use /datum/asset/spritesheet_batched where possible /datum/asset/spritesheet - _abstract = /datum/asset/spritesheet + abstract_type = /datum/asset/spritesheet cross_round_cachable = TRUE var/name /// List of arguments to pass into queuedInsert @@ -408,7 +408,7 @@ /// Spritesheet that only uses simple PNGs and CSS keys. See `assets` variable. /// Deprecated: Use /datum/asset/spritesheet_batched where possible /datum/asset/spritesheet/simple - _abstract = /datum/asset/spritesheet/simple + abstract_type = /datum/asset/spritesheet/simple /// Associative list of icon keys (CSS class names) -> PNG filepaths (single quote!) /// File paths MUST be PNGs var/list/assets diff --git a/code/modules/unit_tests/asset_smart_cache.dm b/code/modules/unit_tests/asset_smart_cache.dm index 297951376a3..1c10e74bec4 100644 --- a/code/modules/unit_tests/asset_smart_cache.dm +++ b/code/modules/unit_tests/asset_smart_cache.dm @@ -3,7 +3,7 @@ load_immediately = TRUE force_cache = TRUE // Don't let the asset subsystem load this. This is how we trick it. - _abstract = /datum/asset/spritesheet_batched/test + abstract_type = /datum/asset/spritesheet_batched/test var/static/list/items = list(/obj/item/binoculars, /obj/item/camera, /obj/item/clothing/under/color/blue, /obj/item/clothing/under/color/black) /datum/asset/spritesheet_batched/test/create_spritesheets() diff --git a/code/modules/unit_tests/spritesheets.dm b/code/modules/unit_tests/spritesheets.dm index 16666dac17f..404590125e6 100644 --- a/code/modules/unit_tests/spritesheets.dm +++ b/code/modules/unit_tests/spritesheets.dm @@ -2,22 +2,18 @@ /datum/unit_test/spritesheets /datum/unit_test/spritesheets/Run() - for(var/datum/asset/spritesheet/sheet as anything in subtypesof(/datum/asset/spritesheet)) + for(var/datum/asset/spritesheet/sheet as anything in valid_subtypesof(/datum/asset/spritesheet)) if(!initial(sheet.name)) //Ignore abstract types continue - if (sheet == initial(sheet._abstract)) - continue sheet = get_asset_datum(sheet) for(var/sprite_name in sheet.sprites) if(!sprite_name) TEST_FAIL("Spritesheet [sheet.type] has a nameless icon state.") // Test IconForge generated sheets as well - for(var/datum/asset/spritesheet_batched/sheet as anything in subtypesof(/datum/asset/spritesheet_batched)) + for(var/datum/asset/spritesheet_batched/sheet as anything in valid_subtypesof(/datum/asset/spritesheet_batched)) if(!initial(sheet.name)) //Ignore abstract types continue - if (sheet == initial(sheet._abstract)) - continue sheet = get_asset_datum(sheet) for(var/sprite_name in sheet.sprites) if(!sprite_name)