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