From 2e2f6d21012cdcc5455da85ef7fddf54a1960ab4 Mon Sep 17 00:00:00 2001 From: Cyberboss Date: Thu, 30 Mar 2017 17:08:05 -0400 Subject: [PATCH] Improves SSU item dispensing Fixes some null runtimes if you spamclick the UI --- code/game/machinery/suit_storage_unit.dm | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/code/game/machinery/suit_storage_unit.dm b/code/game/machinery/suit_storage_unit.dm index 540f4439d26..5a924b2bfa2 100644 --- a/code/game/machinery/suit_storage_unit.dm +++ b/code/game/machinery/suit_storage_unit.dm @@ -375,18 +375,13 @@ if("dispense") if(!state_open) return - switch(params["item"]) - if("helmet") - helmet.loc = loc - helmet = null - if("suit") - suit.loc = loc - suit = null - if("mask") - mask.loc = loc - mask = null - if("storage") - storage.loc = loc - storage = null + + var/static/list/valid_items = list("helmet", "suit", "mask", "storage") + var/item_name = params["item"] + if(item_name in valid_items) + var/obj/item/I = vars[item_name] + vars[item_name] = null + if(I) + I.forceMove(loc) . = TRUE update_icon()