diff --git a/code/__DEFINES/dcs/datum_signals.dm b/code/__DEFINES/dcs/datum_signals.dm
index 650c91a12e3..6850155f345 100644
--- a/code/__DEFINES/dcs/datum_signals.dm
+++ b/code/__DEFINES/dcs/datum_signals.dm
@@ -8,7 +8,7 @@
/// when a component is added to a datum: (/datum/component)
#define COMSIG_COMPONENT_ADDED "component_added"
-/// before a component is removed from a datum because of RemoveComponent: (/datum/component)
+/// before a component is removed from a datum because of UnlinkComponent: (/datum/component)
#define COMSIG_COMPONENT_REMOVING "component_removing"
/// before a datum's Destroy() is called: (force), returning a nonzero value will cancel the qdel operation
#define COMSIG_PARENT_PREQDELETED "parent_preqdeleted"
diff --git a/code/controllers/subsystem/SSstatpanel.dm b/code/controllers/subsystem/SSstatpanel.dm
index 20804e50b5f..b918eb8a4e7 100644
--- a/code/controllers/subsystem/SSstatpanel.dm
+++ b/code/controllers/subsystem/SSstatpanel.dm
@@ -294,7 +294,7 @@ SUBSYSTEM_DEF(statpanels)
actively_tracking = TRUE
/datum/object_window_info/proc/stop_turf_tracking()
- qdel(GetComponent(/datum/component/connect_mob_behalf))
+ DeleteComponent(/datum/component/connect_mob_behalf)
actively_tracking = FALSE
/datum/object_window_info/proc/on_mob_move(mob/source)
diff --git a/code/datums/components/_component.dm b/code/datums/components/_component.dm
index cbf6e6940e7..d525b295db3 100644
--- a/code/datums/components/_component.dm
+++ b/code/datums/components/_component.dm
@@ -441,6 +441,14 @@
return new_comp
return old_comp
+/**
+ * Removes the component from the datum
+ */
+/datum/proc/DeleteComponent(component_to_nuke)
+ var/datum/component/removing = GetComponent(component_to_nuke)
+ if(istype(removing, component_to_nuke) && !QDELETED(removing))
+ qdel(removing)
+
/**
* Get existing component of type, or create it and return a reference to it
*
@@ -458,7 +466,7 @@
/**
* Removes the component from parent, ends up with a null parent
*/
-/datum/component/proc/RemoveComponent()
+/datum/component/proc/UnlinkComponent()
if(!parent)
return
var/datum/old_parent = parent
@@ -467,6 +475,13 @@
parent = null
SEND_SIGNAL(old_parent, COMSIG_COMPONENT_REMOVING, src)
+/**
+ * Deletes the component and removes it from parent.
+ */
+/datum/component/proc/RemoveComponent() // This really is just a wrapper to pretend that we're using sane procs to fully remove a component
+ if(!QDELETED(src))
+ qdel(src)
+
/**
* Transfer this component to another parent
*
@@ -479,7 +494,7 @@
if(!target || target.parent == src)
return
if(target.parent)
- target.RemoveComponent()
+ target.UnlinkComponent()
target.parent = src
var/result = target.PostTransfer()
switch(result)
diff --git a/code/datums/components/surgery_initiator.dm b/code/datums/components/surgery_initiator.dm
index 54fd99d2cf8..9f476ba089d 100644
--- a/code/datums/components/surgery_initiator.dm
+++ b/code/datums/components/surgery_initiator.dm
@@ -67,8 +67,8 @@
SIGNAL_HANDLER // COMSIG_ATOM_UPDATE_SHARPNESS
var/obj/item/P = parent
if(!P.sharp)
+ UnlinkComponent()
RemoveComponent()
- qdel(src)
/// Does the surgery initiation.
/datum/component/surgery_initiator/proc/initiate_surgery_moment(datum/source, atom/target, mob/user)
diff --git a/code/datums/diseases/zombie_virus.dm b/code/datums/diseases/zombie_virus.dm
index 1bd7beb6681..37b96d68420 100644
--- a/code/datums/diseases/zombie_virus.dm
+++ b/code/datums/diseases/zombie_virus.dm
@@ -148,7 +148,7 @@
/datum/disease/zombie/cure()
affected_mob.mind?.remove_antag_datum(/datum/antagonist/zombie)
REMOVE_TRAIT(affected_mob, TRAIT_I_WANT_BRAINS, ZOMBIE_TRAIT)
- qdel(affected_mob.GetComponent(/datum/component/zombie_regen))
+ affected_mob.DeleteComponent(/datum/component/zombie_regen)
affected_mob.med_hud_set_health()
affected_mob.med_hud_set_status()
return ..()
diff --git a/code/datums/outfits/outfit_admin.dm b/code/datums/outfits/outfit_admin.dm
index 22963dd84aa..8dc1e28d24e 100644
--- a/code/datums/outfits/outfit_admin.dm
+++ b/code/datums/outfits/outfit_admin.dm
@@ -1572,7 +1572,8 @@
if(istype(I))
apply_to_card(I, H, list(ACCESS_MAINT_TUNNELS), "Solar Federation Infilitrator", "lifetimeid")
- qdel(H.GetComponent(/datum/component/footstep)) // they're literally stealth
+ H.DeleteComponent(/datum/component/footstep)
+
var/datum/martial_art/cqc/CQC = new()
CQC.teach(H)
diff --git a/code/game/atoms.dm b/code/game/atoms.dm
index 401a22ead04..d623ec9dc29 100644
--- a/code/game/atoms.dm
+++ b/code/game/atoms.dm
@@ -1002,7 +1002,7 @@ GLOBAL_LIST_EMPTY(blood_splatter_icons)
if(!QDELETED(healthy_green_glow))
healthy_green_glow.strength = max(0, (healthy_green_glow.strength - (RAD_BACKGROUND_RADIATION * clean_factor)))
if(healthy_green_glow.strength <= RAD_BACKGROUND_RADIATION)
- qdel(healthy_green_glow)
+ healthy_green_glow.RemoveComponent()
/obj/effect/decal/cleanable/blood/clean_blood(radiation_clean = FALSE)
return // While this seems nonsensical, clean_blood isn't supposed to be used like this on a blood decal.
diff --git a/code/game/atoms_movable.dm b/code/game/atoms_movable.dm
index e6d9a5a3af3..ba00d876622 100644
--- a/code/game/atoms_movable.dm
+++ b/code/game/atoms_movable.dm
@@ -677,9 +677,7 @@
/// Easy way to remove the component when the fun has been played out
/atom/movable/proc/stop_deadchat_plays()
- var/datum/component/deadchat_control/comp = GetComponent(/datum/component/deadchat_control)
- if(!QDELETED(comp))
- qdel(comp)
+ DeleteComponent(/datum/component/deadchat_control)
/atom/movable/vv_get_dropdown()
. = ..()
diff --git a/code/game/jobs/job/support.dm b/code/game/jobs/job/support.dm
index 7ea202bf802..fb6e69fdb87 100644
--- a/code/game/jobs/job/support.dm
+++ b/code/game/jobs/job/support.dm
@@ -473,7 +473,7 @@
if(visualsOnly)
return
- qdel(H.GetComponent(/datum/component/footstep))
+ H.DeleteComponent(/datum/component/footstep)
/datum/outfit/job/mime/on_mind_initialize(mob/living/carbon/human/H)
. = ..()
diff --git a/code/game/mecha/equipment/tools/work_tools.dm b/code/game/mecha/equipment/tools/work_tools.dm
index 7d8f64ed04e..934c7c364bf 100644
--- a/code/game/mecha/equipment/tools/work_tools.dm
+++ b/code/game/mecha/equipment/tools/work_tools.dm
@@ -479,10 +479,9 @@
/obj/item/kinetic_crusher/mecha/Initialize(mapload)
. = ..()
- var/datum/component/unwanted = GetComponent(/datum/component/parry)
- unwanted?.RemoveComponent()
- unwanted = GetComponent(/datum/component/two_handed)
- unwanted?.RemoveComponent()
+ DeleteComponent(/datum/component/parry)
+ DeleteComponent(/datum/component/two_handed)
+
/// This is only for the sake of internal checks in the crusher itself.
ADD_TRAIT(src, TRAIT_WIELDED, "mech[UID()]")
diff --git a/code/game/objects/items/weapons/grenades/grenade.dm b/code/game/objects/items/weapons/grenades/grenade.dm
index b2e0fee35fd..212088822e7 100644
--- a/code/game/objects/items/weapons/grenades/grenade.dm
+++ b/code/game/objects/items/weapons/grenades/grenade.dm
@@ -29,7 +29,7 @@
. += "The fuze is set to [det_time / 10] second\s."
else
. += "[src] is set for instant detonation."
-
+
if(modifiable_timer)
. += "Use a screwdriver to modify the time on the fuze."
else
@@ -125,8 +125,4 @@
if(!HAS_TRAIT(src, TRAIT_CMAGGED))
return
REMOVE_TRAIT(src, TRAIT_CMAGGED, "cmagged grenade")
- var/datum/component/bomberang = GetComponent(/datum/component/boomerang)
- if(!bomberang)
- return
- bomberang.RemoveComponent()
- qdel(bomberang)
+ DeleteComponent(/datum/component/boomerang)
diff --git a/code/game/objects/structures/aliens.dm b/code/game/objects/structures/aliens.dm
index 41affd7a4fc..80e9ae91f70 100644
--- a/code/game/objects/structures/aliens.dm
+++ b/code/game/objects/structures/aliens.dm
@@ -524,7 +524,8 @@
icon_state = "egg_hatched"
flick("egg_opening", src)
status = BURSTING
- qdel(GetComponent(/datum/component/proximity_monitor))
+ DeleteComponent(/datum/component/proximity_monitor)
+
addtimer(CALLBACK(src, PROC_REF(hatch)), 1.5 SECONDS)
///We now check HOW the hugger is hatching, kill carried from Burst() and obj_break()
diff --git a/code/modules/awaymissions/mission_code/ruins/telecomns.dm b/code/modules/awaymissions/mission_code/ruins/telecomns.dm
index d151dfa849e..117bd99d7e5 100644
--- a/code/modules/awaymissions/mission_code/ruins/telecomns.dm
+++ b/code/modules/awaymissions/mission_code/ruins/telecomns.dm
@@ -430,7 +430,8 @@ GLOBAL_LIST_EMPTY(telecomms_trap_tank)
/obj/structure/environmental_storytelling_holopad/proc/start_message(mob/living/carbon/human/H)
activated = TRUE
- qdel(GetComponent(/datum/component/proximity_monitor))
+ DeleteComponent(/datum/component/proximity_monitor)
+
icon_state = "holopad1"
update_icon(UPDATE_OVERLAYS)
var/obj/effect/overlay/hologram = new(get_turf(src))
diff --git a/code/modules/events/brand_intelligence.dm b/code/modules/events/brand_intelligence.dm
index c8612e16346..ac95ae68fda 100644
--- a/code/modules/events/brand_intelligence.dm
+++ b/code/modules/events/brand_intelligence.dm
@@ -90,7 +90,8 @@
saved.shoot_inventory = FALSE
saved.aggressive = FALSE
if(saved.tiltable)
- qdel(saved.GetComponent(/datum/component/proximity_monitor))
+ saved.DeleteComponent(/datum/component/proximity_monitor)
+
if(originMachine)
originMachine.speak("I am... vanquished. My people will remem...ber...meeee.")
originMachine.visible_message("[originMachine] beeps and seems lifeless.")
diff --git a/code/modules/mob/living/carbon/alien/special/facehugger.dm b/code/modules/mob/living/carbon/alien/special/facehugger.dm
index 4b54760533a..191ae690666 100644
--- a/code/modules/mob/living/carbon/alien/special/facehugger.dm
+++ b/code/modules/mob/living/carbon/alien/special/facehugger.dm
@@ -203,7 +203,7 @@
icon_state = "[initial(icon_state)]_dead"
item_state = "facehugger_inactive"
stat = DEAD
- qdel(GetComponent(/datum/component/proximity_monitor))
+ DeleteComponent(/datum/component/proximity_monitor)
visible_message("[src] curls up into a ball!")
diff --git a/code/modules/mob/living/carbon/human/human_mob.dm b/code/modules/mob/living/carbon/human/human_mob.dm
index c73e1df7734..4c914284b5c 100644
--- a/code/modules/mob/living/carbon/human/human_mob.dm
+++ b/code/modules/mob/living/carbon/human/human_mob.dm
@@ -21,7 +21,7 @@
if(!mind)
return FALSE
if(mind.miming)
- qdel(GetComponent(/datum/component/footstep))
+ DeleteComponent(/datum/component/footstep)
return TRUE
/**
diff --git a/code/modules/mob/living/simple_animal/hostile/mining/elites/elite.dm b/code/modules/mob/living/simple_animal/hostile/mining/elites/elite.dm
index 88c8bb0a212..fa47cc5ff25 100644
--- a/code/modules/mob/living/simple_animal/hostile/mining/elites/elite.dm
+++ b/code/modules/mob/living/simple_animal/hostile/mining/elites/elite.dm
@@ -413,7 +413,7 @@ While using this makes the system rely on OnFire, it still gives options for tim
text += "If teleported to the Station by jaunter, you are allowed to attack people on Station, until you get killed."
to_chat(mychild, text.Join(" "))
- qdel(GetComponent(/datum/component/proximity_monitor))
+ DeleteComponent(/datum/component/proximity_monitor)
/obj/item/tumor_shard
name = "tumor shard"
diff --git a/code/modules/mod/modules/modules_antag.dm b/code/modules/mod/modules/modules_antag.dm
index 3bfdf62ccb6..909cb209e50 100644
--- a/code/modules/mod/modules/modules_antag.dm
+++ b/code/modules/mod/modules/modules_antag.dm
@@ -506,7 +506,7 @@
/obj/item/mod/module/energy_shield/on_suit_deactivation(deleting = FALSE)
var/datum/component/shielded/shield = mod.GetComponent(/datum/component/shielded)
charges = shield.current_charges
- qdel(shield)
+ shield.RemoveComponent()
UnregisterSignal(mod.wearer, COMSIG_HUMAN_CHECK_SHIELDS)
/obj/item/mod/module/energy_shield/proc/shield_reaction(mob/living/carbon/human/owner,
@@ -581,7 +581,7 @@
return FALSE
var/datum/component/shielded/shield = mod.GetComponent(/datum/component/shielded)
charges = shield.current_charges
- qdel(shield)
+ shield.RemoveComponent()
UnregisterSignal(mod.wearer, COMSIG_HUMAN_CHECK_SHIELDS)
REMOVE_TRAIT(mod.wearer, TRAIT_SHOCKIMMUNE, UNIQUE_TRAIT_SOURCE(src))
diff --git a/code/modules/mod/modules/modules_service.dm b/code/modules/mod/modules/modules_service.dm
index 69720a0e354..617ef90756c 100644
--- a/code/modules/mod/modules/modules_service.dm
+++ b/code/modules/mod/modules/modules_service.dm
@@ -38,7 +38,8 @@
/obj/item/mod/module/waddle/on_suit_deactivation(deleting = FALSE)
if(!deleting)
- qdel(mod.boots.GetComponent(/datum/component/squeak))
+ mod.boots.DeleteComponent(/datum/component/squeak)
+
mod.wearer.RemoveElement(/datum/element/waddling)
//Boot heating - dries floors like galoshes/dry
diff --git a/code/modules/reagents/chemistry/reagents/misc_reagents.dm b/code/modules/reagents/chemistry/reagents/misc_reagents.dm
index 2a8117cf019..223bd2f1ae7 100644
--- a/code/modules/reagents/chemistry/reagents/misc_reagents.dm
+++ b/code/modules/reagents/chemistry/reagents/misc_reagents.dm
@@ -514,8 +514,8 @@
if(M.mind?.assigned_role != "Clown")
REMOVE_TRAIT(M, TRAIT_COMIC_SANS, id)
M.RemoveElement(/datum/element/waddling)
- qdel(M.GetComponent(/datum/component/squeak))
+ M.DeleteComponent(/datum/component/squeak)
/datum/reagent/royal_bee_jelly
name = "Royal bee jelly"