From 89824404dabf8a8494525491be03f3f8c2d5e4f4 Mon Sep 17 00:00:00 2001 From: Farie82 Date: Sun, 21 Feb 2021 22:43:38 +0100 Subject: [PATCH] Makes the coinpress respect inventory limits (#15202) Co-authored-by: joep van der velden <15887760+farie82@users.noreply.github.com> --- code/modules/mining/mint.dm | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/code/modules/mining/mint.dm b/code/modules/mining/mint.dm index 9cabe4ac486..857bd1e4b6e 100644 --- a/code/modules/mining/mint.dm +++ b/code/modules/mining/mint.dm @@ -81,8 +81,11 @@ updateUsrDialog() return - while(coinsToProduce > 0 && materials.use_amount_type(coin_mat, chosen)) - create_coins(M.coin_type) + while(coinsToProduce > 0 && materials.can_use_amount(coin_mat, chosen)) + if(!create_coins(M.coin_type)) + visible_message("[src] stops printing to prevent an overflow.") + break + materials.use_amount_type(coin_mat, chosen) coinsToProduce-- newCoins++ updateUsrDialog() @@ -95,10 +98,15 @@ /obj/machinery/mineral/mint/proc/create_coins(P) var/turf/T = get_step(src,output_dir) - if(T) - var/obj/item/O = new P(src) - var/obj/item/storage/bag/money/M = locate(/obj/item/storage/bag/money, T) - if(!M) - M = new /obj/item/storage/bag/money(src) - unload_mineral(M) - O.forceMove(M) + if(!T) + return FALSE + var/obj/item/O = new P(src) + var/obj/item/storage/bag/money/M = locate(/obj/item/storage/bag/money, T) + if(!M) + M = new /obj/item/storage/bag/money(src) + unload_mineral(M) + else if(!M.can_be_inserted(O, FALSE)) // First coin will always fit. But will the Xth? + qdel(O) + return FALSE + O.forceMove(M) + return TRUE