diff --git a/code/datums/components/_component.dm b/code/datums/components/_component.dm index ab935bf3e24..b9a6797cb15 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.type]!") + CRASH("Incompatible [type] assigned to a [P.type]! args: [json_encode(arguments)]") _JoinParent(P) @@ -281,10 +281,11 @@ var/datum/old_parent = parent PreTransfer() _RemoveFromParent() + parent = null SEND_SIGNAL(old_parent, COMSIG_COMPONENT_REMOVING, src) /datum/proc/TakeComponent(datum/component/target) - if(!target) + if(!target || target.parent == src) return if(target.parent) target.RemoveComponent() diff --git a/code/datums/components/signal_redirect.dm b/code/datums/components/signal_redirect.dm index 4de7e99a024..170774c53b3 100644 --- a/code/datums/components/signal_redirect.dm +++ b/code/datums/components/signal_redirect.dm @@ -3,15 +3,23 @@ /datum/component/redirect dupe_mode = COMPONENT_DUPE_ALLOWED + var/list/signals -/datum/component/redirect/Initialize(list/signals, datum/callback/_callback, flags=NONE) +/datum/component/redirect/Initialize(list/_signals, flags=NONE) //It's not our job to verify the right signals are registered here, just do it. - if(!LAZYLEN(signals) || !istype(_callback)) - warning("signals are [list2params(signals)], callback is [_callback]]") + if(!LAZYLEN(_signals)) return COMPONENT_INCOMPATIBLE if(flags & REDIRECT_TRANSFER_WITH_TURF && isturf(parent)) RegisterSignal(parent, COMSIG_TURF_CHANGE, .proc/turf_change) - RegisterSignal(parent, signals, _callback) + + signals = _signals + +/datum/component/redirect/RegisterWithParent() + for(var/signal in signals) + RegisterSignal(parent, signal, signals[signal]) + +/datum/component/redirect/UnregisterFromParent() + UnregisterSignal(parent, signals) /datum/component/redirect/proc/turf_change(path, new_baseturfs, flags, list/transfers) transfers += src diff --git a/code/datums/status_effects/gas.dm b/code/datums/status_effects/gas.dm index ee974a6e6e0..5f9a9d131e9 100644 --- a/code/datums/status_effects/gas.dm +++ b/code/datums/status_effects/gas.dm @@ -13,7 +13,7 @@ icon_state = "frozen" /datum/status_effect/freon/on_apply() - redirect_component = WEAKREF(owner.AddComponent(/datum/component/redirect, list(COMSIG_LIVING_RESIST), CALLBACK(src, .proc/owner_resist))) + redirect_component = WEAKREF(owner.AddComponent(/datum/component/redirect, list(COMSIG_LIVING_RESIST = CALLBACK(src, .proc/owner_resist)))) if(!owner.stat) to_chat(owner, "You become frozen in a cube!") cube = icon('icons/effects/freeze.dmi', "ice_cube") diff --git a/code/game/machinery/_machinery.dm b/code/game/machinery/_machinery.dm index da2a913ccd2..a11ece50db7 100644 --- a/code/game/machinery/_machinery.dm +++ b/code/game/machinery/_machinery.dm @@ -130,7 +130,7 @@ Class Procs: else START_PROCESSING(SSfastprocess, src) power_change() - AddComponent(/datum/component/redirect, list(COMSIG_ENTER_AREA), CALLBACK(src, .proc/power_change)) + AddComponent(/datum/component/redirect, list(COMSIG_ENTER_AREA = CALLBACK(src, .proc/power_change))) if (occupant_typecache) occupant_typecache = typecacheof(occupant_typecache) diff --git a/code/game/machinery/washing_machine.dm b/code/game/machinery/washing_machine.dm index 56377e5a1fb..c101ed321e9 100644 --- a/code/game/machinery/washing_machine.dm +++ b/code/game/machinery/washing_machine.dm @@ -13,7 +13,7 @@ /obj/machinery/washing_machine/ComponentInitialize() . = ..() - AddComponent(/datum/component/redirect, list(COMSIG_COMPONENT_CLEAN_ACT), CALLBACK(src, .proc/clean_blood)) + AddComponent(/datum/component/redirect, list(COMSIG_COMPONENT_CLEAN_ACT = CALLBACK(src, .proc/clean_blood))) /obj/machinery/washing_machine/examine(mob/user) ..() diff --git a/code/game/objects/effects/proximity.dm b/code/game/objects/effects/proximity.dm index 8cd23f2cf82..de17582f274 100644 --- a/code/game/objects/effects/proximity.dm +++ b/code/game/objects/effects/proximity.dm @@ -23,7 +23,7 @@ last_host_loc = host.loc if(movement_tracker) QDEL_NULL(movement_tracker) - movement_tracker = host.AddComponent(/datum/component/redirect, COMSIG_MOVABLE_MOVED, CALLBACK(src, .proc/HandleMove)) + movement_tracker = host.AddComponent(/datum/component/redirect, list(COMSIG_MOVABLE_MOVED = CALLBACK(src, .proc/HandleMove))) SetRange(current_range,TRUE) /datum/proximity_monitor/Destroy() diff --git a/code/game/objects/items/RCL.dm b/code/game/objects/items/RCL.dm index f423249b70e..50e333872a9 100644 --- a/code/game/objects/items/RCL.dm +++ b/code/game/objects/items/RCL.dm @@ -143,7 +143,7 @@ if (mobhook && mobhook.parent != user) QDEL_NULL(mobhook) if (!mobhook) - mobhook = user.AddComponent(/datum/component/redirect, list(COMSIG_MOVABLE_MOVED), CALLBACK(src, .proc/trigger, user)) + mobhook = user.AddComponent(/datum/component/redirect, list(COMSIG_MOVABLE_MOVED = CALLBACK(src, .proc/trigger, user))) else QDEL_NULL(mobhook) diff --git a/code/game/objects/items/defib.dm b/code/game/objects/items/defib.dm index 3d069f1cffb..9400535889a 100644 --- a/code/game/objects/items/defib.dm +++ b/code/game/objects/items/defib.dm @@ -303,7 +303,7 @@ if (mobhook && mobhook.parent != user) QDEL_NULL(mobhook) if (!mobhook) - mobhook = user.AddComponent(/datum/component/redirect, list(COMSIG_MOVABLE_MOVED), CALLBACK(src, .proc/check_range)) + mobhook = user.AddComponent(/datum/component/redirect, list(COMSIG_MOVABLE_MOVED = CALLBACK(src, .proc/check_range))) /obj/item/twohanded/shockpaddles/Moved() . = ..() diff --git a/code/game/objects/items/devices/geiger_counter.dm b/code/game/objects/items/devices/geiger_counter.dm index 439c8957890..d4c25241012 100644 --- a/code/game/objects/items/devices/geiger_counter.dm +++ b/code/game/objects/items/devices/geiger_counter.dm @@ -208,7 +208,7 @@ if (mobhook && mobhook.parent != user) QDEL_NULL(mobhook) if (!mobhook) - mobhook = user.AddComponent(/datum/component/redirect, list(COMSIG_ATOM_RAD_ACT), CALLBACK(src, /atom.proc/rad_act)) + mobhook = user.AddComponent(/datum/component/redirect, list(COMSIG_ATOM_RAD_ACT = CALLBACK(src, /atom.proc/rad_act))) /obj/item/geiger_counter/cyborg/dropped() . = ..() diff --git a/code/game/objects/items/storage/bags.dm b/code/game/objects/items/storage/bags.dm index 11dbf727f16..2e9d717267c 100644 --- a/code/game/objects/items/storage/bags.dm +++ b/code/game/objects/items/storage/bags.dm @@ -119,7 +119,7 @@ if (mobhook && mobhook.parent != user) QDEL_NULL(mobhook) if (!mobhook) - mobhook = user.AddComponent(/datum/component/redirect, list(COMSIG_MOVABLE_MOVED), CALLBACK(src, .proc/Pickup_ores, user)) + mobhook = user.AddComponent(/datum/component/redirect, list(COMSIG_MOVABLE_MOVED = CALLBACK(src, .proc/Pickup_ores, user))) /obj/item/storage/bag/ore/dropped() . = ..() diff --git a/code/modules/antagonists/disease/disease_mob.dm b/code/modules/antagonists/disease/disease_mob.dm index 6908c5eebf0..a5a17daace1 100644 --- a/code/modules/antagonists/disease/disease_mob.dm +++ b/code/modules/antagonists/disease/disease_mob.dm @@ -245,7 +245,7 @@ the new instance inside the host to be updated to the template's stats. /mob/camera/disease/proc/set_following(mob/living/L) following_host = L if(!move_listener) - move_listener = L.AddComponent(/datum/component/redirect, COMSIG_MOVABLE_MOVED, CALLBACK(src, .proc/follow_mob)) + move_listener = L.AddComponent(/datum/component/redirect, list(COMSIG_MOVABLE_MOVED = CALLBACK(src, .proc/follow_mob))) else L.TakeComponent(move_listener) if(QDELING(move_listener)) diff --git a/code/modules/assembly/infrared.dm b/code/modules/assembly/infrared.dm index 94359f0a101..57eda8202ee 100644 --- a/code/modules/assembly/infrared.dm +++ b/code/modules/assembly/infrared.dm @@ -164,7 +164,7 @@ /obj/item/assembly/infra/proc/switchListener(turf/newloc) QDEL_NULL(listener) - listener = newloc.AddComponent(/datum/component/redirect, COMSIG_ATOM_EXITED, CALLBACK(src, .proc/check_exit)) + listener = newloc.AddComponent(/datum/component/redirect, list(COMSIG_ATOM_EXITED = CALLBACK(src, .proc/check_exit))) /obj/item/assembly/infra/proc/check_exit(atom/movable/offender) if(QDELETED(src)) diff --git a/code/modules/clothing/gloves/_gloves.dm b/code/modules/clothing/gloves/_gloves.dm index 0e9be23aed5..79a24afc6f5 100644 --- a/code/modules/clothing/gloves/_gloves.dm +++ b/code/modules/clothing/gloves/_gloves.dm @@ -13,7 +13,7 @@ /obj/item/clothing/gloves/ComponentInitialize() . = ..() - AddComponent(/datum/component/redirect, list(COMSIG_COMPONENT_CLEAN_ACT), CALLBACK(src, .proc/clean_blood)) + AddComponent(/datum/component/redirect, list(COMSIG_COMPONENT_CLEAN_ACT = CALLBACK(src, .proc/clean_blood))) /obj/item/clothing/gloves/proc/clean_blood(strength) if(strength < CLEAN_STRENGTH_BLOOD) diff --git a/code/modules/clothing/shoes/_shoes.dm b/code/modules/clothing/shoes/_shoes.dm index e3c32cd26c5..375b4855e73 100644 --- a/code/modules/clothing/shoes/_shoes.dm +++ b/code/modules/clothing/shoes/_shoes.dm @@ -17,7 +17,7 @@ /obj/item/clothing/shoes/ComponentInitialize() . = ..() - AddComponent(/datum/component/redirect, list(COMSIG_COMPONENT_CLEAN_ACT), CALLBACK(src, .proc/clean_blood)) + AddComponent(/datum/component/redirect, list(COMSIG_COMPONENT_CLEAN_ACT = CALLBACK(src, .proc/clean_blood))) /obj/item/clothing/shoes/suicide_act(mob/living/carbon/user) if(rand(2)>1) diff --git a/code/modules/clothing/spacesuits/hardsuit.dm b/code/modules/clothing/spacesuits/hardsuit.dm index 2e5896098f3..75c5a7d1d09 100644 --- a/code/modules/clothing/spacesuits/hardsuit.dm +++ b/code/modules/clothing/spacesuits/hardsuit.dm @@ -628,7 +628,7 @@ if (mobhook && mobhook.parent != user) QDEL_NULL(mobhook) if (!mobhook) - mobhook = user.AddComponent(/datum/component/redirect, list(COMSIG_MOVABLE_MOVED), CALLBACK(src, .proc/on_mob_move)) + mobhook = user.AddComponent(/datum/component/redirect, list(COMSIG_MOVABLE_MOVED = CALLBACK(src, .proc/on_mob_move))) else QDEL_NULL(mobhook) diff --git a/code/modules/fields/fields.dm b/code/modules/fields/fields.dm index 0fdd2699d67..5e34c934d90 100644 --- a/code/modules/fields/fields.dm +++ b/code/modules/fields/fields.dm @@ -305,7 +305,7 @@ to_chat(user, "You turn [src] [operating? "on":"off"].") QDEL_NULL(mobhook) if(!istype(current) && operating) - mobhook = user.AddComponent(/datum/component/redirect, list(COMSIG_MOVABLE_MOVED), CALLBACK(src, .proc/on_mob_move)) + mobhook = user.AddComponent(/datum/component/redirect, list(COMSIG_MOVABLE_MOVED = CALLBACK(src, .proc/on_mob_move))) setup_debug_field() else if(!operating) QDEL_NULL(current) diff --git a/code/modules/mob/living/carbon/human/human.dm b/code/modules/mob/living/carbon/human/human.dm index 8429b1d106b..adae11bf690 100644 --- a/code/modules/mob/living/carbon/human/human.dm +++ b/code/modules/mob/living/carbon/human/human.dm @@ -28,7 +28,7 @@ . = ..() - AddComponent(/datum/component/redirect, list(COMSIG_COMPONENT_CLEAN_ACT), CALLBACK(src, .proc/clean_blood)) + AddComponent(/datum/component/redirect, list(COMSIG_COMPONENT_CLEAN_ACT = CALLBACK(src, .proc/clean_blood))) /mob/living/carbon/human/ComponentInitialize() diff --git a/code/modules/projectiles/guns/misc/beam_rifle.dm b/code/modules/projectiles/guns/misc/beam_rifle.dm index fb137da2f41..d2a703ef222 100644 --- a/code/modules/projectiles/guns/misc/beam_rifle.dm +++ b/code/modules/projectiles/guns/misc/beam_rifle.dm @@ -285,7 +285,7 @@ if(istype(user)) current_user = user LAZYOR(current_user.mousemove_intercept_objects, src) - mobhook = user.AddComponent(/datum/component/redirect, list(COMSIG_MOVABLE_MOVED), CALLBACK(src, .proc/on_mob_move)) + mobhook = user.AddComponent(/datum/component/redirect, list(COMSIG_MOVABLE_MOVED = CALLBACK(src, .proc/on_mob_move))) /obj/item/gun/energy/beam_rifle/onMouseDrag(src_object, over_object, src_location, over_location, params, mob) if(aiming) diff --git a/code/modules/research/xenobiology/xenobio_camera.dm b/code/modules/research/xenobiology/xenobio_camera.dm index 19c6d77576e..c3a6ca8aef7 100644 --- a/code/modules/research/xenobiology/xenobio_camera.dm +++ b/code/modules/research/xenobiology/xenobio_camera.dm @@ -50,7 +50,7 @@ scan_action = new potion_action = new stored_slimes = list() - listener = AddComponent(/datum/component/redirect, COMSIG_ATOM_CONTENTS_DEL, CALLBACK(src, .proc/on_contents_del)) + listener = AddComponent(/datum/component/redirect, list(COMSIG_ATOM_CONTENTS_DEL = CALLBACK(src, .proc/on_contents_del))) /obj/machinery/computer/camera_advanced/xenobio/Destroy() stored_slimes = null diff --git a/code/modules/surgery/organs/eyes.dm b/code/modules/surgery/organs/eyes.dm index d38e76ae6e2..af750b8b846 100644 --- a/code/modules/surgery/organs/eyes.dm +++ b/code/modules/surgery/organs/eyes.dm @@ -242,7 +242,7 @@ if (mobhook && mobhook.parent != M) QDEL_NULL(mobhook) if (!mobhook) - mobhook = M.AddComponent(/datum/component/redirect, list(COMSIG_ATOM_DIR_CHANGE), CALLBACK(src, .proc/update_visuals)) + mobhook = M.AddComponent(/datum/component/redirect, list(COMSIG_ATOM_DIR_CHANGE = CALLBACK(src, .proc/update_visuals))) /obj/item/organ/eyes/robotic/glow/Remove(mob/living/carbon/M) . = ..()