From 7dbb3ba53c4b371e96f404d67417dc576d58cd0e Mon Sep 17 00:00:00 2001 From: Raeschen Date: Tue, 19 Mar 2024 21:02:06 +0100 Subject: [PATCH] Remove recursivemove + signals from being on EVERY machine by default (#7992) --- code/game/machinery/machinery_power.dm | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/code/game/machinery/machinery_power.dm b/code/game/machinery/machinery_power.dm index c5c6c6c03c..3a01f654a8 100644 --- a/code/game/machinery/machinery_power.dm +++ b/code/game/machinery/machinery_power.dm @@ -70,11 +70,20 @@ return amount // If channel is powered then you can do it. return 0 +/obj/machinery + var/recursive_set = FALSE //CHOMPEdit: bool to indicate if recursive movement detection ever got set. If it did, don't try to set it again! + // Do not do power stuff in New/Initialize until after ..() /obj/machinery/Initialize() . = ..() - RegisterSignal(src, COMSIG_OBSERVER_MOVED, PROC_REF(update_power_on_move)) - AddComponent(/datum/component/recursive_move) + + //ChompEDIT START -- only add this if we init on a non-turf (and non-null) + if(loc && !isturf(loc)) + recursive_set = TRUE + AddComponent(/datum/component/recursive_move) + RegisterSignal(src, COMSIG_OBSERVER_MOVED, PROC_REF(update_power_on_move)) //we only need this for recursive moving + //ChompEDIT END + var/power = POWER_CONSUMPTION REPORT_POWER_CONSUMPTION_CHANGE(0, power) power_init_complete = TRUE @@ -94,6 +103,14 @@ /obj/machinery/Moved(atom/old_loc, direction, forced = FALSE) . = ..() update_power_on_move(src, old_loc, loc) + + //ChompEDIT START -- only add this if we move into a non-turf (not null) and we've never been given recursive move handling + if(!recursive_set && loc && !isturf(loc)) + recursive_set = TRUE + AddComponent(/datum/component/recursive_move) + RegisterSignal(src, COMSIG_OBSERVER_MOVED, PROC_REF(update_power_on_move)) //we only need this for recursive moving + //ChompEDIT END + /* No if(ismovable(old_loc)) // Unregister recursive movement. UnregisterSignal(old_loc, COMSIG_OBSERVER_MOVED)