From edcd051e56cbf214bb38b799a53ca4be28dd8e2f Mon Sep 17 00:00:00 2001 From: SkyratBot <59378654+SkyratBot@users.noreply.github.com> Date: Mon, 27 Dec 2021 03:25:37 +0100 Subject: [PATCH] [MIRROR] Fixes loading shells with their own initial circuits [MDB IGNORE] (#10293) * save shell component properly loads shells that come with their own circuit (#63628) Attempting to load a BCI or circuit MODsuit module with the save shell component yields an empty circuit. This PR fixes that by making the save shell component check for and delete any pre-existing circuit in the loaded shell. * Fixes loading shells with their own initial circuits Co-authored-by: Y0SH1M4S73R --- code/modules/wiremod/components/admin/save_shell.dm | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/code/modules/wiremod/components/admin/save_shell.dm b/code/modules/wiremod/components/admin/save_shell.dm index b940d1b2280..80ce13e0d02 100644 --- a/code/modules/wiremod/components/admin/save_shell.dm +++ b/code/modules/wiremod/components/admin/save_shell.dm @@ -28,7 +28,12 @@ /obj/item/circuit_component/save_shell/proc/on_post_load(datum/source) SIGNAL_HANDLER - loaded_shell.AddComponent(/datum/component/shell, starting_circuit = parent) + var/datum/component/shell/shell_component = loaded_shell.GetComponent(/datum/component/shell) + if(!istype(shell_component)) + loaded_shell.AddComponent(/datum/component/shell, starting_circuit = parent) + else + QDEL_NULL(shell_component.attached_circuit) + shell_component.attach_circuit(parent) on_loaded.set_output(COMPONENT_SIGNAL) /obj/item/circuit_component/save_shell/proc/on_pre_save_to_json(datum/source, list/general_data)