From e20eee52ada250bde46972ed9b9a409ad762cd2d Mon Sep 17 00:00:00 2001 From: duncathan Date: Thu, 14 Jan 2016 14:02:01 -0600 Subject: [PATCH] fixes reconcile_air(); makes gas flow properly through pipes --- code/ATMOSPHERICS/datum_pipeline.dm | 17 +++++++++-------- code/LINDA/LINDA_turf_tile.dm | 8 ++------ code/__DEFINES/atmospherics.dm | 4 ++-- code/datums/gas_mixture.dm | 1 - code/game/machinery/atmoalter/canister.dm | 7 ++++--- 5 files changed, 17 insertions(+), 20 deletions(-) diff --git a/code/ATMOSPHERICS/datum_pipeline.dm b/code/ATMOSPHERICS/datum_pipeline.dm index 7ba93a55298..6c765cd1c11 100644 --- a/code/ATMOSPHERICS/datum_pipeline.dm +++ b/code/ATMOSPHERICS/datum_pipeline.dm @@ -195,8 +195,8 @@ var/pipenetwarnings = 10 var/list/datum/pipeline/PL = list() PL += src - for(var/i=1;i<=PL.len;i++) - var/datum/pipeline/P = PL[i] + for(var/i in PL) + var/datum/pipeline/P = i GL += P.air GL += P.other_airs for(var/obj/machinery/atmospherics/components/binary/valve/V in P.other_atmosmch) @@ -209,18 +209,18 @@ var/pipenetwarnings = 10 var/total_thermal_energy = 0 var/total_heat_capacity = 0 - var/datum/gas_mixture/total_gas_mixture = new + var/datum/gas_mixture/total_gas_mixture = new(0) - for(var/datum/gas_mixture/G in GL) + for(var/i in GL) + var/datum/gas_mixture/G = i total_gas_mixture.volume += G.volume + total_gas_mixture.merge(G) + total_thermal_energy += G.thermal_energy() total_heat_capacity += G.heat_capacity() - if(total_heat_capacity > 0) - total_gas_mixture.temperature = total_thermal_energy/total_heat_capacity - else - total_gas_mixture.temperature = 0 + total_gas_mixture.temperature = total_heat_capacity ? total_thermal_energy/total_heat_capacity : 0 if(total_gas_mixture.volume > 0) //Update individual gas_mixtures by volume ratio @@ -229,3 +229,4 @@ var/pipenetwarnings = 10 var/list/G_gases = G.gases for(var/id in G_gases) G_gases[id][MOLES] *= G.volume/total_gas_mixture.volume + diff --git a/code/LINDA/LINDA_turf_tile.dm b/code/LINDA/LINDA_turf_tile.dm index d11b2ab02ac..fdada2d153d 100644 --- a/code/LINDA/LINDA_turf_tile.dm +++ b/code/LINDA/LINDA_turf_tile.dm @@ -219,15 +219,11 @@ /turf/simulated/proc/update_visuals() var/list/new_overlay_types = tile_graphic() - for(var/overlay in atmos_overlay_types) - if(overlay in new_overlay_types) - continue //doesn't remove overlays that would only be added + for(var/overlay in atmos_overlay_types-new_overlay_types) //doesn't remove overlays that would only be added overlays -= overlay atmos_overlay_types -= overlay - for(var/overlay in new_overlay_types) - if(overlay in atmos_overlay_types) - continue //doesn't add overlays that already exist + for(var/overlay in new_overlay_types-atmos_overlay_types) //doesn't add overlays that already exist overlays += overlay atmos_overlay_types = new_overlay_types diff --git a/code/__DEFINES/atmospherics.dm b/code/__DEFINES/atmospherics.dm index a25c92581e7..8d410ef0764 100644 --- a/code/__DEFINES/atmospherics.dm +++ b/code/__DEFINES/atmospherics.dm @@ -15,8 +15,8 @@ //this is kinda hacky... but it means I don't have to change every single time they're called. #define SPECIFIC_HEAT GAS_META][1 #define GAS_NAME GAS_META][2 -#define GAS_OVERLAY GAS_META][3 -#define MOLES_VISIBLE GAS_META][4 +#define GAS_OVERLAY GAS_META][4 +#define MOLES_VISIBLE GAS_META][3 //stuff you should probably leave well alone! //ATMOS diff --git a/code/datums/gas_mixture.dm b/code/datums/gas_mixture.dm index a95d2a84f1c..69293a78bf9 100644 --- a/code/datums/gas_mixture.dm +++ b/code/datums/gas_mixture.dm @@ -174,7 +174,6 @@ var/list/cached_gases_list = null //Prevents whatever mechanism is causing it to hit negative temperatures. //world << "post [temperature], [procgases["plasma"][MOLES]], [procgases["co2"][MOLES]] */ - fuel_burnt = 0 if(temperature > FIRE_MINIMUM_TEMPERATURE_TO_EXIST) //world << "pre [temperature], [procgases["o2"][MOLES]], [procgases["plasma"][MOLES]]" diff --git a/code/game/machinery/atmoalter/canister.dm b/code/game/machinery/atmoalter/canister.dm index 7b0d3fcd3d8..65674a55c35 100644 --- a/code/game/machinery/atmoalter/canister.dm +++ b/code/game/machinery/atmoalter/canister.dm @@ -22,7 +22,7 @@ use_power = 0 var/release_log = "" var/update_flag = 0 - var/gas_type + var/gas_type = "" /obj/machinery/portable_atmospherics/canister/sleeping_agent @@ -379,8 +379,9 @@ update_flag return 1 /obj/machinery/portable_atmospherics/canister/proc/create_gas() - air_contents.assert_gas(gas_type) - air_contents.gases[gas_type][MOLES] = (src.maximum_pressure*filled)*air_contents.volume/(R_IDEAL_GAS_EQUATION*air_contents.temperature) + if(gas_type) + air_contents.assert_gas(gas_type) + air_contents.gases[gas_type][MOLES] = (src.maximum_pressure*filled)*air_contents.volume/(R_IDEAL_GAS_EQUATION*air_contents.temperature) //Dirty way to fill room with gas. However it is a bit easier to do than creating some floor/engine/n2o -rastaf0