From a2fcec6a33e15742997fd2e6a6a55bcf49778f7a Mon Sep 17 00:00:00 2001 From: RikuTheKiller <88713943+RikuTheKiller@users.noreply.github.com> Date: Sat, 8 Oct 2022 17:24:31 +0300 Subject: [PATCH] BCIs are now stored in the manipulation chamber's contents, instead of nullspace (#70350) Fixes a bug where MMIs would be sent into the nullspace room when in an MMI component inside of a BCI that is inserted into a BCI manipulation chamber. Stores the BCI in the chamber's contents, instead of nullspace, allowing the MMI to talk, the BCI to still act as it would normally and overall just solves the issue and maybe some others alongside it. Fixes #70349 --- .../library/skill_learning/skill_station.dm | 3 +- .../wiremod/shell/brain_computer_interface.dm | 57 +++++++++++-------- 2 files changed, 33 insertions(+), 27 deletions(-) diff --git a/code/modules/library/skill_learning/skill_station.dm b/code/modules/library/skill_learning/skill_station.dm index 580bd3116aa..ac4f324685e 100644 --- a/code/modules/library/skill_learning/skill_station.dm +++ b/code/modules/library/skill_learning/skill_station.dm @@ -100,8 +100,7 @@ /obj/machinery/skill_station/dump_inventory_contents(list/subset = null) // Don't drop the skillchip, it's directly inserted into the machine. // dump_contents() will drop everything including the skillchip as an alternative to this. - subset = contents - inserted_skillchip - return ..() + return ..(contents - inserted_skillchip) /obj/machinery/skill_station/proc/toggle_open(mob/user) state_open ? close_machine() : open_machine() diff --git a/code/modules/wiremod/shell/brain_computer_interface.dm b/code/modules/wiremod/shell/brain_computer_interface.dm index 82711646613..ad16c38fa8b 100644 --- a/code/modules/wiremod/shell/brain_computer_interface.dm +++ b/code/modules/wiremod/shell/brain_computer_interface.dm @@ -281,7 +281,7 @@ var/busy_icon_state var/locked = FALSE - var/datum/weakref/bci_to_implant + var/obj/item/organ/internal/cyberimp/bci/bci_to_implant COOLDOWN_DECLARE(message_cooldown) @@ -290,18 +290,15 @@ occupant_typecache = typecacheof(/mob/living/carbon) /obj/machinery/bci_implanter/on_deconstruction() - var/obj/item/organ/internal/cyberimp/bci/bci_to_implant_resolved = bci_to_implant?.resolve() - bci_to_implant_resolved?.forceMove(drop_location()) - bci_to_implant = null + drop_stored_bci() /obj/machinery/bci_implanter/Destroy() - QDEL_NULL(bci_to_implant) + qdel(bci_to_implant) return ..() /obj/machinery/bci_implanter/examine(mob/user) . = ..() - - if (isnull(bci_to_implant?.resolve())) + if (isnull(bci_to_implant)) . += span_notice("There is no BCI inserted.") else . += span_notice("Right-click to remove current BCI.") @@ -350,15 +347,12 @@ balloon_alert(user, "it's locked!") return SECONDARY_ATTACK_CANCEL_ATTACK_CHAIN - var/obj/item/organ/internal/cyberimp/bci/bci_to_implant_resolved = bci_to_implant?.resolve() - if (isnull(bci_to_implant_resolved)) + if (isnull(bci_to_implant)) balloon_alert(user, "no bci inserted!") else - user.put_in_hands(bci_to_implant_resolved) + user.put_in_hands(bci_to_implant) balloon_alert(user, "ejected bci") - bci_to_implant = null - return SECONDARY_ATTACK_CANCEL_ATTACK_CHAIN /obj/machinery/bci_implanter/attackby(obj/item/weapon, mob/user, params) @@ -368,10 +362,10 @@ balloon_alert(user, "bci has no circuit!") return - var/obj/item/organ/internal/cyberimp/bci/previous_bci_to_implant = bci_to_implant?.resolve() + var/obj/item/organ/internal/cyberimp/bci/previous_bci_to_implant = bci_to_implant - bci_to_implant = WEAKREF(weapon) - weapon.moveToNullspace() + user.transferItemToLoc(weapon, src) + bci_to_implant = weapon if (isnull(previous_bci_to_implant)) balloon_alert(user, "inserted bci") @@ -426,22 +420,20 @@ playsound(loc, 'sound/machines/ping.ogg', 30, FALSE) var/obj/item/organ/internal/cyberimp/bci/bci_organ = carbon_occupant.getorgan(/obj/item/organ/internal/cyberimp/bci) - var/obj/item/organ/internal/cyberimp/bci/bci_to_implant_resolved = bci_to_implant?.resolve() if (bci_organ) bci_organ.Remove(carbon_occupant) - if (isnull(bci_to_implant_resolved)) + if (isnull(bci_to_implant)) say("Occupant's previous brain-computer interface has been transferred to internal storage unit.") - bci_organ.moveToNullspace() - bci_to_implant = WEAKREF(bci_organ) + carbon_occupant.transferItemToLoc(bci_organ, src) + bci_to_implant = bci_organ else say("Occupant's previous brain-computer interface has been ejected.") bci_organ.forceMove(drop_location()) - else if (!isnull(bci_to_implant_resolved)) - say("Occupant has been injected with [bci_to_implant_resolved].") - bci_to_implant_resolved.Insert(carbon_occupant) - bci_to_implant = null + else if (!isnull(bci_to_implant)) + say("Occupant has been injected with [bci_to_implant].") + bci_to_implant.Insert(carbon_occupant) /obj/machinery/bci_implanter/open_machine() if(state_open) @@ -459,8 +451,8 @@ var/mob/living/carbon/carbon_occupant = occupant if (istype(occupant)) - var/obj/item/organ/internal/cyberimp/bci/existing_bci_organ = carbon_occupant.getorgan(/obj/item/organ/internal/cyberimp/bci) - if (isnull(existing_bci_organ) && isnull(bci_to_implant?.resolve())) + var/obj/item/organ/internal/cyberimp/bci/bci_organ = carbon_occupant.getorgan(/obj/item/organ/internal/cyberimp/bci) + if (isnull(bci_organ) && isnull(bci_to_implant)) say("No brain-computer interface inserted, and occupant does not have one. Insert a BCI to implant one.") playsound(src, 'sound/machines/buzz-sigh.ogg', 30, TRUE) return FALSE @@ -495,6 +487,21 @@ open_machine() +/obj/machinery/bci_implanter/proc/drop_stored_bci() + if (isnull(bci_to_implant)) + return + bci_to_implant.forceMove(drop_location()) + +/obj/machinery/bci_implanter/dump_inventory_contents(list/subset) + // Prevents opening the machine dropping the BCI. + // "dump_contents()" still drops the BCI. + return ..(contents - bci_to_implant) + +/obj/machinery/bci_implanter/Exited(atom/movable/gone, direction) + if (gone == bci_to_implant) + bci_to_implant = null + return ..() + /obj/item/circuitboard/machine/bci_implanter name = "Brain-Computer Interface Manipulation Chamber (Machine Board)" greyscale_colors = CIRCUIT_COLOR_SCIENCE