diff --git a/code/game/machinery/kitchen/smartfridge.dm b/code/game/machinery/kitchen/smartfridge.dm index f52350aa8db3..903cd06c3119 100644 --- a/code/game/machinery/kitchen/smartfridge.dm +++ b/code/game/machinery/kitchen/smartfridge.dm @@ -23,7 +23,7 @@ var/icon_on = "smartfridge" var/icon_off = "smartfridge-off" var/icon_panel = "smartfridge-panel" - var/item_quants = list() + var/list/item_quants = list() //! Assoc list of names -> list(items) var/ispowered = TRUE //starts powered var/is_secure_fridge = FALSE var/shoot_inventory = FALSE @@ -40,6 +40,24 @@ GLOB.vending_products[/obj/item/reagent_container/glass/bottle] = 1 GLOB.vending_products[/obj/item/storage/pill_bottle] = 1 +/obj/structure/machinery/smartfridge/Destroy(force) + if(is_in_network()) // Delete all contents from networked storage index + for(var/atom/movable/item as anything in contents) + delete_contents(item) + item_quants.Cut() + return ..() // parent will delete contents if we're not networked + +/// Deletes given object in contents of the smartfridge +/obj/structure/machinery/smartfridge/proc/delete_contents(obj/item/item) + if(item.loc != src) + return + contents -= item + if(item_quants[item.name]) + item_quants[item.name] -= item + if(is_in_network() && chemical_data.shared_item_storage[item.name]) + chemical_data.shared_item_storage[item.name] -= item + qdel(item) + /obj/structure/machinery/smartfridge/proc/accept_check(obj/item/O as obj) if(istype(O,/obj/item/reagent_container/food/snacks/grown/) || istype(O,/obj/item/seeds/)) return 1 diff --git a/code/modules/reagents/chemistry_machinery/autodispenser.dm b/code/modules/reagents/chemistry_machinery/autodispenser.dm index a06042aac7a8..eed96564da71 100644 --- a/code/modules/reagents/chemistry_machinery/autodispenser.dm +++ b/code/modules/reagents/chemistry_machinery/autodispenser.dm @@ -346,8 +346,7 @@ C.reagents.trans_to(container, amount) //We don't care about keeping empty bottles stored if(C.reagents.total_volume <= 0 && istypestrict(C,/obj/item/reagent_container/glass/bottle)) - linked_storage.item_quants[C.name]-- - qdel(C) //Might want to connect it to a disposal system later instead + linked_storage.delete_contents(C) if(stage_missing) amount = stage_missing