From 80b535b1ff10f2548d233261e265aa13db302385 Mon Sep 17 00:00:00 2001 From: SkyratBot <59378654+SkyratBot@users.noreply.github.com> Date: Tue, 12 Oct 2021 02:45:54 +0200 Subject: [PATCH] [MIRROR] Adds the CIRCUIT_FLAG_REFUSE_MODULE circuit flag. [MDB IGNORE] (#8763) * Adds the CIRCUIT_FLAG_REFUSE_MODULE circuit flag. (#62033) Components like the MMI one can't be added to circuits more than once since they may register signals with same proctype and similar things which make for some tangled up race conditions if more than one is present. Unfortunately this safety can be bypassed - with little gain alas, an MMI can't be inserted by attacking the component with it. it needs a shell - by using a module component. That's no good. So I'm adding a flag that can be used to stop certain components from being added to module components. * Adds the CIRCUIT_FLAG_REFUSE_MODULE circuit flag. Co-authored-by: Ghom <42542238+Ghommie@users.noreply.github.com> --- code/__DEFINES/wiremod.dm | 2 ++ code/modules/wiremod/components/abstract/module.dm | 3 +++ code/modules/wiremod/components/action/mmi.dm | 1 + code/modules/wiremod/core/component.dm | 6 +++++- 4 files changed, 11 insertions(+), 1 deletion(-) diff --git a/code/__DEFINES/wiremod.dm b/code/__DEFINES/wiremod.dm index 5ccc49b39ad..5e44de2395d 100644 --- a/code/__DEFINES/wiremod.dm +++ b/code/__DEFINES/wiremod.dm @@ -109,6 +109,8 @@ #define CIRCUIT_FLAG_HIDDEN (1<<4) /// This circuit component has been marked as a component that has instant execution and will show up in the UI as so. This will only cause a visual change. #define CIRCUIT_FLAG_INSTANT (1<<5) +/// This circuit component can't be loaded in module component. Saves us some headaches. +#define CIRCUIT_FLAG_REFUSE_MODULE (1<<6) // Datatype flags /// The datatype supports manual inputs diff --git a/code/modules/wiremod/components/abstract/module.dm b/code/modules/wiremod/components/abstract/module.dm index 257028bd696..3566d619c9f 100644 --- a/code/modules/wiremod/components/abstract/module.dm +++ b/code/modules/wiremod/components/abstract/module.dm @@ -47,6 +47,9 @@ return ..() /obj/item/integrated_circuit/module/add_component(obj/item/circuit_component/to_add, mob/living/user) + if(to_add.circuit_flags & CIRCUIT_FLAG_REFUSE_MODULE) + balloon_alert(user, "doesn't fit into module!") + return . = ..() if(attached_module) attached_module.circuit_size += to_add.circuit_size diff --git a/code/modules/wiremod/components/action/mmi.dm b/code/modules/wiremod/components/action/mmi.dm index 991e90a7b17..e0ee407a7e1 100644 --- a/code/modules/wiremod/components/action/mmi.dm +++ b/code/modules/wiremod/components/action/mmi.dm @@ -6,6 +6,7 @@ /obj/item/circuit_component/mmi display_name = "Man-Machine Interface" desc = "A component that allows MMI to enter shells to send output signals." + circuit_flags = CIRCUIT_FLAG_REFUSE_MODULE /// The message to send to the MMI in the shell. var/datum/port/input/message diff --git a/code/modules/wiremod/core/component.dm b/code/modules/wiremod/core/component.dm index 5a6ac5ecc6e..b7a9fb5cfc1 100644 --- a/code/modules/wiremod/core/component.dm +++ b/code/modules/wiremod/core/component.dm @@ -82,7 +82,6 @@ if(circuit_flags & CIRCUIT_FLAG_INSTANT) ui_color = "orange" - /obj/item/circuit_component/Destroy() if(parent) // Prevents a Destroy() recursion @@ -97,6 +96,11 @@ QDEL_LIST(input_ports) return ..() +/obj/item/circuit_component/examine(mob/user) + . = ..() + if(circuit_flags & CIRCUIT_FLAG_REFUSE_MODULE) + . += span_notice("It's incompatible with module components.") + /** * Called when a shell is registered from the component/the component is added to a circuit. *