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.
This commit is contained in:
Leshana
2016-05-26 21:13:43 -04:00
parent 3caec84482
commit 715dbae590
+3
View File
@@ -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()