diff --git a/code/datums/components/README.md b/code/datums/components/README.md index 026b387e2707..110b3626a3a1 100644 --- a/code/datums/components/README.md +++ b/code/datums/components/README.md @@ -26,7 +26,7 @@ Stands have a lot of procs which mimic mob procs. Rather than inserting hooks fo ### Defines -1. `COMPONENT_INCOMPATIBLE` Return this from `/datum/component/Initialize` or `datum/component/OnTransfer` to have the component be deleted if it's applied to an incorrect type. `parent` must not be modified if this is to be returned. +1. `COMPONENT_INCOMPATIBLE` Return this from `/datum/component/Initialize` or `datum/component/OnTransfer` to have the component be deleted if it's applied to an incorrect type. `parent` must not be modified if this is to be returned. This will be noted in the runtime logs ### Vars diff --git a/code/datums/components/_component.dm b/code/datums/components/_component.dm index 423dcf82df95..4076918ecf9d 100644 --- a/code/datums/components/_component.dm +++ b/code/datums/components/_component.dm @@ -10,7 +10,7 @@ var/list/arguments = args.Copy(2) if(Initialize(arglist(arguments)) == COMPONENT_INCOMPATIBLE) qdel(src, TRUE, TRUE) - CRASH("Incompatible [type] assigned to a [P]!") + CRASH("Incompatible [type] assigned to a [P.type]!") _JoinParent(P) @@ -233,7 +233,9 @@ //if we're taking to the same thing no need for anything return if(C.OnTransfer(src) == COMPONENT_INCOMPATIBLE) + var/c_type = C.type qdel(C) + CRASH("Incompatible [c_type] transfer attempt to a [type]!") return C._RemoveFromParent() helicopter.SendSignal(COMSIG_COMPONENT_REMOVING, C) diff --git a/code/datums/components/beauty.dm b/code/datums/components/beauty.dm index 4dbfca4014e6..f6031046bd17 100644 --- a/code/datums/components/beauty.dm +++ b/code/datums/components/beauty.dm @@ -3,8 +3,7 @@ /datum/component/beauty/Initialize(beautyamount) if(!ismovableatom(parent)) - . = COMPONENT_INCOMPATIBLE - CRASH("Someone put a beauty component on a non-atom/movable, not everything can be pretty.") + return COMPONENT_INCOMPATIBLE beauty = beautyamount RegisterSignal(COMSIG_ENTER_AREA, .proc/enter_area) RegisterSignal(COMSIG_EXIT_AREA, .proc/exit_area) diff --git a/code/datums/components/cleaning.dm b/code/datums/components/cleaning.dm index 9566b5faabd6..6f2f08c61775 100644 --- a/code/datums/components/cleaning.dm +++ b/code/datums/components/cleaning.dm @@ -3,8 +3,7 @@ /datum/component/cleaning/Initialize() if(!ismovableatom(parent)) - . = COMPONENT_INCOMPATIBLE - CRASH("[type] added to a [parent.type]") + return COMPONENT_INCOMPATIBLE RegisterSignal(list(COMSIG_MOVABLE_MOVED), .proc/Clean) /datum/component/cleaning/proc/Clean() diff --git a/code/datums/components/construction.dm b/code/datums/components/construction.dm index 74b6f54a6c4c..c9cf47e221d3 100644 --- a/code/datums/components/construction.dm +++ b/code/datums/components/construction.dm @@ -13,8 +13,7 @@ /datum/component/construction/Initialize() if(!isatom(parent)) - . = COMPONENT_INCOMPATIBLE - CRASH("A construction component was applied incorrectly to non-atom: [parent.type].") + return COMPONENT_INCOMPATIBLE RegisterSignal(COMSIG_PARENT_EXAMINE, .proc/examine) RegisterSignal(COMSIG_PARENT_ATTACKBY,.proc/action) diff --git a/code/datums/components/decal.dm b/code/datums/components/decal.dm index 6b7f846e8337..0d8613bd86e3 100644 --- a/code/datums/components/decal.dm +++ b/code/datums/components/decal.dm @@ -7,8 +7,7 @@ /datum/component/decal/Initialize(_icon, _icon_state, _dir, _cleanable=CLEAN_GOD, _color, _layer=TURF_LAYER, _description) if(!isatom(parent) || !generate_appearance(_icon, _icon_state, _dir, _layer, _color)) - . = COMPONENT_INCOMPATIBLE - CRASH("A turf decal was applied incorrectly to [parent.type]: icon:[_icon ? _icon : "none"] icon_state:[_icon_state ? _icon_state : "none"]") + return COMPONENT_INCOMPATIBLE description = _description cleanable = _cleanable diff --git a/code/datums/components/decals/blood.dm b/code/datums/components/decals/blood.dm index 5a14aecd527a..e69f94358c45 100644 --- a/code/datums/components/decals/blood.dm +++ b/code/datums/components/decals/blood.dm @@ -3,8 +3,7 @@ /datum/component/decal/blood/Initialize(_icon, _icon_state, _dir, _cleanable=CLEAN_STRENGTH_BLOOD, _color, _layer=ABOVE_OBJ_LAYER) if(!isitem(parent)) - . = COMPONENT_INCOMPATIBLE - CRASH("Warning: Blood decal attempted to be added to non-item of type [parent.type]") + return COMPONENT_INCOMPATIBLE . = ..() RegisterSignal(COMSIG_ATOM_GET_EXAMINE_NAME, .proc/get_examine_name) diff --git a/code/datums/components/forensics.dm b/code/datums/components/forensics.dm index 417525ab08a9..33456e6e98e0 100644 --- a/code/datums/components/forensics.dm +++ b/code/datums/components/forensics.dm @@ -15,8 +15,7 @@ /datum/component/forensics/Initialize(new_fingerprints, new_hiddenprints, new_blood_DNA, new_fibers) if(!isatom(parent)) - . = COMPONENT_INCOMPATIBLE - CRASH("Forensics datum applied incorrectly to non-atom of type [parent.type]!") + return COMPONENT_INCOMPATIBLE fingerprints = new_fingerprints hiddenprints = new_hiddenprints blood_DNA = new_blood_DNA diff --git a/code/datums/components/jousting.dm b/code/datums/components/jousting.dm index 8348e59fe2e8..679d37738b16 100644 --- a/code/datums/components/jousting.dm +++ b/code/datums/components/jousting.dm @@ -18,8 +18,7 @@ /datum/component/jousting/Initialize() if(!isitem(parent)) - . = COMPONENT_INCOMPATIBLE - CRASH("Warning: Jousting component incorrectly applied to invalid parent type [parent.type]") + return COMPONENT_INCOMPATIBLE RegisterSignal(COMSIG_ITEM_EQUIPPED, .proc/on_equip) RegisterSignal(COMSIG_ITEM_DROPPED, .proc/on_drop) RegisterSignal(COMSIG_ITEM_ATTACK, .proc/on_attack) diff --git a/code/datums/components/knockoff.dm b/code/datums/components/knockoff.dm index 35d1e5423e09..60b86f01d2aa 100644 --- a/code/datums/components/knockoff.dm +++ b/code/datums/components/knockoff.dm @@ -7,8 +7,7 @@ /datum/component/knockoff/Initialize(knockoff_chance,zone_override,slots_knockoffable) if(!isitem(parent)) - . = COMPONENT_INCOMPATIBLE - CRASH("Knockoff component misuse") + return COMPONENT_INCOMPATIBLE RegisterSignal(COMSIG_ITEM_EQUIPPED,.proc/OnEquipped) RegisterSignal(COMSIG_ITEM_DROPPED,.proc/OnDropped) diff --git a/code/datums/components/lockon_aiming.dm b/code/datums/components/lockon_aiming.dm index 017e7ea8ebc3..02dfb8eaa053 100644 --- a/code/datums/components/lockon_aiming.dm +++ b/code/datums/components/lockon_aiming.dm @@ -22,8 +22,7 @@ /datum/component/lockon_aiming/Initialize(range, list/typecache, amount, list/immune, datum/callback/when_locked, icon, icon_state, datum/callback/target_callback) if(!ismob(parent)) - . = COMPONENT_INCOMPATIBLE - CRASH("Lockon aiming component attempted to be added to a non mob!") + return COMPONENT_INCOMPATIBLE if(target_callback) can_target_callback = target_callback else diff --git a/code/datums/components/mood.dm b/code/datums/components/mood.dm index 95f8f65bb64b..8714b41f05e3 100644 --- a/code/datums/components/mood.dm +++ b/code/datums/components/mood.dm @@ -10,8 +10,7 @@ /datum/component/mood/Initialize() if(!isliving(parent)) - . = COMPONENT_INCOMPATIBLE - CRASH("Some good for nothing loser put a mood component on something that isn't even a living mob.") + return COMPONENT_INCOMPATIBLE START_PROCESSING(SSmood, src) owner = parent soundloop = new(list(owner), FALSE, TRUE) diff --git a/code/datums/components/riding.dm b/code/datums/components/riding.dm index f165717a3124..3701be2ae9b7 100644 --- a/code/datums/components/riding.dm +++ b/code/datums/components/riding.dm @@ -20,8 +20,7 @@ /datum/component/riding/Initialize() if(!ismovableatom(parent)) - . = COMPONENT_INCOMPATIBLE - CRASH("RIDING COMPONENT ASSIGNED TO NON ATOM MOVABLE!") + return COMPONENT_INCOMPATIBLE RegisterSignal(COMSIG_MOVABLE_BUCKLE, .proc/vehicle_mob_buckle) RegisterSignal(COMSIG_MOVABLE_UNBUCKLE, .proc/vehicle_mob_unbuckle) RegisterSignal(COMSIG_MOVABLE_MOVED, .proc/vehicle_moved) diff --git a/code/datums/components/signal_redirect.dm b/code/datums/components/signal_redirect.dm index 38372dd356ad..764a44e4a95e 100644 --- a/code/datums/components/signal_redirect.dm +++ b/code/datums/components/signal_redirect.dm @@ -4,6 +4,5 @@ /datum/component/redirect/Initialize(list/signals, datum/callback/_callback) //It's not our job to verify the right signals are registered here, just do it. if(!LAZYLEN(signals) || !istype(_callback)) - . = COMPONENT_INCOMPATIBLE - CRASH("A redirection component was initialized with incorrect args.") + return COMPONENT_INCOMPATIBLE RegisterSignal(signals, _callback) diff --git a/code/datums/components/storage/storage.dm b/code/datums/components/storage/storage.dm index 5d225df7dbf5..f65f62084088 100644 --- a/code/datums/components/storage/storage.dm +++ b/code/datums/components/storage/storage.dm @@ -60,7 +60,7 @@ /datum/component/storage/Initialize(datum/component/storage/concrete/master) if(!isatom(parent)) - . = COMPONENT_INCOMPATIBLE + return COMPONENT_INCOMPATIBLE if(master) change_master(master) boxes = new(null, src) diff --git a/code/datums/components/thermite.dm b/code/datums/components/thermite.dm index 0cc95e57b3c5..809abbfdcc1f 100644 --- a/code/datums/components/thermite.dm +++ b/code/datums/components/thermite.dm @@ -21,10 +21,7 @@ ) /datum/component/thermite/Initialize(_amount) - if(!istype(parent, /turf)) - . = COMPONENT_INCOMPATIBLE - CRASH("A thermite component has been applied to an incorrect object. parent: [parent]") - if(blacklist[parent.type]) + if(!istype(parent, /turf) || blacklist[parent.type]) return COMPONENT_INCOMPATIBLE if(immunelist[parent.type]) _amount*=0 //Yeah the overlay can still go on it and be cleaned but you arent burning down a diamond wall diff --git a/code/datums/components/wet_floor.dm b/code/datums/components/wet_floor.dm index 7faeb2dfb2b0..78b31802c96a 100644 --- a/code/datums/components/wet_floor.dm +++ b/code/datums/components/wet_floor.dm @@ -24,8 +24,7 @@ /datum/component/wet_floor/Initialize(strength, duration_minimum, duration_add, duration_maximum, _permanent = FALSE) if(!isopenturf(parent)) - . = COMPONENT_INCOMPATIBLE - CRASH("Wet floor component attempted to be applied to a non open turf!") + return COMPONENT_INCOMPATIBLE add_wet(strength, duration_minimum, duration_add, duration_maximum) RegisterSignal(COMSIG_TURF_IS_WET, .proc/is_wet) RegisterSignal(COMSIG_TURF_MAKE_DRY, .proc/dry) @@ -138,8 +137,7 @@ /datum/component/wet_floor/OnTransfer(datum/to_datum) if(!isopenturf(to_datum)) - . = COMPONENT_INCOMPATIBLE - CRASH("Wet floor component attempted to be transferred to a non open turf!") + return COMPONENT_INCOMPATIBLE var/turf/O = parent O.cut_overlay(current_overlay) var/turf/T = to_datum