Skip to content

Commit

Permalink
Machine's correctly eject signaller's attached to it's wires (#75928)
Browse files Browse the repository at this point in the history
## About The Pull Request

Fixes #72053
the signaller is made part of the machine's `component_parts` now so it
doesn't get moved out when `dump_inventory_contents()` is called like in
the case of microwave when it has finished cooking
This fix also applies for other machine's that call this proc

Fixes #72132
Clear's out the `holder` & `connected` vars from the signaller when the
wire's get destroyed allowing the signaller to be picked up

## Changelog
:cl:
fix: microwave's(after it has finished cooking) & other machine's that
spit out contents don't spit out assemblies/signallers attached to it's
wires.
fix: signallers can be picked up if you attached them to a machine's
wire & later deconstructed that machine without detaching it first.
/:cl:

---------

Co-authored-by: Jeremiah <[email protected]>
  • Loading branch information
2 people authored and Absolucy committed Oct 23, 2024
1 parent 293dd84 commit 5193934
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions code/datums/wires/_wires.dm
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,12 @@

/datum/wires/Destroy()
holder = null
assemblies = list()
//properly clear refs to avoid harddels & other problems
for(var/color in assemblies)
var/obj/item/assembly/assembly = assemblies[color]
assembly.holder = null
assembly.connected = null
LAZYCLEARLIST(assemblies)
return ..()

/datum/wires/proc/add_duds(duds)
Expand Down Expand Up @@ -186,6 +191,14 @@
if(S && istype(S) && S.attachable && !is_attached(color))
assemblies[color] = S
S.forceMove(holder)
/**
* special snowflake check for machines
* someone attached a signaler to the machines wires
* move it to the machines component parts so it doesn't get moved out in dump_inventory_contents() which gets called a lot
*/
if(istype(holder, /obj/machinery))
var/obj/machinery/machine = holder
LAZYADD(machine.component_parts, S)
S.connected = src
S.on_attach() // Notify assembly that it is attached
return S
Expand All @@ -195,7 +208,6 @@
if(S && istype(S))
assemblies -= color
S.on_detach() // Notify the assembly. This should remove the reference to our holder
S.forceMove(holder.drop_location())
return S

/// Called from [/atom/proc/emp_act]
Expand Down

0 comments on commit 5193934

Please sign in to comment.