From da4868cff94e5882876bc3297091c304767e12e5 Mon Sep 17 00:00:00 2001 From: SyncIt21 <110812394+SyncIt21@users.noreply.github.com> Date: Thu, 11 Sep 2025 16:10:08 +0530 Subject: [PATCH] Fixes random runtime for round start silo connections (#92897) ## About The Pull Request Happens randomly only at round start. Between the time the silo connection gets initialized (i.e. when the atom subsystem is initialized) & the round start literarily anything can happen like the atom getting destroyed by some random event resulting in the parent becoming null. So we check for that & abort accordingly ## Changelog :cl: fix: Fixes random runtime for round start silo connections /:cl: --------- Co-authored-by: LemonInTheDark <58055496+LemonInTheDark@users.noreply.github.com> --- code/datums/components/material/remote_materials.dm | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/code/datums/components/material/remote_materials.dm b/code/datums/components/material/remote_materials.dm index 1d4d89d819b..f122bfb908b 100644 --- a/code/datums/components/material/remote_materials.dm +++ b/code/datums/components/material/remote_materials.dm @@ -23,6 +23,8 @@ handles linking back and forth. var/mat_container_flags = NONE ///List of signals to hook onto the local container var/list/mat_container_signals + ///Callback for round start silo connections. Have to cancel this if the parent gets destroyed before round start + VAR_PRIVATE/datum/callback/connection /datum/component/remote_materials/Initialize( mapload, @@ -46,7 +48,8 @@ handles linking back and forth. connect_to_silo = TRUE if(mapload) // wait for silo to initialize during mapload - SSticker.OnRoundstart(CALLBACK(src, PROC_REF(_PrepareStorage), connect_to_silo)) + connection = CALLBACK(src, PROC_REF(_PrepareStorage), connect_to_silo) + SSticker.OnRoundstart(connection) else //directly register in round _PrepareStorage(connect_to_silo) @@ -60,6 +63,7 @@ handles linking back and forth. /datum/component/remote_materials/proc/_PrepareStorage(connect_to_silo) PRIVATE_PROC(TRUE) + connection = null if (connect_to_silo) silo = GLOB.ore_silo_default if (silo) @@ -72,6 +76,9 @@ handles linking back and forth. _MakeLocal() /datum/component/remote_materials/Destroy() + if(connection) + LAZYREMOVE(SSticker.round_start_events, connection) + connection = null if(silo) allow_standalone = FALSE disconnect()