From a40cdbf97f1266173c6ce59cd2213e752a222b25 Mon Sep 17 00:00:00 2001 From: SkyratBot <59378654+SkyratBot@users.noreply.github.com> Date: Sun, 25 Apr 2021 04:30:34 +0200 Subject: [PATCH] [MIRROR] Small Crystallizer Fixes (#5166) * Small Crystallizer Fixes (#58614) fix: fixed crystallizer locking up when the input port is devoid of proper gases. fix: fixed crystallizer conducting heat with the heat loop only on reactions. It should conduct at all times now. * Small Crystallizer Fixes Co-authored-by: vincentiusvin <54709710+vincentiusvin@users.noreply.github.com> --- .../gas_recipe_machines/crystallizer.dm | 32 ++++++++++--------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/code/modules/atmospherics/machinery/components/gas_recipe_machines/crystallizer.dm b/code/modules/atmospherics/machinery/components/gas_recipe_machines/crystallizer.dm index fb85d8f5d3b..9d71e5f5929 100644 --- a/code/modules/atmospherics/machinery/components/gas_recipe_machines/crystallizer.dm +++ b/code/modules/atmospherics/machinery/components/gas_recipe_machines/crystallizer.dm @@ -131,17 +131,6 @@ ///Calculation for the heat of the various gas mixes and controls the quality of the item /obj/machinery/atmospherics/components/binary/crystallizer/proc/heat_calculations() - var/datum/gas_mixture/cooling_port = airs[1] - if(cooling_port.total_moles() > MINIMUM_MOLE_COUNT) - if(internal.total_moles() > 0) - var/coolant_temperature_delta = cooling_port.temperature - internal.temperature - var/cooling_heat_capacity = cooling_port.heat_capacity() - var/internal_heat_capacity = internal.heat_capacity() - var/cooling_heat_amount = HIGH_CONDUCTIVITY_RATIO * coolant_temperature_delta * (cooling_heat_capacity * internal_heat_capacity / (cooling_heat_capacity + internal_heat_capacity)) - cooling_port.temperature = max(cooling_port.temperature - cooling_heat_amount / cooling_heat_capacity, TCMB) - internal.temperature = max(internal.temperature + cooling_heat_amount / internal_heat_capacity, TCMB) - update_parents() - if( (internal.temperature >= (selected_recipe.min_temp * MIN_DEVIATION_RATE) && internal.temperature <= selected_recipe.min_temp) || \ (internal.temperature >= selected_recipe.max_temp && internal.temperature <= (selected_recipe.max_temp * MAX_DEVIATION_RATE))) quality_loss = min(quality_loss + 1.5, 100) @@ -155,6 +144,19 @@ else if(selected_recipe.reaction_type == "exothermic") internal.temperature = max(internal.temperature + (selected_recipe.energy_release / internal.heat_capacity()), TCMB) +///Conduction between the internal gasmix and the moderating (cooling/heating) gasmix. +/obj/machinery/atmospherics/components/binary/crystallizer/proc/heat_conduction() + var/datum/gas_mixture/cooling_port = airs[1] + if(cooling_port.total_moles() > MINIMUM_MOLE_COUNT) + if(internal.total_moles() > 0) + var/coolant_temperature_delta = cooling_port.temperature - internal.temperature + var/cooling_heat_capacity = cooling_port.heat_capacity() + var/internal_heat_capacity = internal.heat_capacity() + var/cooling_heat_amount = HIGH_CONDUCTIVITY_RATIO * coolant_temperature_delta * (cooling_heat_capacity * internal_heat_capacity / (cooling_heat_capacity + internal_heat_capacity)) + cooling_port.temperature = max(cooling_port.temperature - cooling_heat_amount / cooling_heat_capacity, TCMB) + internal.temperature = max(internal.temperature + cooling_heat_amount / internal_heat_capacity, TCMB) + update_parents() + ///Calculate the total moles needed for the recipe /obj/machinery/atmospherics/components/binary/crystallizer/proc/moles_calculations() var/amounts = 0 @@ -172,15 +174,15 @@ if(!on || !is_operational || selected_recipe == null) return - if(!check_gas_requirements()) - return - - inject_gases() + if(check_gas_requirements()) + inject_gases() if(!internal.total_moles()) update_parents() return + heat_conduction() + if(internal_check()) if(check_temp_requirements()) heat_calculations()