From 715dbae5905c952ab740a67aa257ba293d3a3fb3 Mon Sep 17 00:00:00 2001 From: Leshana Date: Thu, 26 May 2016 21:13:00 -0400 Subject: [PATCH] Prevent duplicate components in contents of machines built in-game. * Many machines create their default component parts in their constructor. But machines made in game get the parts from the frame added to them. * Existing code already partially handled this case by clearing out the component_parts list prior to adding the parts from the frame. However the list was merely Cut(), leaving the parts still in the contents of the machine. This bug was not easily visible, becuase there is no in-game way to get the parts back out. * This fix improves the situation by explicitly deleting the parts instead of leaving them semi-orphaned. --- code/game/machinery/frame.dm | 3 +++ 1 file changed, 3 insertions(+) diff --git a/code/game/machinery/frame.dm b/code/game/machinery/frame.dm index a264df51f2..1dddcedea0 100644 --- a/code/game/machinery/frame.dm +++ b/code/game/machinery/frame.dm @@ -218,7 +218,10 @@ if(component_check) playsound(src.loc, 'sound/items/Screwdriver.ogg', 50, 1) var/obj/machinery/new_machine = new src.circuit.build_path(src.loc, src.dir) + // Handle machines that have allocated default parts in thier constructor. if(new_machine.component_parts) + for(var/CP in new_machine.component_parts) + qdel(CP) new_machine.component_parts.Cut() else new_machine.component_parts = list()