From d0e85e5271b27c4caf58d7c394d7b2f5c2904a3c Mon Sep 17 00:00:00 2001 From: Bjamcham <107899953+Bjamcham@users.noreply.github.com> Date: Mon, 9 Oct 2023 15:43:45 -0400 Subject: [PATCH] Expanded Passive Gate Functionality (#22736) * Questionable choices * Syntax fix * Code improvement --- .../components/binary_devices/passive_gate.dm | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/code/modules/atmospherics/machinery/components/binary_devices/passive_gate.dm b/code/modules/atmospherics/machinery/components/binary_devices/passive_gate.dm index 0352d11b4ad..a2d8103b114 100644 --- a/code/modules/atmospherics/machinery/components/binary_devices/passive_gate.dm +++ b/code/modules/atmospherics/machinery/components/binary_devices/passive_gate.dm @@ -37,17 +37,21 @@ var/output_starting_pressure = air2.return_pressure() var/input_starting_pressure = air1.return_pressure() - if(output_starting_pressure >= min(target_pressure,input_starting_pressure-10)) + if(output_starting_pressure >= min(target_pressure,input_starting_pressure - 10)) //No need to pump gas if target is already reached or input pressure is too low //Need at least 10 KPa difference to overcome friction in the mechanism return 1 + if(target_pressure >= input_starting_pressure - 10) + //Gas will not pump if the input pressure is lower than the target + return 1 + //Calculate necessary moles to transfer using PV = nRT - if((air1.total_moles() > 0) && (air1.temperature>0)) - var/pressure_delta = min(target_pressure - output_starting_pressure, (input_starting_pressure - output_starting_pressure)/2) + if((air1.total_moles() > 0) && (air1.temperature > 0)) + var/pressure_delta = min(target_pressure - output_starting_pressure, (input_starting_pressure - output_starting_pressure) / 2) //Can not have a pressure delta that would cause output_pressure > input_pressure - var/transfer_moles = pressure_delta*air2.volume/(air1.temperature * R_IDEAL_GAS_EQUATION) + var/transfer_moles = pressure_delta * air2.volume/(air1.temperature * R_IDEAL_GAS_EQUATION) //Actually transfer the gas var/datum/gas_mixture/removed = air1.remove(transfer_moles)