From 41a05bc196a359efc4cd24fce7c876b961fb34f2 Mon Sep 17 00:00:00 2001 From: Fluffy <65877598+FluffyGhoster@users.noreply.github.com> Date: Fri, 23 Aug 2024 12:49:28 +0200 Subject: [PATCH] Refactored the abstract meta propriety (#19797) Refactored the abstract meta propriety into defines. It's now more easy to spot/see abstract types thanks to the macro that defines them. Added a check on initialization of atoms to avoid spawning abstract types. Made the spawn_atom proc check for abstractness. Made the spawn_atom proc use tgui_list for types list shorter than 1000 elements, which enables to search in them. It's too laggy on larger lists so above 1000 it uses the builtin input. Made the spawn_atom use a list subtraction instead of a double list, it's lighter on memory and processing. --- aurorastation.dme | 2 +- code/__DEFINES/abstract_type.dm | 25 ++++++++ code/_onclick/hud/rendering/_renderer.dm | 3 +- code/core/datum/IsAbstract.dm | 23 ------- .../overhead_emote_singleton.dm | 4 +- code/datums/datum.dm | 10 +++ code/datums/repositories/singletons.dm | 3 +- .../game/atom/atoms_initializing_EXPENSIVE.dm | 7 +++ code/game/machinery/howitzer.dm | 24 ++----- code/game/objects/items/weapons/RFD.dm | 4 +- .../objects/items/weapons/cigs_lighters.dm | 3 +- .../objects/items/weapons/implants/implant.dm | 3 +- code/game/objects/structures/urban.dm | 6 +- code/modules/abstract/_abstract.dm | 3 +- code/modules/admin/admin.dm | 29 ++++++--- .../loadout/items/accessories.dm | 3 +- .../loadout/items/computer.dm | 6 +- .../loadout/items/religion.dm | 12 ++-- .../preference_setup/loadout/items/suit.dm | 3 +- .../loadout/items/xeno/diona.dm | 6 +- .../loadout/items/xeno/machine.dm | 3 +- .../loadout/items/xeno/skrell.dm | 10 ++- .../loadout/items/xeno/tajara.dm | 3 +- .../loadout/items/xeno/vaurca.dm | 3 +- code/modules/clothing/under/pants.dm | 3 +- .../mob/living/simple_animal/aquatic.dm | 4 +- .../hostile/commanded/commanded.dm | 4 +- .../living/simple_animal/hostile/hostile.dm | 4 +- .../hostile/retaliate/aquatic.dm | 4 +- .../hostile/retaliate/retaliate.dm | 4 +- code/modules/power/apc.dm | 3 +- .../Chemistry-Reagents-Dispenser.dm | 3 +- .../food/snacks/cultural/human.dm | 3 +- .../reagent_containers/food/snacks/noodles.dm | 3 +- .../weather/weather_fsm_state_transitions.dm | 3 +- code/modules/weather/weather_fsm_states.dm | 5 +- code/unit_tests/create_and_destroy.dm | 4 ++ code/unit_tests/unit_test.dm | 3 +- html/changelogs/fluffyghost-reabstracting.yml | 63 +++++++++++++++++++ maps/away/away_site/shady/shady.dmm | 1 - maps/away/away_sites.dm | 3 +- .../exoplanets/exoplanet_ruins.dm | 4 +- maps/random_ruins/space_ruins/space_ruins.dm | 4 +- 43 files changed, 177 insertions(+), 146 deletions(-) create mode 100644 code/__DEFINES/abstract_type.dm delete mode 100644 code/core/datum/IsAbstract.dm create mode 100644 html/changelogs/fluffyghost-reabstracting.yml diff --git a/aurorastation.dme b/aurorastation.dme index 95f2e734dd2..7be4b3374cd 100644 --- a/aurorastation.dme +++ b/aurorastation.dme @@ -28,6 +28,7 @@ #include "code\__DEFINES\_tick.dm" #include "code\__DEFINES\_unit_tests.dm" #include "code\__DEFINES\_world.dm" +#include "code\__DEFINES\abstract_type.dm" #include "code\__DEFINES\access.dm" #include "code\__DEFINES\accessories.dm" #include "code\__DEFINES\admin.dm" @@ -408,7 +409,6 @@ #include "code\controllers\subsystems\processing\psi.dm" #include "code\controllers\subsystems\processing\shuttle.dm" #include "code\controllers\subsystems\processing\tgui.dm" -#include "code\core\datum\IsAbstract.dm" #include "code\datums\ai_law_sets.dm" #include "code\datums\ai_laws.dm" #include "code\datums\beam.dm" diff --git a/code/__DEFINES/abstract_type.dm b/code/__DEFINES/abstract_type.dm new file mode 100644 index 00000000000..c069f140523 --- /dev/null +++ b/code/__DEFINES/abstract_type.dm @@ -0,0 +1,25 @@ +/** + * Abstract-ness is a meta-property of a class that is used to indicate + * that the class is intended to be used as a base class for others, and + * should not (or cannot) be instantiated. + * + * We have no such language concept in DM, and so we provide a datum member + * that can be used to hint at abstractness for circumstances where we would + * like that to be the case, such as base behavior providers. + * + * Use this macro, and only this macro, to define an abstract type. + */ +#define ABSTRACT_TYPE(typepath)\ +##typepath {\ + abstract_type = ##typepath; \ +}; ##typepath + +/** + * Returns whether the given datum/path is an abstract type + * + * * thing - A `datum` or `typepath` to check + */ +#define is_abstract(thing) (ispath(##thing) ? (##thing == initial(##thing:abstract_type)) : (##thing:type == (##thing:abstract_type))) +// ^- The dynamic access operator is needed because we accept paths and we can't fake cast them to a hygenic typed var since we have to give a return value +// it sucks, but it's DM, so things are bound to suck sometimes. Thanks byond. It shouldn't however give any issue, because the abstract_type var is defined +// at the datum level, so essentially for everything, and this being a macro saves proc call overhead -- essentially, i think the tradeoff is worth it diff --git a/code/_onclick/hud/rendering/_renderer.dm b/code/_onclick/hud/rendering/_renderer.dm index 3d5547ba0b0..51b8274562e 100644 --- a/code/_onclick/hud/rendering/_renderer.dm +++ b/code/_onclick/hud/rendering/_renderer.dm @@ -8,8 +8,7 @@ */ /// The base /renderer definition and defaults. -/atom/movable/renderer - abstract_type = /atom/movable/renderer +ABSTRACT_TYPE(/atom/movable/renderer) appearance_flags = DEFAULT_RENDERER_APPEARANCE_FLAGS screen_loc = "CENTER" plane = LOWEST_PLANE diff --git a/code/core/datum/IsAbstract.dm b/code/core/datum/IsAbstract.dm deleted file mode 100644 index 1bb092f3eb3..00000000000 --- a/code/core/datum/IsAbstract.dm +++ /dev/null @@ -1,23 +0,0 @@ -/** -* Abstract-ness is a meta-property of a class that is used to indicate -* that the class is intended to be used as a base class for others, and -* should not (or cannot) be instantiated. -* We have no such language concept in DM, and so we provide a datum member -* that can be used to hint at abstractness for circumstances where we would -* like that to be the case, such as base behavior providers. -*/ - -/// If set, a path at/above this one that expects not to be instantiated. -/datum/var/abstract_type - -/// If true, this datum is an instance of an abstract type. Oops. -/datum/proc/IsAbstract() - SHOULD_NOT_OVERRIDE(TRUE) - return type == abstract_type - -/// Passed a path or instance, returns whether it is abstract. Otherwise null. -/proc/is_abstract(datum/thing) - if (ispath(thing)) - return thing == initial(thing.abstract_type) - if (istype(thing)) - return thing.IsAbstract() diff --git a/code/datums/components/overhead_emote/overhead_emote_singleton.dm b/code/datums/components/overhead_emote/overhead_emote_singleton.dm index 99c560ba70c..3c93d1038dc 100644 --- a/code/datums/components/overhead_emote/overhead_emote_singleton.dm +++ b/code/datums/components/overhead_emote/overhead_emote_singleton.dm @@ -1,6 +1,4 @@ -/singleton/overhead_emote - abstract_type = /singleton/overhead_emote - +ABSTRACT_TYPE(/singleton/overhead_emote) var/icon = 'icons/mob/overhead_emote.dmi' var/icon_state = "abstract" diff --git a/code/datums/datum.dm b/code/datums/datum.dm index e9bfaff6549..f94d98d80bb 100644 --- a/code/datums/datum.dm +++ b/code/datums/datum.dm @@ -33,6 +33,16 @@ /// Datum level flags var/datum_flags = NONE + /** + * If set, a path at/above this one that expects not to be instantiated + * + * This is a `typepath` + * + * Do not instantiate a datum that has the path set as its abstract_type, this indicates + * that the datum is abstract and is not meant to be spawned/used directly + */ + var/abstract_type + /// A weak reference to another datum var/datum/weakref/weak_reference diff --git a/code/datums/repositories/singletons.dm b/code/datums/repositories/singletons.dm index b4016b9bd7e..38d8bf21beb 100644 --- a/code/datums/repositories/singletons.dm +++ b/code/datums/repositories/singletons.dm @@ -163,8 +163,7 @@ var/global/repository/singletons/Singletons = new return result -/singleton - abstract_type = /singleton +ABSTRACT_TYPE(/singleton) /singleton/proc/Initialize() diff --git a/code/game/atom/atoms_initializing_EXPENSIVE.dm b/code/game/atom/atoms_initializing_EXPENSIVE.dm index 1e960128759..7587e8fb914 100644 --- a/code/game/atom/atoms_initializing_EXPENSIVE.dm +++ b/code/game/atom/atoms_initializing_EXPENSIVE.dm @@ -144,6 +144,13 @@ if (update_icon_on_init) SSicon_update.add_to_queue(src) + //Finally an aurora snowflake code that matters, + //this try to ensure noone is stupid enough to instantiate an abstract type + if(is_abstract(src)) + var/datum/space_level/L = SSmapping.get_level(z) + stack_trace("Atom [src] ([type]) \[ X:[x] Y:[y] Z:[z] (Space level: [L ? L.name : "NOT FOUND"]) \] is abstract, but is trying to initialize!") + return INITIALIZE_HINT_QDEL + return INITIALIZE_HINT_NORMAL /** diff --git a/code/game/machinery/howitzer.dm b/code/game/machinery/howitzer.dm index 4bd37ef406f..5f41106066f 100644 --- a/code/game/machinery/howitzer.dm +++ b/code/game/machinery/howitzer.dm @@ -3,9 +3,7 @@ * * Howitzers are a field weapon capable of delivering artillery fire to a location */ -/obj/machinery/howitzer - abstract_type = /obj/machinery/howitzer - +ABSTRACT_TYPE(/obj/machinery/howitzer) name = "howitzer" icon = 'icons/obj/machinery/howitzer/howitzer.dmi' @@ -355,9 +353,7 @@ * * Howitzer ammo casing is a type of ammo casing that can be loaded into howitzers. */ -/obj/item/ammo_casing/howitzer - abstract_type = /obj/item/ammo_casing/howitzer - +ABSTRACT_TYPE(/obj/item/ammo_casing/howitzer) name = "howitzer ammo casing" icon = 'icons/obj/machinery/howitzer/howitzer_ammo.dmi' icon_state = "howitzer_ammo" @@ -381,9 +377,7 @@ * * Howitzer ammo is a type of ammo that can be used in howitzers. */ -/obj/projectile/howitzer - abstract_type = /obj/projectile/howitzer - +ABSTRACT_TYPE(/obj/projectile/howitzer) name = "howitzer ammo" icon = 'icons/obj/machinery/howitzer/howitzer_ammo.dmi' icon_state = "howitzer_ammo" @@ -426,10 +420,8 @@ /* High Explosive */ -/obj/item/ammo_casing/howitzer/high_explosive +ABSTRACT_TYPE(/obj/item/ammo_casing/howitzer/high_explosive) name = "high explosive howitzer ammo" - abstract_type = /obj/item/ammo_casing/howitzer/high_explosive - projectile_type = /obj/projectile/howitzer/high_explosive /** @@ -437,9 +429,7 @@ * * Big boom, many fragments */ -/obj/projectile/howitzer/high_explosive - abstract_type = /obj/projectile/howitzer/high_explosive - +ABSTRACT_TYPE(/obj/projectile/howitzer/high_explosive) name = "high explosive howitzer ammo" ///The minimum number of fragments this HE shell will create @@ -474,9 +464,7 @@ /*#################################### GUNPOWDER PELLETS ####################################*/ -/obj/item/howitzer_pellet - abstract_type = /obj/item/howitzer_pellet - +ABSTRACT_TYPE(/obj/item/howitzer_pellet) name = "howitzer pellet" desc = "A pellet that can be used in a howitzer to propel the projectile." diff --git a/code/game/objects/items/weapons/RFD.dm b/code/game/objects/items/weapons/RFD.dm index 5969e6c070a..3464d69afdf 100644 --- a/code/game/objects/items/weapons/RFD.dm +++ b/code/game/objects/items/weapons/RFD.dm @@ -10,9 +10,7 @@ * * A device used for rapid fabrication of things, built from a compressed matter cartridge */ -/obj/item/rfd - abstract_type = /obj/item/rfd //This is an abstract, use one of the subtypes instead - +ABSTRACT_TYPE(/obj/item/rfd) name = "\improper Rapid Fabrication Device" desc = "A device used for rapid fabrication. The matter decompression matrix is untuned, rendering it useless." icon = 'icons/obj/rfd.dmi' diff --git a/code/game/objects/items/weapons/cigs_lighters.dm b/code/game/objects/items/weapons/cigs_lighters.dm index 1b080963b30..eb6ee65bebc 100644 --- a/code/game/objects/items/weapons/cigs_lighters.dm +++ b/code/game/objects/items/weapons/cigs_lighters.dm @@ -142,8 +142,7 @@ CIGARETTE PACKETS ARE IN FANCY.DM ////////////////// //FINE SMOKABLES// ////////////////// -/obj/item/clothing/mask/smokable - abstract_type = /obj/item/clothing/mask/smokable +ABSTRACT_TYPE(/obj/item/clothing/mask/smokable) name = "smokable item" desc = "You're not sure what this is. You should probably ahelp it." icon = 'icons/obj/smokables.dmi' diff --git a/code/game/objects/items/weapons/implants/implant.dm b/code/game/objects/items/weapons/implants/implant.dm index 57c608806b7..eb1ade2934c 100644 --- a/code/game/objects/items/weapons/implants/implant.dm +++ b/code/game/objects/items/weapons/implants/implant.dm @@ -2,8 +2,7 @@ #define MALFUNCTION_PERMANENT 2 -/obj/item/implant - abstract_type = /obj/item/implant +ABSTRACT_TYPE(/obj/item/implant) name = "implant" icon = 'icons/obj/item/implants.dmi' w_class = WEIGHT_CLASS_TINY diff --git a/code/game/objects/structures/urban.dm b/code/game/objects/structures/urban.dm index 253e2848386..c6d5bd7df18 100644 --- a/code/game/objects/structures/urban.dm +++ b/code/game/objects/structures/urban.dm @@ -67,8 +67,7 @@ name = "[street_name]" desc = "This sign indicates this crossing street is called [street_name]." -/obj/structure/stairs/urban - abstract_type = /obj/structure/stairs/urban +ABSTRACT_TYPE(/obj/structure/stairs/urban) icon = 'icons/obj/structure/urban/ledges.dmi' icon_state = "stairs-single" layer = 2.01 @@ -92,12 +91,11 @@ dir = SOUTH bound_height = 64 -/obj/structure/stairs/urban/road_ramp +ABSTRACT_TYPE(/obj/structure/stairs/urban/road_ramp) name = "inclined asphalt ramp" desc = "A solid asphalt ramp to allow your vehicle to traverse inclines with ease." icon_state = "road-ramp-center" layer = 2.02 - abstract_type = /obj/structure/stairs/urban/road_ramp /obj/structure/stairs/urban/road_ramp/right dir = EAST diff --git a/code/modules/abstract/_abstract.dm b/code/modules/abstract/_abstract.dm index 8c9bf080c84..457933a7b6e 100644 --- a/code/modules/abstract/_abstract.dm +++ b/code/modules/abstract/_abstract.dm @@ -1,11 +1,10 @@ -/obj/abstract +ABSTRACT_TYPE(/obj/abstract) name = "" icon = 'icons/effects/landmarks.dmi' icon_state = "x2" simulated = FALSE density = FALSE anchored = TRUE - abstract_type = /obj/abstract invisibility = INVISIBILITY_ABSTRACT /obj/abstract/Initialize() diff --git a/code/modules/admin/admin.dm b/code/modules/admin/admin.dm index c13cf8fdfe7..d110f0a5de0 100644 --- a/code/modules/admin/admin.dm +++ b/code/modules/admin/admin.dm @@ -1016,27 +1016,36 @@ var/global/enabled_spooking = 0 set desc = "(atom path) Spawn an atom" set name = "Spawn" - if(!check_rights(R_SPAWN)) return + if(!check_rights(R_SPAWN)) + return - var/list/types = typesof(/atom) - var/list/matches = new() + var/list/matches = typesof(/atom) - for(var/path in types) - if(findtext("[path]", object)) - matches += path + for(var/path in matches) + if(!findtext("[path]", object)) + matches -= path - if(matches.len==0) + if(!length(matches)) return var/chosen - if(matches.len==1) + if(length(matches) == 1) chosen = matches[1] else - chosen = input("Select an atom type", "Spawn Atom", matches[1]) as null|anything in matches + //TGUI input gets fucky if the list is too large, so we revert back to standard input in that case + if(length(matches) < 1000) + chosen = tgui_input_list(usr, "Select an atom type", "Spawn Atom", matches) + else + chosen = input("Select an atom type", "Spawn Atom", matches[1]) as null|anything in matches + if(!chosen) return - if(ispath(chosen,/turf)) + if(is_abstract(chosen)) + tgui_alert(usr, "This is an abstract type, you can't spawn it!", "Abstract Type") + return + + if(ispath(chosen, /turf)) var/turf/T = get_turf(usr.loc) T.ChangeTurf(chosen) else diff --git a/code/modules/client/preference_setup/loadout/items/accessories.dm b/code/modules/client/preference_setup/loadout/items/accessories.dm index 0c36c515151..fc8082efb83 100644 --- a/code/modules/client/preference_setup/loadout/items/accessories.dm +++ b/code/modules/client/preference_setup/loadout/items/accessories.dm @@ -1,5 +1,4 @@ -/datum/gear/accessory - abstract_type = /datum/gear/accessory +ABSTRACT_TYPE(/datum/gear/accessory) sort_category = "Accessories" /datum/gear/accessory/locket diff --git a/code/modules/client/preference_setup/loadout/items/computer.dm b/code/modules/client/preference_setup/loadout/items/computer.dm index fed3e136e59..0951e7b9960 100644 --- a/code/modules/client/preference_setup/loadout/items/computer.dm +++ b/code/modules/client/preference_setup/loadout/items/computer.dm @@ -4,8 +4,7 @@ sort_category = "Modular Computers" cost = 2 -/datum/gear/computer/handheld - abstract_type = /datum/gear/computer/handheld +ABSTRACT_TYPE(/datum/gear/computer/handheld) /datum/gear/computer/handheld/tablet display_name = "tablet" @@ -26,8 +25,7 @@ tablets["machinist tablet"] = /obj/item/modular_computer/handheld/preset/supply/machinist gear_tweaks += new /datum/gear_tweak/path(tablets) -/datum/gear/computer/handheld/wristbound - abstract_type = /datum/gear/computer/handheld/wristbound +ABSTRACT_TYPE(/datum/gear/computer/handheld/wristbound) /datum/gear/computer/handheld/wristbound/selection display_name = "wristbound computer selection" diff --git a/code/modules/client/preference_setup/loadout/items/religion.dm b/code/modules/client/preference_setup/loadout/items/religion.dm index 2982a7bd56d..94992b2b014 100644 --- a/code/modules/client/preference_setup/loadout/items/religion.dm +++ b/code/modules/client/preference_setup/loadout/items/religion.dm @@ -1,10 +1,8 @@ -/datum/gear/religion - abstract_type = /datum/gear/religion +ABSTRACT_TYPE(/datum/gear/religion) sort_category = "Religion" flags = GEAR_HAS_DESC_SELECTION -/datum/gear/religion/trinary - abstract_type = /datum/gear/religion/trinary +ABSTRACT_TYPE(/datum/gear/religion/trinary) religion = RELIGION_TRINARY /datum/gear/religion/trinary/mask @@ -105,8 +103,7 @@ slot = slot_tie flags = GEAR_HAS_DESC_SELECTION | GEAR_HAS_COLOR_SELECTION -/datum/gear/religion/dominia - abstract_type = /datum/gear/religion/dominia +ABSTRACT_TYPE(/datum/gear/religion/dominia) religion = RELIGION_MOROZ /datum/gear/religion/dominia/robe @@ -219,8 +216,7 @@ dominiaicon["icon of the martyr, valeria"] = /obj/item/sign/painting_frame/martyr/valeria gear_tweaks += new /datum/gear_tweak/path(dominiaicon) -/datum/gear/religion/assunzione - abstract_type = /datum/gear/religion/assunzione +ABSTRACT_TYPE(/datum/gear/religion/assunzione) religion = RELIGION_LUCEISM /datum/gear/religion/assunzione/scripture diff --git a/code/modules/client/preference_setup/loadout/items/suit.dm b/code/modules/client/preference_setup/loadout/items/suit.dm index ec34e224a66..b2788cd3c3c 100644 --- a/code/modules/client/preference_setup/loadout/items/suit.dm +++ b/code/modules/client/preference_setup/loadout/items/suit.dm @@ -380,8 +380,7 @@ jacket["departmental jacket, service"] = /obj/item/clothing/suit/storage/toggle/serv_dep_jacket gear_tweaks += new /datum/gear_tweak/path(jacket) -/datum/gear/suit/miscellaneous - abstract_type = /datum/gear/suit/miscellaneous +ABSTRACT_TYPE(/datum/gear/suit/miscellaneous) /datum/gear/suit/miscellaneous/peacoat display_name = "peacoat" diff --git a/code/modules/client/preference_setup/loadout/items/xeno/diona.dm b/code/modules/client/preference_setup/loadout/items/xeno/diona.dm index 808880d7943..3514a686d82 100644 --- a/code/modules/client/preference_setup/loadout/items/xeno/diona.dm +++ b/code/modules/client/preference_setup/loadout/items/xeno/diona.dm @@ -8,8 +8,7 @@ flags = GEAR_NO_SELECTION culture_restriction = list(/singleton/origin_item/culture/diona_sol) -/datum/gear/suit/diona - abstract_type = /datum/gear/suit/diona +ABSTRACT_TYPE(/datum/gear/suit/diona) /datum/gear/suit/diona/eternal display_name = "mesh weave robes" @@ -128,8 +127,7 @@ sort_category = "Xenowear - Diona" culture_restriction = list(/singleton/origin_item/culture/dionae_nralakk, /singleton/origin_item/culture/xrim) -/datum/gear/accessory/diona - abstract_type = /datum/gear/accessory/diona +ABSTRACT_TYPE(/datum/gear/accessory/diona) /datum/gear/accessory/diona/skrell_passport display_name = "dionae nralakk federation passport" diff --git a/code/modules/client/preference_setup/loadout/items/xeno/machine.dm b/code/modules/client/preference_setup/loadout/items/xeno/machine.dm index f5c3817bc8d..12ac0f21405 100644 --- a/code/modules/client/preference_setup/loadout/items/xeno/machine.dm +++ b/code/modules/client/preference_setup/loadout/items/xeno/machine.dm @@ -140,8 +140,7 @@ goldendeep["golden deep skirtsuit"] = /obj/item/clothing/under/goldendeep/skirtsuit gear_tweaks += new /datum/gear_tweak/path(goldendeep) -/datum/gear/augment/machine - abstract_type = /datum/gear/augment/machine +ABSTRACT_TYPE(/datum/gear/augment/machine) /datum/gear/augment/machine/gustatorial display_name = "gustatorial centre (tongue)" diff --git a/code/modules/client/preference_setup/loadout/items/xeno/skrell.dm b/code/modules/client/preference_setup/loadout/items/xeno/skrell.dm index 3996c41b14e..9da9eb4d77a 100644 --- a/code/modules/client/preference_setup/loadout/items/xeno/skrell.dm +++ b/code/modules/client/preference_setup/loadout/items/xeno/skrell.dm @@ -1,5 +1,4 @@ -/datum/gear/ears/skrell - abstract_type = /datum/gear/ears/skrell +ABSTRACT_TYPE(/datum/gear/ears/skrell) /datum/gear/ears/skrell/chains //Chains display_name = "headtail chain selection" @@ -298,8 +297,7 @@ var/datum/gear_tweak/social_credit/social_credit_tweak = new() outfit["iqi medical"] = /obj/item/clothing/under/skrell/nralakk/iqi/med gear_tweaks += new /datum/gear_tweak/path(outfit) -/datum/gear/suit/skrell - abstract_type = /datum/gear/suit/skrell +ABSTRACT_TYPE(/datum/gear/suit/skrell) /datum/gear/suit/skrell/jacket display_name = "work jackets" @@ -333,8 +331,8 @@ var/datum/gear_tweak/social_credit/social_credit_tweak = new() jacket["iqi medical"] = /obj/item/clothing/suit/storage/toggle/skrell/iqi/med gear_tweaks += new /datum/gear_tweak/path(jacket) -/datum/gear/accessory/skrell - abstract_type = /datum/gear/accessory/skrell +ABSTRACT_TYPE(/datum/gear/accessory/skrell) + /datum/gear/accessory/skrell/starcoat display_name = "star coat" path = /obj/item/clothing/suit/storage/toggle/skrell/starcoat diff --git a/code/modules/client/preference_setup/loadout/items/xeno/tajara.dm b/code/modules/client/preference_setup/loadout/items/xeno/tajara.dm index 9028655f596..2a9f605307c 100644 --- a/code/modules/client/preference_setup/loadout/items/xeno/tajara.dm +++ b/code/modules/client/preference_setup/loadout/items/xeno/tajara.dm @@ -1,5 +1,4 @@ -/datum/gear/shoes/tajara - abstract_type = /datum/gear/shoes/tajara +ABSTRACT_TYPE(/datum/gear/shoes/tajara) /datum/gear/shoes/tajara/boots display_name = "tajaran boots selection" diff --git a/code/modules/client/preference_setup/loadout/items/xeno/vaurca.dm b/code/modules/client/preference_setup/loadout/items/xeno/vaurca.dm index cdf8f4cd8b4..01845d019f1 100644 --- a/code/modules/client/preference_setup/loadout/items/xeno/vaurca.dm +++ b/code/modules/client/preference_setup/loadout/items/xeno/vaurca.dm @@ -232,8 +232,7 @@ whitelisted = list(SPECIES_VAURCA_WORKER, SPECIES_VAURCA_WARRIOR, SPECIES_VAURCA_BREEDER, SPECIES_VAURCA_BULWARK) flags = GEAR_NO_SELECTION -/datum/gear/ears/vaurca - abstract_type = /datum/gear/ears/vaurca +ABSTRACT_TYPE(/datum/gear/ears/vaurca) /datum/gear/ears/vaurca/rings display_name = "bulwark horn rings" diff --git a/code/modules/clothing/under/pants.dm b/code/modules/clothing/under/pants.dm index 53fd8bad2ec..0698801d382 100644 --- a/code/modules/clothing/under/pants.dm +++ b/code/modules/clothing/under/pants.dm @@ -3,8 +3,7 @@ // // Pants Parent Item -/obj/item/clothing/under/pants - abstract_type = /obj/item/clothing/under/pants +ABSTRACT_TYPE(/obj/item/clothing/under/pants) name = "pants parent item" desc = DESC_PARENT icon = 'icons/obj/item/clothing/under/pants.dmi' diff --git a/code/modules/mob/living/simple_animal/aquatic.dm b/code/modules/mob/living/simple_animal/aquatic.dm index fcace16fbf5..330013c5e6b 100644 --- a/code/modules/mob/living/simple_animal/aquatic.dm +++ b/code/modules/mob/living/simple_animal/aquatic.dm @@ -1,7 +1,5 @@ //For things that swim and don't do much else. -/mob/living/simple_animal/aquatic - abstract_type = /mob/living/simple_animal/aquatic - +ABSTRACT_TYPE(/mob/living/simple_animal/aquatic) name = "aquatic animal" desc = DESC_PARENT icon = 'icons/mob/npc/fish.dmi' diff --git a/code/modules/mob/living/simple_animal/hostile/commanded/commanded.dm b/code/modules/mob/living/simple_animal/hostile/commanded/commanded.dm index 0f5bd594518..78f50750f40 100644 --- a/code/modules/mob/living/simple_animal/hostile/commanded/commanded.dm +++ b/code/modules/mob/living/simple_animal/hostile/commanded/commanded.dm @@ -1,6 +1,4 @@ -/mob/living/simple_animal/hostile/commanded - abstract_type = /mob/living/simple_animal/hostile/commanded - +ABSTRACT_TYPE(/mob/living/simple_animal/hostile/commanded) name = "commanded" var/short_name = null stance = COMMANDED_STOP diff --git a/code/modules/mob/living/simple_animal/hostile/hostile.dm b/code/modules/mob/living/simple_animal/hostile/hostile.dm index b4503c36e8d..b50946d3799 100644 --- a/code/modules/mob/living/simple_animal/hostile/hostile.dm +++ b/code/modules/mob/living/simple_animal/hostile/hostile.dm @@ -1,6 +1,4 @@ -/mob/living/simple_animal/hostile - abstract_type = /mob/living/simple_animal/hostile - +ABSTRACT_TYPE(/mob/living/simple_animal/hostile) faction = "hostile" var/stance = HOSTILE_STANCE_IDLE //Used to determine behavior var/mob/living/target_mob diff --git a/code/modules/mob/living/simple_animal/hostile/retaliate/aquatic.dm b/code/modules/mob/living/simple_animal/hostile/retaliate/aquatic.dm index d2349d0b5d1..ba30508f69e 100644 --- a/code/modules/mob/living/simple_animal/hostile/retaliate/aquatic.dm +++ b/code/modules/mob/living/simple_animal/hostile/retaliate/aquatic.dm @@ -1,7 +1,5 @@ //For things that swim and don't do much else, but also bite! -/mob/living/simple_animal/hostile/retaliate/aquatic - abstract_type = /mob/living/simple_animal/hostile/retaliate/aquatic - +ABSTRACT_TYPE(/mob/living/simple_animal/hostile/retaliate/aquatic) name = "aquatic animal" desc = DESC_PARENT icon = 'icons/mob/npc/fish.dmi' diff --git a/code/modules/mob/living/simple_animal/hostile/retaliate/retaliate.dm b/code/modules/mob/living/simple_animal/hostile/retaliate/retaliate.dm index e61865ac6c3..1f205f81a96 100644 --- a/code/modules/mob/living/simple_animal/hostile/retaliate/retaliate.dm +++ b/code/modules/mob/living/simple_animal/hostile/retaliate/retaliate.dm @@ -1,6 +1,4 @@ -/mob/living/simple_animal/hostile/retaliate - abstract_type = /mob/living/simple_animal/hostile/retaliate - +ABSTRACT_TYPE(/mob/living/simple_animal/hostile/retaliate) var/list/enemies = list() /mob/living/simple_animal/hostile/retaliate/Destroy() diff --git a/code/modules/power/apc.dm b/code/modules/power/apc.dm index 9f6b189ccd2..da4b5c9fbaf 100644 --- a/code/modules/power/apc.dm +++ b/code/modules/power/apc.dm @@ -68,8 +68,7 @@ // may be opened to change power cell // three different channels (lighting/equipment/environ) - may each be set to on, off, or auto -/obj/machinery/power/apc - abstract_type = /obj/machinery/power/apc //This is an abstract representation of the APC, use one of the subtypes for the actual APC +ABSTRACT_TYPE(/obj/machinery/power/apc) name = "area power controller" desc = "A control terminal for the area electrical systems." desc_info = "An APC (Area Power Controller) regulates and supplies backup power for the area they are in. Their power channels are divided \ diff --git a/code/modules/reagents/Chemistry-Reagents/Chemistry-Reagents-Dispenser.dm b/code/modules/reagents/Chemistry-Reagents/Chemistry-Reagents-Dispenser.dm index 31bb6307655..831d903ad56 100644 --- a/code/modules/reagents/Chemistry-Reagents/Chemistry-Reagents-Dispenser.dm +++ b/code/modules/reagents/Chemistry-Reagents/Chemistry-Reagents-Dispenser.dm @@ -120,8 +120,7 @@ * * Parent class for all alcoholic reagents, though this one shouldn't be used anywhere */ -/singleton/reagent/alcohol - abstract_type = /singleton/reagent/alcohol +ABSTRACT_TYPE(/singleton/reagent/alcohol) name = null description = DESC_PARENT reagent_state = LIQUID diff --git a/code/modules/reagents/reagent_containers/food/snacks/cultural/human.dm b/code/modules/reagents/reagent_containers/food/snacks/cultural/human.dm index 9b1e72c51c3..42172dade77 100644 --- a/code/modules/reagents/reagent_containers/food/snacks/cultural/human.dm +++ b/code/modules/reagents/reagent_containers/food/snacks/cultural/human.dm @@ -501,8 +501,7 @@ // Eridani -/obj/item/reagent_containers/food/snacks/bowl - abstract_type = /obj/item/reagent_containers/food/snacks/bowl +ABSTRACT_TYPE(/obj/item/reagent_containers/food/snacks/bowl) name = "a bowl of item" desc = "If you're seeing this, something has gone wrong D:" icon = 'icons/obj/item/reagent_containers/food/cultural/human.dmi' diff --git a/code/modules/reagents/reagent_containers/food/snacks/noodles.dm b/code/modules/reagents/reagent_containers/food/snacks/noodles.dm index 0c451c23b67..dca3c4cf7d9 100644 --- a/code/modules/reagents/reagent_containers/food/snacks/noodles.dm +++ b/code/modules/reagents/reagent_containers/food/snacks/noodles.dm @@ -140,8 +140,7 @@ reagent_data = list(/singleton/reagent/nutriment = list("spaghetti" = 5, "seasoned vegetables" = 4), /singleton/reagent/nutriment/protein= list ("ground beef" = 5)) bitesize = 3 -/obj/item/reagent_containers/food/snacks/ravioli - abstract_type = /obj/item/reagent_containers/food/snacks/ravioli +ABSTRACT_TYPE(/obj/item/reagent_containers/food/snacks/ravioli) icon = 'icons/obj/item/reagent_containers/food/noodles.dmi' icon_state = "ravioli" trash = /obj/item/trash/plate diff --git a/code/modules/weather/weather_fsm_state_transitions.dm b/code/modules/weather/weather_fsm_state_transitions.dm index c8099d1f914..32b2f48b703 100644 --- a/code/modules/weather/weather_fsm_state_transitions.dm +++ b/code/modules/weather/weather_fsm_state_transitions.dm @@ -1,5 +1,4 @@ -/singleton/state_transition/weather - abstract_type = /singleton/state_transition/weather +ABSTRACT_TYPE(/singleton/state_transition/weather) var/likelihood_weighting = 100 /singleton/state_transition/weather/is_open(datum/holder) diff --git a/code/modules/weather/weather_fsm_states.dm b/code/modules/weather/weather_fsm_states.dm index d9bc8c8e2e5..fd3006952dc 100644 --- a/code/modules/weather/weather_fsm_states.dm +++ b/code/modules/weather/weather_fsm_states.dm @@ -1,7 +1,4 @@ -/singleton/state/weather - - abstract_type = /singleton/state/weather - +ABSTRACT_TYPE(/singleton/state/weather) var/name = "Undefined" var/descriptor = "The weather is undefined." diff --git a/code/unit_tests/create_and_destroy.dm b/code/unit_tests/create_and_destroy.dm index 073aed7715b..84430f265f5 100644 --- a/code/unit_tests/create_and_destroy.dm +++ b/code/unit_tests/create_and_destroy.dm @@ -185,6 +185,10 @@ GLOBAL_VAR_INIT(running_create_and_destroy, FALSE) GLOB.running_create_and_destroy = TRUE for(var/type_path in typesof(/atom/movable, /turf) - ignore) //No areas please + //No abstract types + if(is_abstract(type_path)) + continue + TEST_DEBUG("[name]: now creating and destroying: [type_path]") if(ispath(type_path, /turf)) diff --git a/code/unit_tests/unit_test.dm b/code/unit_tests/unit_test.dm index e84c2418cfd..6197c463241 100644 --- a/code/unit_tests/unit_test.dm +++ b/code/unit_tests/unit_test.dm @@ -41,8 +41,7 @@ var/ascii_reset = "[ascii_esc]\[0m" // We list these here so we can remove them from the for loop running this. // Templates aren't intended to be ran but just serve as a way to create child objects of it with inheritable tests for quick test creation. -/datum/unit_test - abstract_type = /datum/unit_test +ABSTRACT_TYPE(/datum/unit_test) var/name = "template - should not be ran." var/disabled = 0 // If we want to keep a unit test in the codebase but not run it for some reason. var/async = 0 // If the check can be left to do it's own thing, you must define a check_result() proc if you use this. diff --git a/html/changelogs/fluffyghost-reabstracting.yml b/html/changelogs/fluffyghost-reabstracting.yml new file mode 100644 index 00000000000..2b8a260e7df --- /dev/null +++ b/html/changelogs/fluffyghost-reabstracting.yml @@ -0,0 +1,63 @@ +################################ +# Example Changelog File +# +# Note: This file, and files beginning with ".", and files that don't end in ".yml" will not be read. If you change this file, you will look really dumb. +# +# Your changelog will be merged with a master changelog. (New stuff added only, and only on the date entry for the day it was merged.) +# When it is, any changes listed below will disappear. +# +# Valid Prefixes: +# bugfix +# - (fixes bugs) +# wip +# - (work in progress) +# qol +# - (quality of life) +# soundadd +# - (adds a sound) +# sounddel +# - (removes a sound) +# rscadd +# - (adds a feature) +# rscdel +# - (removes a feature) +# imageadd +# - (adds an image or sprite) +# imagedel +# - (removes an image or sprite) +# spellcheck +# - (fixes spelling or grammar) +# experiment +# - (experimental change) +# balance +# - (balance changes) +# code_imp +# - (misc internal code change) +# refactor +# - (refactors code) +# config +# - (makes a change to the config files) +# admin +# - (makes changes to administrator tools) +# server +# - (miscellaneous changes to server) +################################# + +# Your name. +author: FluffyGhost + +# Optional: Remove this file after generating master changelog. Useful for PR changelogs that won't get used again. +delete-after: True + +# Any changes you've made. See valid prefix list above. +# INDENT WITH TWO SPACES. NOT TABS. SPACES. +# SCREW THIS UP AND IT WON'T WORK. +# Also, this gets changed to [] after reading. Just remove the brackets when you add new shit. +# Please surround your changes in double quotes ("). It works without them, but if you use certain characters it screws up compiling. The quotes will not show up in the changelog. +changes: + - refactor: "Refactored the abstract meta propriety into defines." + - refactor: "It's now more easy to spot/see abstract types thanks to the macro that defines them." + - rscadd: "Added a check on initialization of atoms to avoid spawning abstract types." + - rscadd: "Made the spawn_atom proc check for abstractness." + - rscadd: "Made the spawn_atom proc use tgui_list for types list shorter than 1000 elements, which enables to search in them. It's too laggy on larger lists so above 1000 it uses the builtin input." + - refactor: "Made the spawn_atom use a list subtraction instead of a double list, it's lighter on memory and processing." diff --git a/maps/away/away_site/shady/shady.dmm b/maps/away/away_site/shady/shady.dmm index 2c11f9aff9e..ff5d22a833e 100644 --- a/maps/away/away_site/shady/shady.dmm +++ b/maps/away/away_site/shady/shady.dmm @@ -242,7 +242,6 @@ /obj/structure/closet/cabinet, /obj/item/clothing/under/pants/camo, /obj/item/clothing/under/pants/mustang, -/obj/item/clothing/under/pants, /obj/item/clothing/under/pants/tacticool, /obj/item/clothing/under/pants/track, /obj/effect/decal/cleanable/dirt, diff --git a/maps/away/away_sites.dm b/maps/away/away_sites.dm index b8308660ad5..839e9a2e651 100644 --- a/maps/away/away_sites.dm +++ b/maps/away/away_sites.dm @@ -1,7 +1,6 @@ // Hey! Listen! Update \config\away_site_blacklist.txt with your new ruins! -/datum/map_template/ruin/away_site - abstract_type = /datum/map_template/ruin/away_site +ABSTRACT_TYPE(/datum/map_template/ruin/away_site) prefix = "maps/away/" /// If null, ignored, and exoplanet generation is not used. diff --git a/maps/random_ruins/exoplanets/exoplanet_ruins.dm b/maps/random_ruins/exoplanets/exoplanet_ruins.dm index ddbaf5ea4e8..5d66146359e 100644 --- a/maps/random_ruins/exoplanets/exoplanet_ruins.dm +++ b/maps/random_ruins/exoplanets/exoplanet_ruins.dm @@ -1,6 +1,4 @@ -/datum/map_template/ruin/exoplanet - abstract_type = /datum/map_template/ruin/exoplanet - +ABSTRACT_TYPE(/datum/map_template/ruin/exoplanet) prefix = "maps/random_ruins/exoplanets/" template_flags = TEMPLATE_FLAG_NO_RUINS spawn_weight = 1 diff --git a/maps/random_ruins/space_ruins/space_ruins.dm b/maps/random_ruins/space_ruins/space_ruins.dm index 00b7763dc3e..a5e3520612f 100644 --- a/maps/random_ruins/space_ruins/space_ruins.dm +++ b/maps/random_ruins/space_ruins/space_ruins.dm @@ -1,8 +1,6 @@ // Hey! Listen! Update \config\space_ruin_blacklist.txt with your new ruins! -/datum/map_template/ruin/space - abstract_type = /datum/map_template/ruin/space - +ABSTRACT_TYPE(/datum/map_template/ruin/space) prefix = "maps/random_ruins/space_ruins/" spawn_cost = 1