From ebac9745686144690fc2654ed63e1ae8720dcb97 Mon Sep 17 00:00:00 2001 From: Watermelon914 <37270891+Watermelon914@users.noreply.github.com> Date: Sat, 3 Jul 2021 18:59:38 +0100 Subject: [PATCH] Fixed being able to insert infinitely many components into a shell. Fixes being able to view the shell's circuit in a locked shell. (#59962) --- code/datums/components/shell.dm | 12 ++++++++++-- code/modules/wiremod/integrated_circuit.dm | 8 ++++++++ 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/code/datums/components/shell.dm b/code/datums/components/shell.dm index 38415bff80b..487aa60e5c8 100644 --- a/code/datums/components/shell.dm +++ b/code/datums/components/shell.dm @@ -101,12 +101,12 @@ return if(attached_circuit?.owner_id && item == attached_circuit.owner_id.resolve()) - locked = !locked + set_locked(!locked) source.balloon_alert(attacker, "[locked? "locked" : "unlocked"] [source]") return COMPONENT_NO_AFTERATTACK if(attached_circuit && istype(item, /obj/item/circuit_component)) - attached_circuit.add_component(item, attacker) + attached_circuit.add_component_manually(item, attacker) return if(!istype(item, /obj/item/integrated_circuit)) @@ -128,6 +128,12 @@ logic_board.inserter_mind = WEAKREF(attacker.mind) attach_circuit(logic_board, attacker) +/// Sets whether the shell is locked or not +/datum/component/shell/proc/set_locked(new_value) + locked = new_value + attached_circuit?.locked = locked + + /datum/component/shell/proc/on_multitool_act(atom/source, mob/user, obj/item/tool) SIGNAL_HANDLER if(!attached_circuit) @@ -201,6 +207,7 @@ attached_circuit.add_component(to_add) RegisterSignal(circuitboard, COMSIG_CIRCUIT_ADD_COMPONENT_MANUALLY, .proc/on_circuit_add_component_manually) attached_circuit.set_shell(parent) + attached_circuit.locked = FALSE if(shell_flags & SHELL_FLAG_REQUIRE_ANCHOR) var/atom/movable/parent_atom = parent @@ -224,6 +231,7 @@ for(var/obj/item/circuit_component/to_remove as anything in unremovable_circuit_components) attached_circuit.remove_component(to_remove) to_remove.moveToNullspace() + attached_circuit.locked = FALSE attached_circuit = null /datum/component/shell/proc/on_atom_usb_cable_try_attach(atom/source, obj/item/usb_cable/usb_cable, mob/user) diff --git a/code/modules/wiremod/integrated_circuit.dm b/code/modules/wiremod/integrated_circuit.dm index fe9011559ee..fdae1cf903c 100644 --- a/code/modules/wiremod/integrated_circuit.dm +++ b/code/modules/wiremod/integrated_circuit.dm @@ -29,6 +29,9 @@ /// Whether the integrated circuit is on or not. Handled by the shell. var/on = FALSE + /// Whether the integrated circuit is locked or not. Handled by the shell. + var/locked = FALSE + /// The ID that is authorized to unlock/lock the shell so that the circuit can/cannot be removed. var/datum/weakref/owner_id @@ -262,6 +265,11 @@ return shell return ..() +/obj/item/integrated_circuit/can_interact(mob/user) + if(locked) + return FALSE + return ..() + /obj/item/integrated_circuit/ui_state(mob/user) if(!shell) return GLOB.hands_state