Fixed stacks sometimes having the wrong amount if created on another stack

This commit is contained in:
Tad Hardesty
2018-05-10 23:23:51 -07:00
committed by letterjay
parent 20ac9089a7
commit 021f30f0c0
24 changed files with 174 additions and 112 deletions

View File

@@ -303,13 +303,12 @@
desired = input("How many sheets?", "How many sheets would you like to smelt?", 1) as null|num
var/amount = round(min(desired,50,smelt_amount))
materials.use_amount(alloy.materials, amount)
var/output = new alloy.build_path(src)
if(istype(output, /obj/item/stack/sheet))
var/obj/item/stack/sheet/produced_alloy = output
produced_alloy.amount = amount
unload_mineral(produced_alloy)
var/output
if(ispath(alloy.build_path, /obj/item/stack/sheet))
output = new alloy.build_path(src, amount)
else
unload_mineral(output)
output = new alloy.build_path(src)
unload_mineral(output)
else
to_chat(usr, "<span class='warning'>Required access not found.</span>")
return TRUE

View File

@@ -44,8 +44,7 @@
if(!(text2path(href_list["release"]) in machine.stack_list))
return //someone tried to spawn materials by spoofing hrefs
var/obj/item/stack/sheet/inp = machine.stack_list[text2path(href_list["release"])]
var/obj/item/stack/sheet/out = new inp.type()
out.amount = inp.amount
var/obj/item/stack/sheet/out = new inp.type(null, inp.amount)
inp.amount = 0
machine.unload_mineral(out)
@@ -81,14 +80,12 @@
/obj/machinery/mineral/stacking_machine/proc/process_sheet(obj/item/stack/sheet/inp)
if(!(inp.type in stack_list)) //It's the first of this sheet added
var/obj/item/stack/sheet/s = new inp.type(src,0)
s.amount = 0
var/obj/item/stack/sheet/s = new inp.type(src, 0)
stack_list[inp.type] = s
var/obj/item/stack/sheet/storage = stack_list[inp.type]
storage.amount += inp.amount //Stack the sheets
qdel(inp) //Let the old sheet garbage collect
while(storage.amount > stack_amt) //Get rid of excessive stackage
var/obj/item/stack/sheet/out = new inp.type()
out.amount = stack_amt
var/obj/item/stack/sheet/out = new inp.type(null, stack_amt)
unload_mineral(out)
storage.amount -= stack_amt