From ceea41b5fe30ef91b7cc190f276e01014c034d08 Mon Sep 17 00:00:00 2001 From: Ashe Higgs Date: Sat, 10 Mar 2018 15:37:03 -0500 Subject: [PATCH] Fixes slow circuit cloning breaking with some circuits, and makes it use world time checks instead of decrementing countdowns (#36255) * Fixes slowcloning breaking with nonints * Refactors to use timestamps and not seconds --- code/modules/integrated_electronics/core/printer.dm | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/code/modules/integrated_electronics/core/printer.dm b/code/modules/integrated_electronics/core/printer.dm index c8ca7514fd..5576b42afc 100644 --- a/code/modules/integrated_electronics/core/printer.dm +++ b/code/modules/integrated_electronics/core/printer.dm @@ -12,7 +12,7 @@ var/debug = FALSE // If it's upgraded and can clone, even without config settings. var/current_category = null var/cloning = FALSE // If the printer is currently creating a circuit - var/clone_countdown = 0 // This counts down when cloning is in progress, and clones the circuit when it's ready + var/clone_countdown = 0 // Timestamp for when to print the circuit var/recycling = FALSE // If an assembly is being emptied into this printer var/list/program // Currently loaded save, in form of list @@ -42,8 +42,7 @@ /obj/item/device/integrated_circuit_printer/process() if(!cloning) STOP_PROCESSING(SSprocessing, src) - clone_countdown-- - if(!clone_countdown || fast_clone) + if(world.time >= clone_countdown || fast_clone) var/turf/T = get_turf(src) T.visible_message("[src] has finished printing its assembly!") playsound(get_turf(T), 'sound/items/poster_being_created.ogg', 50, TRUE) @@ -142,7 +141,7 @@ if(!program) HTML += " {[fast_clone ? "Print" : "Begin Printing"] Assembly}" else if(cloning) - HTML += " {Cancel Print} - [clone_countdown] second(s) remaining until completion" + HTML += " {Cancel Print} - [DisplayTimeText(max(0, clone_countdown - world.time))] remaining until completion" else HTML += " {[fast_clone ? "Print" : "Begin Printing"] Assembly}" @@ -273,11 +272,11 @@ if(!materials.use_amount_type(program["metal_cost"], MAT_METAL)) to_chat(usr, "You need [program["metal_cost"]] metal to build that!") return - var/cloning_time = program["metal_cost"] / 150 + var/cloning_time = round(program["metal_cost"] / 15) cloning_time = min(cloning_time, MAX_CIRCUIT_CLONE_TIME) cloning = TRUE - clone_countdown = cloning_time - to_chat(usr, "You begin printing a custom assembly. This will take approximately [round(cloning_time / 60, 0.1)] minute(s). You can still print \ + clone_countdown = world.time + cloning_time + to_chat(usr, "You begin printing a custom assembly. This will take approximately [DisplayTimeText(cloning_time)]. You can still print \ off normal parts during this time.") playsound(src, 'sound/items/poster_being_created.ogg', 50, TRUE) START_PROCESSING(SSprocessing, src)