From 99d5a4970b3ea811576503b10622a3cce2b37801 Mon Sep 17 00:00:00 2001 From: Artorp Date: Wed, 25 Feb 2015 22:23:40 +0100 Subject: [PATCH 1/3] Autolathe queue shows items being processed --- code/game/machinery/autolathe.dm | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/code/game/machinery/autolathe.dm b/code/game/machinery/autolathe.dm index b7cdd87cdaa..753f67bb8d0 100644 --- a/code/game/machinery/autolathe.dm +++ b/code/game/machinery/autolathe.dm @@ -16,7 +16,7 @@ var/operating = 0.0 var/list/queue = list() - var/queue_max_len = 10 + var/queue_max_len = 12 var/turf/BuildTurf anchored = 1.0 var/list/L = list() @@ -190,16 +190,17 @@ ///////////////// //href protection - being_built = files.FindDesignByID(href_list["make"]) //check if it's a valid design - if(!being_built) + var/datum/design/design_last_ordered + design_last_ordered = files.FindDesignByID(href_list["make"]) //check if it's a valid design + if(!design_last_ordered) return - if(!(being_built.build_type & AUTOLATHE)) + if(!(design_last_ordered.build_type & AUTOLATHE)) return //multiplier checks : only stacks can have one and its value is 1, 10 ,25 or max_multiplier var/multiplier = text2num(href_list["multiplier"]) - var/max_multiplier = min(50, being_built.materials["$metal"] ?round(m_amount/being_built.materials["$metal"]):INFINITY,being_built.materials["$glass"]?round(g_amount/being_built.materials["$glass"]):INFINITY) - var/is_stack = ispath(being_built.build_path, /obj/item/stack) + var/max_multiplier = min(50, design_last_ordered.materials["$metal"] ?round(m_amount/design_last_ordered.materials["$metal"]):INFINITY,design_last_ordered.materials["$glass"]?round(g_amount/design_last_ordered.materials["$glass"]):INFINITY) + var/is_stack = ispath(design_last_ordered.build_path, /obj/item/stack) if(!is_stack && (multiplier > 1)) return @@ -207,8 +208,8 @@ return ///////////////// - if(queue.len1) - output += "[initial(part.name)][is_stack?" (x[multiplier])":null] - [i>1?"":null] [i↓":null] Remove" + output += "[initial(D.name)][is_stack?" (x[multiplier])":null] - [i>1?"":null] [i↓":null] Remove" temp_metal = max(temp_metal-LL[1],1) temp_glass = max(temp_glass-LL[2],1) @@ -373,6 +379,7 @@ build_item(D,multiplier) D = listgetindex(listgetindex(queue, 1),1) multiplier = listgetindex(listgetindex(queue,1),2) + being_built = null //visible_message("\icon[src] \The [src] beeps, \"Queue processing finished successfully.\"") /obj/machinery/autolathe/proc/main_win(mob/user) From 90e346fef3252e5d5d38f1c08474b662573be601 Mon Sep 17 00:00:00 2001 From: Artorp Date: Thu, 26 Feb 2015 00:02:13 +0100 Subject: [PATCH 2/3] Autolathe queue support for stacks - Processing line (first item in list) will now show stack multiplier where applicable - Resources are taken before item is being created, to properly update the UI --- code/game/machinery/autolathe.dm | 37 ++++++++++++++++++++++---------- 1 file changed, 26 insertions(+), 11 deletions(-) diff --git a/code/game/machinery/autolathe.dm b/code/game/machinery/autolathe.dm index 753f67bb8d0..aa2b07ef77f 100644 --- a/code/game/machinery/autolathe.dm +++ b/code/game/machinery/autolathe.dm @@ -34,7 +34,7 @@ var/prod_coeff var/datum/wires/autolathe/wires = null - var/datum/design/being_built + var/list/being_built = list() var/datum/research/files var/list/datum/design/matching_designs var/selected_category @@ -264,20 +264,22 @@ var/glass_cost = D.materials["$glass"] var/power = max(2000, (metal_cost+glass_cost)*multiplier/5) if (can_build(D,multiplier)) - being_built = D + being_built = list(D,multiplier) use_power(power) icon_state = "autolathe" flick("autolathe_n",src) - updateUsrDialog() - sleep(32/coeff) if(is_stack) m_amount -= metal_cost*multiplier g_amount -= glass_cost*multiplier - var/obj/item/stack/S = new D.build_path(BuildTurf) - S.amount = multiplier else m_amount -= metal_cost/coeff g_amount -= glass_cost/coeff + updateUsrDialog() + sleep(32/coeff) + if(is_stack) + var/obj/item/stack/S = new D.build_path(BuildTurf) + S.amount = multiplier + else var/obj/item/new_item = new D.build_path(BuildTurf) new_item.m_amt /= coeff new_item.g_amt /= coeff @@ -313,6 +315,13 @@ OutputList[2] = (D.materials["$glass"] / coeff)*multiplier return OutputList +/obj/machinery/autolathe/proc/get_processing_line() + var/datum/design/D = being_built[1] + var/multiplier = being_built[2] + var/is_stack = (multiplier>1) + var/output = "PROCESSING: [initial(D.name)][is_stack?" (x[multiplier])":null]" + return output + /obj/machinery/autolathe/proc/get_queue() var/temp_metal = m_amount var/temp_glass = g_amount @@ -320,14 +329,18 @@ output += "
" output += "Queue contains:" if (!istype(queue) || !queue.len) - if(being_built) - output += "
  1. PROCESSING: [initial(being_built.name)]
" + if(being_built.len) + output += "
  1. " + output += get_processing_line() + output += "
" else output += "
Nothing" else output += "
    " - if(being_built) - output += "
  1. PROCESSING: [initial(being_built.name)]
  2. " + if(being_built.len) + output += "
  3. " + output += get_processing_line() + output += "
  4. " var/i = 0 var/datum/design/D for(var/list/L in queue) @@ -369,17 +382,19 @@ return while(D) if(stat&(NOPOWER|BROKEN)) + being_built = new /list() return 0 if(!can_build(D,multiplier)) visible_message("\icon[src] \The [src] beeps, \"Not enough resources. Queue processing terminated.\"") queue = list() + being_built = new /list() return 0 remove_from_queue(1) build_item(D,multiplier) D = listgetindex(listgetindex(queue, 1),1) multiplier = listgetindex(listgetindex(queue,1),2) - being_built = null + being_built = new /list() //visible_message("\icon[src] \The [src] beeps, \"Queue processing finished successfully.\"") /obj/machinery/autolathe/proc/main_win(mob/user) From 8f1081a86faf51cd6455910a342ab80fe31c0e0f Mon Sep 17 00:00:00 2001 From: Artorp Date: Thu, 26 Feb 2015 00:41:58 +0100 Subject: [PATCH 3/3] Autolathe queue fix Old oversight, stacks and cost calculation was bugged --- code/game/machinery/autolathe.dm | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/code/game/machinery/autolathe.dm b/code/game/machinery/autolathe.dm index aa2b07ef77f..6c13db51ad5 100644 --- a/code/game/machinery/autolathe.dm +++ b/code/game/machinery/autolathe.dm @@ -292,17 +292,17 @@ /obj/machinery/autolathe/proc/can_build(var/datum/design/D,var/multiplier=1,var/custom_metal,var/custom_glass) var/coeff = get_coeff(D) - - var/m_amount_tmp = m_amount + + var/metal_amount = m_amount if(custom_metal) - m_amount_tmp = custom_metal - var/g_amount_tmp = g_amount + metal_amount = custom_metal + var/glass_amount = g_amount if(custom_glass) - g_amount_tmp = custom_glass - - if(D.materials["$metal"] && (m_amount_tmp*multiplier < (D.materials["$metal"] / coeff))) + glass_amount = custom_glass + + if(D.materials["$metal"] && (metal_amount < (multiplier*D.materials["$metal"] / coeff))) return 0 - if(D.materials["$glass"] && (g_amount_tmp*multiplier < (D.materials["$glass"] / coeff))) + if(D.materials["$glass"] && (glass_amount < (multiplier*D.materials["$glass"] / coeff))) return 0 return 1