From dcf5caa2bfc0b4b1304d3885bff66d1cfdbd25c9 Mon Sep 17 00:00:00 2001 From: Drulikar Date: Sat, 30 Dec 2023 01:27:26 -0800 Subject: [PATCH] Fix runtimes and sentry bricking if a sentry_computer is deleted --- code/modules/defenses/sentry_computer.dm | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/code/modules/defenses/sentry_computer.dm b/code/modules/defenses/sentry_computer.dm index 6107bc3d7ee8..59c6409d552c 100644 --- a/code/modules/defenses/sentry_computer.dm +++ b/code/modules/defenses/sentry_computer.dm @@ -78,6 +78,8 @@ last_camera_turf = null current = null registered_tools = null + for(var/obj/structure/machinery/defenses/sentry/sentrygun as anything in paired_sentry) + unpair_sentry(sentrygun) paired_sentry = null /obj/item/device/sentry_computer/proc/camera_mapname_update(source, value) @@ -211,7 +213,7 @@ for(var/key_id in tool.encryption_keys) var/datum/weakref/ref = tool.encryption_keys[key_id] var/obj/item/device/sentry_computer/key_object = ref.resolve() - key_object.registered_tools -= id + key_object?.registered_tools -= id tool.encryption_keys = list() to_chat(user, SPAN_NOTICE("Existing encryption keys cleared.")) to_chat(usr, SPAN_NOTICE("You begin encryption key to \the [tool].")) @@ -319,9 +321,8 @@ .["sentry_static"] = list() .["mapRef"] = camera_map_name var/index = 1 - for(var/sentry in paired_sentry) + for(var/obj/structure/machinery/defenses/sentry/sentrygun as anything in paired_sentry) var/list/sentry_holder = list() - var/obj/structure/machinery/defenses/sentry/sentrygun = sentry sentry_holder["selection_menu"] = list() sentry_holder["index"] = index sentry_holder["name"] = sentrygun.name