Pipe networks now cache their total volume

This commit is contained in:
mwerezak
2014-08-03 22:41:31 -04:00
parent 6eb2fe3028
commit 14b57e3560
5 changed files with 32 additions and 23 deletions
@@ -124,7 +124,7 @@
network1.update = 1
else //external -> internal
if (node2 && (environment.temperature || air2.temperature))
var/output_volume = air2.volume * air2.group_multiplier
var/output_volume = air2.volume + (network2? network2.volume : 0)
var/air_temperature = air2.temperature? air2.temperature : environment.temperature
var/transfer_moles = pressure_delta*output_volume/(air_temperature * R_IDEAL_GAS_EQUATION)
@@ -203,7 +203,9 @@
/obj/machinery/atmospherics/binary/dp_vent_pump/examine()
set src in oview(1)
..()
usr << "A small gauge in the corner reads [round(last_flow_rate, 0.1)] L/s; [round(last_power_draw)] W"
if (get_dist(usr, src) <= 1)
usr << "A small gauge in the corner reads [round(last_flow_rate, 0.1)] L/s; [round(last_power_draw)] W"
/obj/machinery/atmospherics/unary/vent_pump/power_change()
var/old_stat = stat
@@ -74,18 +74,15 @@ Thus, the two variables affect pump operation are set in New():
var/power_draw = -1
var/pressure_delta = target_pressure - air2.return_pressure()
if(pressure_delta > 0.01)
/* TODO Uncomment this once we have a good way to get the volume of a pipe network.
if (air1.temperature > 0 || air2.temperature > 0)
//Figure out how much gas to transfer to meet the target pressure.
var/air_temperature = (sink.temperature > 0)? sink.temperature : source.temperature
var/output_volume = sink.volume * sink.group_multiplier
//Return the number of moles that would have to be transfered to bring sink to the target pressure
var/transfer_moles = pressure_delta*output_volume/(air_temperature * R_IDEAL_GAS_EQUATION)
*/
power_draw = pump_gas(air1, air2, air1.total_moles, active_power_usage)
if(pressure_delta > 0.01 && (air1.temperature > 0 || air2.temperature > 0))
//Figure out how much gas to transfer to meet the target pressure.
var/air_temperature = (air2.temperature > 0)? air2.temperature : air1.temperature
var/output_volume = air2.volume + (network2? network2.volume : 0)
//get the number of moles that would have to be transfered to bring sink to the target pressure
var/transfer_moles = pressure_delta*output_volume/(air_temperature * R_IDEAL_GAS_EQUATION)
power_draw = pump_gas(air1, air2, transfer_moles, active_power_usage)
if(network1)
network1.update = 1