diff --git a/baystation12.dme b/baystation12.dme index 155c00911fb..8a1bdf29c13 100644 --- a/baystation12.dme +++ b/baystation12.dme @@ -1516,11 +1516,6 @@ #include "code\modules\research\xenoarchaeology\artifact\effects\unknown_effect_dnaswitch.dm" #include "code\modules\research\xenoarchaeology\artifact\effects\unknown_effect_emp.dm" #include "code\modules\research\xenoarchaeology\artifact\effects\unknown_effect_forcefield.dm" -#include "code\modules\research\xenoarchaeology\artifact\effects\unknown_effect_gasco2.dm" -#include "code\modules\research\xenoarchaeology\artifact\effects\unknown_effect_gasnitro.dm" -#include "code\modules\research\xenoarchaeology\artifact\effects\unknown_effect_gasoxy.dm" -#include "code\modules\research\xenoarchaeology\artifact\effects\unknown_effect_gasplasma.dm" -#include "code\modules\research\xenoarchaeology\artifact\effects\unknown_effect_gassleeping.dm" #include "code\modules\research\xenoarchaeology\artifact\effects\unknown_effect_goodfeeling.dm" #include "code\modules\research\xenoarchaeology\artifact\effects\unknown_effect_heal.dm" #include "code\modules\research\xenoarchaeology\artifact\effects\unknown_effect_heat.dm" @@ -1693,6 +1688,7 @@ #include "code\WorkInProgress\SkyMarshal\officer_stuff.dm" #include "code\WorkInProgress\SkyMarshal\Ultralight_procs.dm" #include "code\ZAS\_docs.dm" +#include "code\ZAS\_gas_datum.dm" #include "code\ZAS\_gas_mixture.dm" #include "code\ZAS\Airflow.dm" #include "code\ZAS\Atom.dm" diff --git a/code/ATMOSPHERICS/components/trinary_devices/filter.dm b/code/ATMOSPHERICS/components/trinary_devices/filter.dm index 12a4cbdbc4b..d51ff106e59 100755 --- a/code/ATMOSPHERICS/components/trinary_devices/filter.dm +++ b/code/ATMOSPHERICS/components/trinary_devices/filter.dm @@ -82,39 +82,30 @@ obj/machinery/atmospherics/trinary/filter/process() var/datum/gas_mixture/filtered_out = new filtered_out.temperature = removed.temperature + var/list/gases_to_remove + switch(filter_type) if(0) //removing hydrocarbons - filtered_out.toxins = removed.toxins - removed.toxins = 0 - - if(removed.trace_gases.len>0) - for(var/datum/gas/trace_gas in removed.trace_gases) - if(istype(trace_gas, /datum/gas/oxygen_agent_b)) - removed.trace_gases -= trace_gas - filtered_out.trace_gases += trace_gas + gases_to_remove = list(PLASMA /*, OXYGEN_AGENT_B*/) if(1) //removing O2 - filtered_out.oxygen = removed.oxygen - removed.oxygen = 0 + gases_to_remove = list(OXYGEN) if(2) //removing N2 - filtered_out.nitrogen = removed.nitrogen - removed.nitrogen = 0 + gases_to_remove = list(NITROGEN) if(3) //removing CO2 - filtered_out.carbon_dioxide = removed.carbon_dioxide - removed.carbon_dioxide = 0 + gases_to_remove = list(CARBON_DIOXIDE) if(4)//removing N2O - if(removed.trace_gases.len>0) - for(var/datum/gas/trace_gas in removed.trace_gases) - if(istype(trace_gas, /datum/gas/sleeping_agent)) - removed.trace_gases -= trace_gas - filtered_out.trace_gases += trace_gas + gases_to_remove = list(NITROUS_OXIDE) else filtered_out = null + for(var/gasid in gases_to_remove) + filtered_out.adjust_gas(gasid, removed.get_moles_by_id(gasid), 0) + removed.set_gas(gasid, 0, 0) air2.merge(filtered_out) air3.merge(removed) diff --git a/code/ATMOSPHERICS/components/unary/oxygen_generator.dm b/code/ATMOSPHERICS/components/unary/oxygen_generator.dm index 39282f50d8c..770d5073100 100644 --- a/code/ATMOSPHERICS/components/unary/oxygen_generator.dm +++ b/code/ATMOSPHERICS/components/unary/oxygen_generator.dm @@ -41,7 +41,7 @@ obj/machinery/atmospherics/unary/oxygen_generator/process() var/added_oxygen = oxygen_content - total_moles air_contents.temperature = (current_heat_capacity*air_contents.temperature + 20*added_oxygen*T0C)/(current_heat_capacity+20*added_oxygen) - air_contents.oxygen += added_oxygen + air_contents.adjust_gas(OXYGEN, added_oxygen, 0) if(network) network.update = 1 diff --git a/code/ATMOSPHERICS/components/unary/tank.dm b/code/ATMOSPHERICS/components/unary/tank.dm index d57d6145f88..d666549eccb 100644 --- a/code/ATMOSPHERICS/components/unary/tank.dm +++ b/code/ATMOSPHERICS/components/unary/tank.dm @@ -29,7 +29,7 @@ /obj/machinery/atmospherics/unary/tank/carbon_dioxide/New() ..() - air_contents.carbon_dioxide = (25*ONE_ATMOSPHERE)*(starting_volume)/(R_IDEAL_GAS_EQUATION*air_contents.temperature) + air_contents.set_gas(CARBON_DIOXIDE, (25*ONE_ATMOSPHERE)*(starting_volume)/(R_IDEAL_GAS_EQUATION*air_contents.temperature), 0) /obj/machinery/atmospherics/unary/tank/toxins @@ -39,8 +39,9 @@ /obj/machinery/atmospherics/unary/tank/toxins/New() ..() - air_contents.toxins = (25*ONE_ATMOSPHERE)*(starting_volume)/(R_IDEAL_GAS_EQUATION*air_contents.temperature) + air_contents.set_gas(PLASMA, (25*ONE_ATMOSPHERE)*(starting_volume)/(R_IDEAL_GAS_EQUATION*air_contents.temperature), 0) +/* /obj/machinery/atmospherics/unary/tank/oxygen_agent_b icon = 'icons/obj/atmospherics/red_orange_pipe_tank.dmi' @@ -49,11 +50,8 @@ /obj/machinery/atmospherics/unary/tank/oxygen_agent_b/New() ..() - var/datum/gas/oxygen_agent_b/trace_gas = new - trace_gas.moles = (25*ONE_ATMOSPHERE)*(starting_volume)/(R_IDEAL_GAS_EQUATION*air_contents.temperature) - - air_contents.trace_gases += trace_gas - + air_contents.set_gas(OXYGEN_AGENT_B, (25*ONE_ATMOSPHERE)*(starting_volume)/(R_IDEAL_GAS_EQUATION*air_contents.temperature), 0) +*/ /obj/machinery/atmospherics/unary/tank/oxygen icon = 'icons/obj/atmospherics/blue_pipe_tank.dmi' @@ -62,7 +60,7 @@ /obj/machinery/atmospherics/unary/tank/oxygen/New() ..() - air_contents.oxygen = (25*ONE_ATMOSPHERE)*(starting_volume)/(R_IDEAL_GAS_EQUATION*air_contents.temperature) + air_contents.set_gas(OXYGEN, (25*ONE_ATMOSPHERE)*(starting_volume)/(R_IDEAL_GAS_EQUATION*air_contents.temperature), 0) /obj/machinery/atmospherics/unary/tank/nitrogen icon = 'icons/obj/atmospherics/red_pipe_tank.dmi' @@ -71,7 +69,7 @@ /obj/machinery/atmospherics/unary/tank/nitrogen/New() ..() - air_contents.nitrogen = (25*ONE_ATMOSPHERE)*(starting_volume)/(R_IDEAL_GAS_EQUATION*air_contents.temperature) + air_contents.set_gas(NITROGEN, (25*ONE_ATMOSPHERE)*(starting_volume)/(R_IDEAL_GAS_EQUATION*air_contents.temperature), 0) /obj/machinery/atmospherics/unary/tank/air icon = 'icons/obj/atmospherics/red_pipe_tank.dmi' @@ -80,8 +78,8 @@ /obj/machinery/atmospherics/unary/tank/air/New() ..() - air_contents.oxygen = (25*ONE_ATMOSPHERE*O2STANDARD)*(starting_volume)/(R_IDEAL_GAS_EQUATION*air_contents.temperature) - air_contents.nitrogen = (25*ONE_ATMOSPHERE*N2STANDARD)*(starting_volume)/(R_IDEAL_GAS_EQUATION*air_contents.temperature) + air_contents.set_gas(OXYGEN, (25*ONE_ATMOSPHERE*O2STANDARD)*(starting_volume)/(R_IDEAL_GAS_EQUATION*air_contents.temperature), 0) + air_contents.set_gas(NITROGEN, (25*ONE_ATMOSPHERE*N2STANDARD)*(starting_volume)/(R_IDEAL_GAS_EQUATION*air_contents.temperature), 0) /obj/machinery/atmospherics/unary/tank/update_icon() if(node) diff --git a/code/ATMOSPHERICS/components/unary/vent_scrubber.dm b/code/ATMOSPHERICS/components/unary/vent_scrubber.dm index 0bf800b2ef0..a212dfc7d09 100644 --- a/code/ATMOSPHERICS/components/unary/vent_scrubber.dm +++ b/code/ATMOSPHERICS/components/unary/vent_scrubber.dm @@ -14,11 +14,10 @@ var/on = 0 var/scrubbing = 1 //0 = siphoning, 1 = scrubbing - var/scrub_CO2 = 1 - var/scrub_Toxins = 1 - var/scrub_N2O = 0 - var/scrub_O2 = 0 - var/scrub_N2 = 0 + + var/list/scrubbing_gases = list(CARBON_DIOXIDE, //list of gas ids we scrub + PLASMA, + NITROUS_OXIDE) var/volume_rate = 1000 // 120 var/panic = 0 //is this scrubber panicked? @@ -46,7 +45,7 @@ icon_state = "[hidden]weld" return var/suffix="" - if(scrub_O2) + if(OXYGEN in scrubbing_gases) suffix="1" if(node && on && !(stat & (NOPOWER|BROKEN))) if(scrubbing) @@ -82,11 +81,11 @@ "power" = on, "scrubbing" = scrubbing, "panic" = panic, - "filter_co2" = scrub_CO2, - "filter_tox" = scrub_Toxins, - "filter_n2o" = scrub_N2O, - "filter_o2" = scrub_O2, - "filter_n2" = scrub_N2, + "filter_co2" = (CARBON_DIOXIDE in scrubbing_gases), + "filter_tox" = (PLASMA in scrubbing_gases), + "filter_n2o" = (NITROUS_OXIDE in scrubbing_gases), + "filter_o2" = (OXYGEN in scrubbing_gases), + "filter_n2" = (NITROGEN in scrubbing_gases), "sigtype" = "status" ) if(!areaMaster.air_scrub_names[id_tag]) @@ -124,13 +123,7 @@ var/datum/gas_mixture/environment = loc.return_air() if(scrubbing) - // Are we scrubbing gasses that are present? - if(\ - (scrub_Toxins && environment.toxins > 0) ||\ - (scrub_CO2 && environment.carbon_dioxide > 0) ||\ - (scrub_N2O && environment.trace_gases.len > 0) ||\ - (scrub_O2 && environment.oxygen > 0) ||\ - (scrub_N2 && environment.nitrogen > 0)) + if(scrubbing_gases.len) var/transfer_moles = min(1, volume_rate/environment.volume)*environment.total_moles() //Take a gas sample @@ -138,35 +131,21 @@ if (isnull(removed)) //in space return - //Filter it var/datum/gas_mixture/filtered_out = new + + for(var/gasid in removed.gases) + if(!(gasid in scrubbing_gases)) + continue + + filtered_out.adjust_gas(gasid, removed.get_moles_by_id(gasid), 0) //move to filtered + removed.set_gas(gasid, 0, 0) //set to 0 + + //Filter it + filtered_out.temperature = removed.temperature - if(scrub_Toxins) - filtered_out.toxins = removed.toxins - removed.toxins = 0 - - if(scrub_CO2) - filtered_out.carbon_dioxide = removed.carbon_dioxide - removed.carbon_dioxide = 0 - - if(scrub_O2) - filtered_out.oxygen = removed.oxygen - removed.oxygen = 0 - - if(scrub_N2) - filtered_out.nitrogen = removed.nitrogen - removed.nitrogen = 0 - - if(removed.trace_gases.len>0) - for(var/datum/gas/trace_gas in removed.trace_gases) - if(istype(trace_gas, /datum/gas/oxygen_agent_b)) - removed.trace_gases -= trace_gas - filtered_out.trace_gases += trace_gas - else if(istype(trace_gas, /datum/gas/sleeping_agent) && scrub_N2O) - removed.trace_gases -= trace_gas - filtered_out.trace_gases += trace_gas - + filtered_out.update_values() + removed.update_values() //Remix the resulting gases air_contents.merge(filtered_out) @@ -239,29 +218,29 @@ scrubbing = !scrubbing if(signal.data["co2_scrub"] != null) - scrub_CO2 = text2num(signal.data["co2_scrub"]) + toggle_gas_scrub(CARBON_DIOXIDE, text2num(signal.data["co2_scrub"])) if(signal.data["toggle_co2_scrub"]) - scrub_CO2 = !scrub_CO2 + toggle_gas_scrub(CARBON_DIOXIDE) if(signal.data["tox_scrub"] != null) - scrub_Toxins = text2num(signal.data["tox_scrub"]) + toggle_gas_scrub(PLASMA, text2num(signal.data["tox_scrub"])) if(signal.data["toggle_tox_scrub"]) - scrub_Toxins = !scrub_Toxins + toggle_gas_scrub(PLASMA) if(signal.data["n2o_scrub"] != null) - scrub_N2O = text2num(signal.data["n2o_scrub"]) + toggle_gas_scrub(NITROUS_OXIDE, text2num(signal.data["n2o_scrub"])) if(signal.data["toggle_n2o_scrub"]) - scrub_N2O = !scrub_N2O + toggle_gas_scrub(NITROUS_OXIDE) if(signal.data["o2_scrub"] != null) - scrub_O2 = text2num(signal.data["o2_scrub"]) + toggle_gas_scrub(OXYGEN, text2num(signal.data["o2_scrub"])) if(signal.data["toggle_o2_scrub"]) - scrub_O2 = !scrub_O2 + toggle_gas_scrub(OXYGEN) if(signal.data["n2_scrub"] != null) - scrub_N2 = text2num(signal.data["n2_scrub"]) + toggle_gas_scrub(NITROGEN, text2num(signal.data["n2_scrub"])) if(signal.data["toggle_n2_scrub"]) - scrub_N2 = !scrub_N2 + toggle_gas_scrub(NITROGEN) if(signal.data["init"] != null) name = signal.data["init"] @@ -278,6 +257,20 @@ update_icon() return +//forcestate 1 turns scrubbing on, forcestate -1 turns scrubbing off. Otherwise, it toggles +/obj/machinery/atmospherics/unary/vent_scrubber/proc/toggle_gas_scrub(gasid, forcestate) + if(!forcestate) + if(gasid in scrubbing_gases) + scrubbing_gases -= gasid + else + scrubbing_gases += gasid + else + switch(forcestate) + if(1) + scrubbing_gases |= gasid //adds it if it's not added already + if(-1) + scrubbing_gases -= gasid //since this only works if it's in, we remove it + /obj/machinery/atmospherics/unary/vent_scrubber/power_change() if(powered(power_channel)) stat &= ~NOPOWER diff --git a/code/ATMOSPHERICS/datum_pipe_network.dm b/code/ATMOSPHERICS/datum_pipe_network.dm index 029c846107c..566cffdd4c5 100644 --- a/code/ATMOSPHERICS/datum_pipe_network.dm +++ b/code/ATMOSPHERICS/datum_pipe_network.dm @@ -100,13 +100,8 @@ //air_transient.volume = 0 var/air_transient_volume = 0 - air_transient.oxygen = 0 - air_transient.nitrogen = 0 - air_transient.toxins = 0 - air_transient.carbon_dioxide = 0 - - - air_transient.trace_gases = list() + for(var/gasid in air_transient.gases) + air_transient.set_gas(gasid, 0, 0) //sets them all to 0 for(var/datum/gas_mixture/gas in gases) air_transient_volume += gas.volume @@ -114,19 +109,7 @@ total_thermal_energy += gas.temperature*temp_heatcap total_heat_capacity += temp_heatcap - air_transient.oxygen += gas.oxygen - air_transient.nitrogen += gas.nitrogen - air_transient.toxins += gas.toxins - air_transient.carbon_dioxide += gas.carbon_dioxide - - if(gas.trace_gases.len) - for(var/datum/gas/trace_gas in gas.trace_gases) - var/datum/gas/corresponding = locate(trace_gas.type) in air_transient.trace_gases - if(!corresponding) - corresponding = new trace_gas.type() - air_transient.trace_gases += corresponding - - corresponding.moles += trace_gas.moles + air_transient.add(gas) air_transient.volume = air_transient_volume @@ -146,88 +129,44 @@ for(var/datum/gas_mixture/gas in gases) var/volume_ratio = gas.volume / air_transient.volume - gas.oxygen = air_transient.oxygen * volume_ratio - gas.nitrogen = air_transient.nitrogen * volume_ratio - gas.toxins = air_transient.toxins * volume_ratio - gas.carbon_dioxide = air_transient.carbon_dioxide * volume_ratio - - gas.temperature = air_transient.temperature - - if(air_transient.trace_gases.len) - for(var/datum/gas/trace_gas in air_transient.trace_gases) - var/datum/gas/corresponding = locate(trace_gas.type) in gas.trace_gases - - if(!corresponding) - corresponding = new trace_gas.type() - gas.trace_gases += corresponding - - corresponding.moles = trace_gas.moles * volume_ratio + gas.copy_from(air_transient) + gas.multiply(volume_ratio) gas.update_values() air_transient.update_values() return 1 -proc/equalize_gases(datum/gas_mixture/list/gases) +proc/equalize_gases(list/datum/gas_mixture/gases) //Perfectly equalize all gases members instantly - //Calculate totals from individual components + var/datum/gas_mixture/total = new var/total_volume = 0 var/total_thermal_energy = 0 - var/total_heat_capacity = 0 - - var/total_oxygen = 0 - var/total_nitrogen = 0 - var/total_toxins = 0 - var/total_carbon_dioxide = 0 - - var/list/total_trace_gases = list() for(var/datum/gas_mixture/gas in gases) total_volume += gas.volume - var/temp_heatcap = gas.heat_capacity() - total_thermal_energy += gas.temperature*temp_heatcap - total_heat_capacity += temp_heatcap + total_thermal_energy += gas.temperature*gas.heat_capacity() - total_oxygen += gas.oxygen - total_nitrogen += gas.nitrogen - total_toxins += gas.toxins - total_carbon_dioxide += gas.carbon_dioxide + total.add(gas) - if(gas.trace_gases.len) - for(var/datum/gas/trace_gas in gas.trace_gases) - var/datum/gas/corresponding = locate(trace_gas.type) in total_trace_gases - if(!corresponding) - corresponding = new trace_gas.type() - total_trace_gases += corresponding - - corresponding.moles += trace_gas.moles if(total_volume > 0) //Calculate temperature var/temperature = 0 - if(total_heat_capacity > 0) - temperature = total_thermal_energy/total_heat_capacity + if(total.heat_capacity() > 0) + temperature = total_thermal_energy/total.heat_capacity() //Update individual gas_mixtures by volume ratio - for(var/datum/gas_mixture/gas in gases) - gas.oxygen = total_oxygen*gas.volume/total_volume - gas.nitrogen = total_nitrogen*gas.volume/total_volume - gas.toxins = total_toxins*gas.volume/total_volume - gas.carbon_dioxide = total_carbon_dioxide*gas.volume/total_volume + for(var/gasid in total.gases) //for each gas in the gas mix in our list of gas mixes + var/total_gas = total.get_moles_by_id(gasid) + for(var/datum/gas_mixture/gas_mix in gases) + gas_mix.set_gas(gasid, total_gas * gas_mix.volume / total_volume, 0) - gas.temperature = temperature - - if(total_trace_gases.len) - for(var/datum/gas/trace_gas in total_trace_gases) - var/datum/gas/corresponding = locate(trace_gas.type) in gas.trace_gases - if(!corresponding) - corresponding = new trace_gas.type() - gas.trace_gases += corresponding - - corresponding.moles = trace_gas.moles*gas.volume/total_volume - gas.update_values() + for(var/datum/gas_mixture/gas_mix in gases) //cheaper to set here + gas_mix.temperature = temperature + gas_mix.update_values() return 1 \ No newline at end of file diff --git a/code/ATMOSPHERICS/datum_pipeline.dm b/code/ATMOSPHERICS/datum_pipeline.dm index e91ca41e0d1..d5e1cf1843b 100644 --- a/code/ATMOSPHERICS/datum_pipeline.dm +++ b/code/ATMOSPHERICS/datum_pipeline.dm @@ -48,19 +48,10 @@ member.air_temporary = new member.air_temporary.volume = member.volume - member.air_temporary.oxygen = air.oxygen*member.volume/air.volume - member.air_temporary.nitrogen = air.nitrogen*member.volume/air.volume - member.air_temporary.toxins = air.toxins*member.volume/air.volume - member.air_temporary.carbon_dioxide = air.carbon_dioxide*member.volume/air.volume - + member.air_temporary.copy_from(air) + member.air_temporary.multiply(member.volume/air.volume) member.air_temporary.temperature = air.temperature - if(air.trace_gases.len) - for(var/datum/gas/trace_gas in air.trace_gases) - var/datum/gas/corresponding = new trace_gas.type() - member.air_temporary.trace_gases += corresponding - - corresponding.moles = trace_gas.moles*member.volume/air.volume member.air_temporary.update_values() /datum/pipeline/proc/build_pipeline(obj/machinery/atmospherics/pipe/base) diff --git a/code/WorkInProgress/Cael_Aislinn/Rust/core_field.dm b/code/WorkInProgress/Cael_Aislinn/Rust/core_field.dm index 17c87e428a9..9fbd1f8a5c0 100644 --- a/code/WorkInProgress/Cael_Aislinn/Rust/core_field.dm +++ b/code/WorkInProgress/Cael_Aislinn/Rust/core_field.dm @@ -135,25 +135,25 @@ Deuterium-tritium fusion: 4.5 x 10^7 K //add plasma from the surrounding environment var/datum/gas_mixture/environment = loc.return_air() + var/held_plasma_moles = held_plasma.get_moles_by_id(PLASMA) //hack in some stuff to remove plasma from the air because SCIENCE //the amount of plasma pulled in each update is relative to the field strength, with 50T (max field strength) = 100% of area covered by the field //at minimum strength, 0.25% of the field volume is pulled in per update (?) //have a max of 1000 moles suspended - if(held_plasma.toxins < transfer_ratio * 1000) + if(held_plasma_moles < transfer_ratio * 1000) var/moles_covered = environment.return_pressure()*volume_covered/(environment.temperature * R_IDEAL_GAS_EQUATION) //world << "moles_covered: [moles_covered]" // var/datum/gas_mixture/gas_covered = environment.remove(moles_covered) var/datum/gas_mixture/plasma_captured = new /datum/gas_mixture() // - plasma_captured.toxins = round(gas_covered.toxins * transfer_ratio) + plasma_captured.set_gas(PLASMA, round(gas_covered.get_moles_by_id(PLASMA) * transfer_ratio), 0) //world << "[plasma_captured.toxins] moles of plasma captured" plasma_captured.temperature = gas_covered.temperature plasma_captured.update_values() // - gas_covered.toxins -= plasma_captured.toxins - gas_covered.update_values() + gas_covered.adjust_gas(PLASMA, -plasma_captured.get_moles_by_id(PLASMA)) // held_plasma.merge(plasma_captured) // @@ -171,7 +171,7 @@ Deuterium-tritium fusion: 4.5 x 10^7 K //change held plasma temp according to energy levels //SPECIFIC_HEAT_TOXIN - if(mega_energy > 0 && held_plasma.toxins) + if(mega_energy > 0 && held_plasma_moles) var/heat_capacity = held_plasma.heat_capacity()//200 * number of plasma moles if(heat_capacity > 0.0003) //formerly MINIMUM_HEAT_CAPACITY held_plasma.temperature = (heat_capacity + mega_energy * 35000)/heat_capacity @@ -179,7 +179,7 @@ Deuterium-tritium fusion: 4.5 x 10^7 K //if there is too much plasma in the field, lose some /*if( held_plasma.toxins > (MOLES_CELLSTANDARD * 7) * (50 / field_strength) ) LosePlasma()*/ - if(held_plasma.toxins > 1) + if(held_plasma_moles > 1) //lose a random amount of plasma back into the air, increased by the field strength (want to switch this over to frequency eventually) var/loss_ratio = rand() * (0.05 + (0.05 * 50 / field_strength)) //world << "lost [loss_ratio*100]% of held plasma" @@ -187,16 +187,16 @@ Deuterium-tritium fusion: 4.5 x 10^7 K var/datum/gas_mixture/plasma_lost = new plasma_lost.temperature = held_plasma.temperature // - plasma_lost.toxins = held_plasma.toxins * loss_ratio + plasma_lost.set_gas(PLASMA, held_plasma_moles * loss_ratio, 0) //plasma_lost.update_values() - held_plasma.toxins -= held_plasma.toxins * loss_ratio + held_plasma.adjust_gas(PLASMA, -held_plasma_moles * loss_ratio, 0) //held_plasma.update_values() // environment.merge(plasma_lost) radiation += loss_ratio * mega_energy * 0.1 mega_energy -= loss_ratio * mega_energy * 0.1 else - held_plasma.toxins = 0 + held_plasma.set_gas(PLASMA, 0) //held_plasma.update_values() //handle some reactants formatting diff --git a/code/WorkInProgress/pomf/spacepods/spacepods.dm b/code/WorkInProgress/pomf/spacepods/spacepods.dm index a55ef12555d..d6336f4f354 100644 --- a/code/WorkInProgress/pomf/spacepods/spacepods.dm +++ b/code/WorkInProgress/pomf/spacepods/spacepods.dm @@ -232,8 +232,8 @@ cabin_air = new cabin_air.temperature = T20C cabin_air.volume = 200 - cabin_air.oxygen = O2STANDARD*cabin_air.volume/(R_IDEAL_GAS_EQUATION*cabin_air.temperature) - cabin_air.nitrogen = N2STANDARD*cabin_air.volume/(R_IDEAL_GAS_EQUATION*cabin_air.temperature) + cabin_air.adjust_gas(OXYGEN, O2STANDARD*cabin_air.volume/(R_IDEAL_GAS_EQUATION*cabin_air.temperature)) + cabin_air.adjust_gas(NITROGEN, N2STANDARD*cabin_air.volume/(R_IDEAL_GAS_EQUATION*cabin_air.temperature)) return cabin_air /obj/spacepod/proc/add_airtank() diff --git a/code/ZAS/ConnectionGroup.dm b/code/ZAS/ConnectionGroup.dm index bb818b673bf..692c29daa02 100644 --- a/code/ZAS/ConnectionGroup.dm +++ b/code/ZAS/ConnectionGroup.dm @@ -251,113 +251,59 @@ var/list/sharing_lookup_table = list(0.30, 0.40, 0.48, 0.54, 0.60, 0.66) proc/ShareRatio(datum/gas_mixture/A, datum/gas_mixture/B, connecting_tiles) //Shares a specific ratio of gas between mixtures using simple weighted averages. - var + //WOOT WOOT TOUCH THIS AND YOU ARE A RETARD - ratio = sharing_lookup_table[6] + var/ratio = sharing_lookup_table[6] //WOOT WOOT TOUCH THIS AND YOU ARE A RETARD - size = max(1,A.group_multiplier) - share_size = max(1,B.group_multiplier) + var/A_full_heat_capacity = A.heat_capacity() * A.group_multiplier - full_oxy = A.oxygen * size - full_nitro = A.nitrogen * size - full_co2 = A.carbon_dioxide * size - full_plasma = A.toxins * size + var/B_full_heat_capacity = B.heat_capacity() * B.group_multiplier - full_heat_capacity = A.heat_capacity() * size - - s_full_oxy = B.oxygen * share_size - s_full_nitro = B.nitrogen * share_size - s_full_co2 = B.carbon_dioxide * share_size - s_full_plasma = B.toxins * share_size - - s_full_heat_capacity = B.heat_capacity() * share_size - - oxy_avg = (full_oxy + s_full_oxy) / (size + share_size) - nit_avg = (full_nitro + s_full_nitro) / (size + share_size) - co2_avg = (full_co2 + s_full_co2) / (size + share_size) - plasma_avg = (full_plasma + s_full_plasma) / (size + share_size) - - temp_avg = (A.temperature * full_heat_capacity + B.temperature * s_full_heat_capacity) / (full_heat_capacity + s_full_heat_capacity) + var/temp_avg = (A.temperature * A_full_heat_capacity + B.temperature * B_full_heat_capacity) / (A_full_heat_capacity + B_full_heat_capacity) //WOOT WOOT TOUCH THIS AND YOU ARE A RETARD if(sharing_lookup_table.len >= connecting_tiles) //6 or more interconnecting tiles will max at 42% of air moved per tick. ratio = sharing_lookup_table[connecting_tiles] //WOOT WOOT TOUCH THIS AND YOU ARE A RETARD - A.oxygen = max(0, (A.oxygen - oxy_avg) * (1-ratio) + oxy_avg ) - A.nitrogen = max(0, (A.nitrogen - nit_avg) * (1-ratio) + nit_avg ) - A.carbon_dioxide = max(0, (A.carbon_dioxide - co2_avg) * (1-ratio) + co2_avg ) - A.toxins = max(0, (A.toxins - plasma_avg) * (1-ratio) + plasma_avg ) + for(var/gasid in A.gases) + var/A_moles = A.get_moles_by_id(gasid) + var/B_moles = B.get_moles_by_id(gasid) + var/avg_gas = (A_moles * A.group_multiplier + B_moles * B.group_multiplier) / (A.group_multiplier + B.group_multiplier) + + A.set_gas(gasid, avg_gas + ((A_moles - avg_gas) * (1 - ratio)), 0) //we don't use adjust_gas because it interferes with the group multiplier + B.set_gas(gasid, avg_gas + ((B_moles - avg_gas) * (1 - ratio)), 0) + A.temperature = max(0, (A.temperature - temp_avg) * (1-ratio) + temp_avg ) - B.oxygen = max(0, (B.oxygen - oxy_avg) * (1-ratio) + oxy_avg ) - B.nitrogen = max(0, (B.nitrogen - nit_avg) * (1-ratio) + nit_avg ) - B.carbon_dioxide = max(0, (B.carbon_dioxide - co2_avg) * (1-ratio) + co2_avg ) - B.toxins = max(0, (B.toxins - plasma_avg) * (1-ratio) + plasma_avg ) - B.temperature = max(0, (B.temperature - temp_avg) * (1-ratio) + temp_avg ) - for(var/datum/gas/G in A.trace_gases) - var/datum/gas/H = locate(G.type) in B.trace_gases - if(H) - var/G_avg = (G.moles*size + H.moles*share_size) / (size+share_size) - G.moles = (G.moles - G_avg) * (1-ratio) + G_avg - - H.moles = (H.moles - G_avg) * (1-ratio) + G_avg - else - H = new G.type - B.trace_gases += H - var/G_avg = (G.moles*size) / (size+share_size) - G.moles = (G.moles - G_avg) * (1-ratio) + G_avg - H.moles = (H.moles - G_avg) * (1-ratio) + G_avg - - for(var/datum/gas/G in B.trace_gases) - var/datum/gas/H = locate(G.type) in A.trace_gases - if(!H) - H = new G.type - A.trace_gases += H - var/G_avg = (G.moles*size) / (size+share_size) - G.moles = (G.moles - G_avg) * (1-ratio) + G_avg - H.moles = (H.moles - G_avg) * (1-ratio) + G_avg - A.update_values() B.update_values() - if(A.compare(B)) return 1 - else return 0 + return A.compare(B) proc/ShareSpace(datum/gas_mixture/A, list/unsimulated_tiles, dbg_output) //A modified version of ShareRatio for spacing gas at the same rate as if it were going into a large airless room. if(!unsimulated_tiles) return 0 - var - unsim_oxygen = 0 - unsim_nitrogen = 0 - unsim_co2 = 0 - unsim_plasma = 0 - unsim_heat_capacity = 0 - unsim_temperature = 0 - - size = max(1,A.group_multiplier) + var/datum/gas_mixture/unsim_mix = new var/tileslen + var/size = A.group_multiplier var/share_size if(istype(unsimulated_tiles, /datum/gas_mixture)) var/datum/gas_mixture/avg_unsim = unsimulated_tiles - unsim_oxygen = avg_unsim.oxygen - unsim_co2 = avg_unsim.carbon_dioxide - unsim_nitrogen = avg_unsim.nitrogen - unsim_plasma = avg_unsim.toxins - unsim_temperature = avg_unsim.temperature + unsim_mix.copy_from(avg_unsim) share_size = max(1, max(size + 3, 1) + avg_unsim.group_multiplier) tileslen = avg_unsim.group_multiplier if(dbg_output) - world << "O2: [unsim_oxygen] N2: [unsim_nitrogen] Size: [share_size] Tiles: [tileslen]" + world << "O2: [unsim_mix.get_moles_by_id(OXYGEN)] N2: [unsim_mix.get_moles_by_id(NITROGEN)] Size: [share_size] Tiles: [tileslen]" else if(istype(unsimulated_tiles, /list)) if(!unsimulated_tiles.len) @@ -372,64 +318,40 @@ proc/ShareSpace(datum/gas_mixture/A, list/unsimulated_tiles, dbg_output) var/correction_ratio = share_size / unsimulated_tiles.len for(var/turf/T in unsimulated_tiles) - unsim_oxygen += T.oxygen - unsim_co2 += T.carbon_dioxide - unsim_nitrogen += T.nitrogen - unsim_plasma += T.toxins - unsim_temperature += T.temperature/unsimulated_tiles.len + unsim_mix.add(T.return_air()) //These values require adjustment in order to properly represent a room of the specified size. - unsim_oxygen *= correction_ratio - unsim_co2 *= correction_ratio - unsim_nitrogen *= correction_ratio - unsim_plasma *= correction_ratio + unsim_mix.multiply(correction_ratio) tileslen = unsimulated_tiles.len else //invalid input type return 0 - unsim_heat_capacity = HEAT_CAPACITY_CALCULATION(unsim_oxygen, unsim_co2, unsim_nitrogen, unsim_plasma) + var/ratio = sharing_lookup_table[6] - var - ratio = sharing_lookup_table[6] + var/old_pressure = A.return_pressure() - old_pressure = A.return_pressure() + var/full_heat_capacity = A.heat_capacity() * A.group_multiplier - full_oxy = A.oxygen * size - full_nitro = A.nitrogen * size - full_co2 = A.carbon_dioxide * size - full_plasma = A.toxins * size + var/temp_avg = 0 - full_heat_capacity = A.heat_capacity() * size - - oxy_avg = (full_oxy + unsim_oxygen*share_size) / (size + share_size) - nit_avg = (full_nitro + unsim_nitrogen*share_size) / (size + share_size) - co2_avg = (full_co2 + unsim_co2*share_size) / (size + share_size) - plasma_avg = (full_plasma + unsim_plasma*share_size) / (size + share_size) - - temp_avg = 0 - - if((full_heat_capacity + unsim_heat_capacity) > 0) - temp_avg = (A.temperature * full_heat_capacity + unsim_temperature * unsim_heat_capacity) / (full_heat_capacity + unsim_heat_capacity) + if((full_heat_capacity + unsim_mix.heat_capacity()) > 0) + temp_avg = (A.temperature * full_heat_capacity + unsim_mix.temperature * unsim_mix.heat_capacity()) / (full_heat_capacity + unsim_mix.heat_capacity()) if(sharing_lookup_table.len >= tileslen) //6 or more interconnecting tiles will max at 42% of air moved per tick. ratio = sharing_lookup_table[tileslen] if(dbg_output) world << "Ratio: [ratio]" - world << "Avg O2: [oxy_avg] N2: [nit_avg]" + //world << "Avg O2: [oxy_avg] N2: [nit_avg]" - A.oxygen = max(0, (A.oxygen - oxy_avg) * (1 - ratio) + oxy_avg ) - A.nitrogen = max(0, (A.nitrogen - nit_avg) * (1 - ratio) + nit_avg ) - A.carbon_dioxide = max(0, (A.carbon_dioxide - co2_avg) * (1 - ratio) + co2_avg ) - A.toxins = max(0, (A.toxins - plasma_avg) * (1 - ratio) + plasma_avg ) + for(var/gasid in A.gases) + var/gas_moles = A.get_moles_by_id(gasid) + var/avg_gas = (gas_moles + unsim_mix.get_moles_by_id(gasid)*share_size) / (size + share_size) + A.set_gas(gasid, (gas_moles - avg_gas) * (1 - ratio) + avg_gas, 0 ) A.temperature = max(TCMB, (A.temperature - temp_avg) * (1 - ratio) + temp_avg ) - for(var/datum/gas/G in A.trace_gases) - var/G_avg = (G.moles * size) / (size + share_size) - G.moles = (G.moles - G_avg) * (1 - ratio) + G_avg - A.update_values() if(dbg_output) world << "Result: [abs(old_pressure - A.return_pressure())] kPa" diff --git a/code/ZAS/Controller.dm b/code/ZAS/Controller.dm index 5f63d445c10..ed53ed802cd 100644 --- a/code/ZAS/Controller.dm +++ b/code/ZAS/Controller.dm @@ -310,11 +310,15 @@ Total Unsimulated Turfs: [world.maxx*world.maxy*world.maxz - simulated_turf_coun return edge /datum/controller/air_system/proc/has_same_air(turf/A, turf/B) - if(A.oxygen != B.oxygen) return 0 - if(A.nitrogen != B.nitrogen) return 0 - if(A.toxins != B.toxins) return 0 - if(A.carbon_dioxide != B.carbon_dioxide) return 0 if(A.temperature != B.temperature) return 0 + + var/datum/gas_mixture/A_mix = A.return_air() + var/datum/gas_mixture/B_mix = B.return_air() + + for(var/gasid in A_mix.gases) + if(A_mix.get_moles_by_id(gasid) != B_mix.get_moles_by_id(gasid)) + return 0 + return 1 /datum/controller/air_system/proc/remove_edge(connection/c) diff --git a/code/ZAS/Diagnostic.dm b/code/ZAS/Diagnostic.dm index 75e4ab50ce9..863e5023842 100644 --- a/code/ZAS/Diagnostic.dm +++ b/code/ZAS/Diagnostic.dm @@ -19,7 +19,11 @@ client/proc/Zone_Info(turf/T as null|turf) mob << "No zone here." var/datum/gas_mixture/mix = T.return_air() mob << "[mix.return_pressure()] kPa [mix.temperature]C" - mob << "O2: [mix.oxygen] N2: [mix.nitrogen] CO2: [mix.carbon_dioxide] TX: [mix.toxins]" + var/message = "" + for(var/gasid in mix.gases) + var/datum/gas/gas = mix.get_gas_by_id(gasid) + message += "[gas.display_short]: [mix.get_moles_by_id(gasid)]" + mob << message else if(zone_debug_images) for(var/zone in zone_debug_images) diff --git a/code/ZAS/Fire.dm b/code/ZAS/Fire.dm index 3e75e815199..fa00864b4f3 100644 --- a/code/ZAS/Fire.dm +++ b/code/ZAS/Fire.dm @@ -140,6 +140,8 @@ Attach to transfer valve and open. BOOM. qdel(src) +#define FIRE_GAS_ROUNDING 0.1 //how much we round gas values to when fire updates a turf + /obj/fire/process() . = 1 @@ -156,18 +158,9 @@ Attach to transfer valve and open. BOOM. var/datum/gas_mixture/air_contents = S.return_air() - //and the volatile stuff from the air - var/datum/gas/volatile_fuel/fuel = locate() in air_contents.trace_gases - //since the air is processed in fractions, we need to make sure not to have any minuscle residue or //the amount of moles might get to low for some functions to catch them and thus result in wonky behaviour - if(air_contents.oxygen < 0.1) - air_contents.oxygen = 0 - if(air_contents.toxins < 0.1) - air_contents.toxins = 0 - if(fuel) - if(fuel.moles < 0.1) - air_contents.trace_gases.Remove(fuel) + air_contents.update_values(FIRE_GAS_ROUNDING) //the define is the level we clean to // Check if there is something to combust. if (!air_contents.check_recombustability(S)) @@ -256,6 +249,13 @@ turf/proc/apply_fire_protection() turf/simulated/apply_fire_protection() fire_protection = world.time +/datum/gas_mixture/proc/get_gas_fuel() + update_values() + return total_fuel + +/datum/gas_mixture/proc/get_gas_oxidiser() + update_values() + return total_oxidiser datum/gas_mixture/proc/zburn(var/turf/T, force_burn) // NOTE: zburn is also called from canisters and in tanks/pipes (via react()). Do NOT assume T is always a turf. @@ -263,14 +263,8 @@ datum/gas_mixture/proc/zburn(var/turf/T, force_burn) var/value = 0 if((temperature > PLASMA_MINIMUM_BURN_TEMPERATURE || force_burn) && check_recombustability(T)) - var/total_fuel = 0 - var/datum/gas/volatile_fuel/fuel = locate() in trace_gases - - total_fuel += toxins - - if(fuel) - //Volatile Fuel - total_fuel += fuel.moles + var/total_fuel = get_gas_fuel() + var/total_oxidiser = get_gas_oxidiser() var/can_use_turf=(T && istype(T)) if(can_use_turf) @@ -290,29 +284,30 @@ datum/gas_mixture/proc/zburn(var/turf/T, force_burn) var/starting_energy = temperature * heat_capacity() //determine the amount of oxygen used - var/total_oxygen = min(oxygen, 2 * total_fuel) + total_oxidiser = min(total_oxidiser, 2 * total_fuel) //determine the amount of fuel actually used - var/used_fuel_ratio = min(oxygen / 2 , total_fuel) / total_fuel + var/used_fuel_ratio = min(total_oxidiser / 2 , total_fuel) / total_fuel total_fuel = total_fuel * used_fuel_ratio - var/total_reactants = total_fuel + total_oxygen + var/total_reactants = total_fuel + total_oxidiser //determine the amount of reactants actually reacting var/used_reactants_ratio = Clamp(total_reactants * firelevel / zas_settings.Get(/datum/ZAS_Setting/fire_firelevel_multiplier), 0.2, total_reactants) / total_reactants //remove and add gasses as calculated - oxygen -= min(oxygen, total_oxygen * used_reactants_ratio ) + for(var/gasid in gases) + var/datum/gas/current_gas = get_gas_by_id(gasid) + if(current_gas.isOxidiser()) + adjust_gas(current_gas.gas_id, -get_moles_by_id(gasid) * used_reactants_ratio * current_gas.fuel_multiplier, 0, 0) //take the cost of oxidiser - toxins -= min(toxins, (toxins * used_fuel_ratio * used_reactants_ratio ) * 3) - if(toxins < 0) - toxins = 0 + //fuels + for(var/gasid in gases) + var/datum/gas/current_gas = get_gas_by_id(gasid) + if(current_gas.isFuel()) + adjust_gas(current_gas.gas_id, -get_moles_by_id(gasid) * used_fuel_ratio * used_reactants_ratio * current_gas.fuel_multiplier, 0, 0) //take the cost of fuel - carbon_dioxide += max(2 * total_fuel, 0) - - if(fuel) - fuel.moles -= (fuel.moles * used_fuel_ratio * used_reactants_ratio) * 5 //Fuel burns 5 times as quick - if(fuel.moles <= 0) del fuel + adjust_gas(CARBON_DIOXIDE, max(2 * total_fuel, 0), 0, 0) if(can_use_turf) if(T.getFireFuel()>0) @@ -331,12 +326,11 @@ datum/gas_mixture/proc/zburn(var/turf/T, force_burn) /datum/gas_mixture/proc/check_recombustability(var/turf/T) //this is a copy proc to continue a fire after its been started. - var/datum/gas/volatile_fuel/fuel = locate() in trace_gases + var/total_fuel = get_gas_fuel() + var/total_oxidiser = get_gas_oxidiser() - if(oxygen && (toxins || fuel)) - if(QUANTIZE(toxins * zas_settings.Get(/datum/ZAS_Setting/fire_consumption_rate)) >= BASE_ZAS_FUEL_REQ) - return 1 - if(fuel && QUANTIZE(fuel.moles * zas_settings.Get(/datum/ZAS_Setting/fire_consumption_rate)) >= BASE_ZAS_FUEL_REQ) + if(total_oxidiser && total_fuel) //have some fuel to burn + if(QUANTIZE(total_fuel * zas_settings.Get(/datum/ZAS_Setting/fire_consumption_rate)) >= BASE_ZAS_FUEL_REQ) return 1 // Check if we're actually in a turf or not before trying to check object fires. @@ -352,7 +346,7 @@ datum/gas_mixture/proc/zburn(var/turf/T, force_burn) var/still_burning=0 for(var/atom/A in T) if(!A) continue - if(!oxygen/* || A.autoignition_temperature > temperature*/) + if(!total_oxidiser/* || A.autoignition_temperature > temperature*/) A.extinguish() continue // if(!A.autoignition_temperature) @@ -373,18 +367,16 @@ datum/gas_mixture/proc/check_combustability(var/turf/T, var/objects) warning("check_combustability being asked to check a [T.type] instead of /turf.") return 0 */ + var/total_fuel = get_gas_fuel() + var/total_oxidiser = get_gas_oxidiser() - var/datum/gas/volatile_fuel/fuel = locate() in trace_gases - - if(oxygen && (toxins || fuel)) - if(QUANTIZE(toxins * zas_settings.Get(/datum/ZAS_Setting/fire_consumption_rate)) >= BASE_ZAS_FUEL_REQ) - return 1 - if(fuel && QUANTIZE(fuel.moles * zas_settings.Get(/datum/ZAS_Setting/fire_consumption_rate)) >= BASE_ZAS_FUEL_REQ) + if(total_oxidiser && total_fuel) + if(QUANTIZE(total_fuel * zas_settings.Get(/datum/ZAS_Setting/fire_consumption_rate)) >= BASE_ZAS_FUEL_REQ) return 1 if(objects && istype(T)) for(var/atom/A in T) - if(!A || !oxygen || A.autoignition_temperature > temperature) continue + if(!A || !total_oxidiser || A.autoignition_temperature > temperature) continue if(QUANTIZE(A.getFireFuel() * zas_settings.Get(/datum/ZAS_Setting/fire_consumption_rate)) >= A.volatility) return 1 @@ -392,33 +384,23 @@ datum/gas_mixture/proc/check_combustability(var/turf/T, var/objects) datum/gas_mixture/proc/calculate_firelevel(var/turf/T) //Calculates the firelevel based on one equation instead of having to do this multiple times in different areas. - - var/datum/gas/volatile_fuel/fuel = locate() in trace_gases var/total_fuel = 0 var/firelevel = 0 + var/total_oxidiser = 0 if(check_recombustability(T)) - total_fuel += toxins + total_fuel += get_gas_fuel() + total_oxidiser += get_gas_oxidiser() - if(T && istype(T)) - total_fuel += T.getFireFuel() + var/total_combustables = (total_fuel + total_oxidiser) - for(var/atom/A in T) - if(A) - total_fuel += A.getFireFuel() - - if(fuel) - total_fuel += fuel.moles - - var/total_combustables = (total_fuel + oxygen) - - if(total_fuel > 0 && oxygen > 0) + if(total_fuel > 0 && total_oxidiser > 0) //slows down the burning when the concentration of the reactants is low - var/dampening_multiplier = total_combustables / (total_combustables + nitrogen + carbon_dioxide) + var/dampening_multiplier = total_combustables / (total_moles()) //calculates how close the mixture of the reactants is to the optimum - var/mix_multiplier = 1 / (1 + (5 * ((oxygen / total_combustables) ** 2))) // Thanks, Mloc + var/mix_multiplier = 1 / (1 + (5 * ((total_oxidiser / total_combustables) ** 2))) // Thanks, Mloc //toss everything together firelevel = zas_settings.Get(/datum/ZAS_Setting/fire_firelevel_multiplier) * mix_multiplier * dampening_multiplier diff --git a/code/ZAS/Plasma.dm b/code/ZAS/Plasma.dm index dc1dc8d75bc..37c6d77cd85 100644 --- a/code/ZAS/Plasma.dm +++ b/code/ZAS/Plasma.dm @@ -53,7 +53,7 @@ var/image/contamination_overlay = image('icons/effects/contamination.dmi') if(stat >= 2) return - if(species.breath_type != "plasma") + if(species.breath_type != PLASMA) //Burn skin if exposed. if(zas_settings.Get(/datum/ZAS_Setting/SKIN_BURNS)) @@ -124,6 +124,6 @@ var/image/contamination_overlay = image('icons/effects/contamination.dmi') if(istype(I) && zas_settings.Get(/datum/ZAS_Setting/CLOTH_CONTAMINATION)) var/datum/gas_mixture/environment = return_air() - if(environment.toxins > MOLES_PLASMA_VISIBLE + 1) + if(environment.get_moles_by_id(PLASMA) > MOLES_PLASMA_VISIBLE + 1) if(I.can_contaminate()) I.contaminate() diff --git a/code/ZAS/Turf.dm b/code/ZAS/Turf.dm index 38ddb77bb08..cd82c7ecc0d 100644 --- a/code/ZAS/Turf.dm +++ b/code/ZAS/Turf.dm @@ -204,41 +204,22 @@ /turf/return_air() //Create gas mixture to hold data for passing - var/datum/gas_mixture/GM = new + if(!air) + make_air() - GM.oxygen = oxygen - GM.carbon_dioxide = carbon_dioxide - GM.nitrogen = nitrogen - GM.toxins = toxins + air.temperature = temperature + air.update_values() - GM.temperature = temperature - GM.update_values() - - return GM + return air /turf/remove_air(amount as num) - var/datum/gas_mixture/GM = new - - var/sum = oxygen + carbon_dioxide + nitrogen + toxins - if(sum>0) - GM.oxygen = (oxygen/sum)*amount - GM.carbon_dioxide = (carbon_dioxide/sum)*amount - GM.nitrogen = (nitrogen/sum)*amount - GM.toxins = (toxins/sum)*amount - - GM.temperature = temperature - GM.update_values() - - return GM + var/datum/gas_mixture/my_air = return_air() + return my_air.remove(amount) /turf/simulated/assume_air(datum/gas_mixture/giver) var/datum/gas_mixture/my_air = return_air() my_air.merge(giver) -/turf/simulated/remove_air(amount as num) - var/datum/gas_mixture/my_air = return_air() - return my_air.remove(amount) - /turf/simulated/return_air() if(zone) if(!zone.invalid) @@ -257,9 +238,10 @@ /turf/proc/make_air() air = new/datum/gas_mixture air.temperature = temperature - air.adjust(oxygen, carbon_dioxide, nitrogen, toxins) air.group_multiplier = 1 air.volume = CELL_VOLUME + if(starting_gases) + air.adjust(starting_gases) /turf/simulated/proc/c_copy_air() if(!air) air = new/datum/gas_mixture diff --git a/code/ZAS/Zone.dm b/code/ZAS/Zone.dm index eb23fe7d1e5..cf5167a15fd 100644 --- a/code/ZAS/Zone.dm +++ b/code/ZAS/Zone.dm @@ -128,9 +128,13 @@ Class Procs: /zone/proc/dbg_data(mob/M) M << name - M << "O2: [air.oxygen] N2: [air.nitrogen] CO2: [air.carbon_dioxide] P: [air.toxins]" + var/gas_message = "" + for(var/gasid in air.gases) + var/datum/gas/gas = air.get_gas_by_id(gasid) + gas_message += "[gas.display_short]: [air.get_moles_by_id(gasid)]" + M << gas_message M << "P: [air.return_pressure()] kPa V: [air.volume]L T: [air.temperature]°K ([air.temperature - T0C]°C)" - M << "O2 per N2: [(air.nitrogen ? air.oxygen/air.nitrogen : "N/A")] Moles: [air.total_moles]" + M << "O2 per N2: [(air.get_moles_by_id(NITROGEN) ? air.get_moles_by_id(OXYGEN)/air.get_moles_by_id(NITROGEN) : "N/A")] Moles: [air.total_moles]" M << "Simulated: [contents.len] ([air.group_multiplier])" //M << "Unsimulated: [unsimulated_contents.len]" //M << "Edges: [edges.len]" diff --git a/code/ZAS/_gas_datum.dm b/code/ZAS/_gas_datum.dm new file mode 100644 index 00000000000..8d0f0e388bc --- /dev/null +++ b/code/ZAS/_gas_datum.dm @@ -0,0 +1,72 @@ +var/global/list/gas_datum_list + +/datum/gas + var/display_name = "" + var/display_short = "" + + var/gas_id = "" //all ids must be unique + + var/specific_heat = 0 + + var/gas_flags = 0 + var/fuel_multiplier = 1 //multiplier of rate of burning + +/datum/gas/proc/isFuel() + return gas_flags & IS_FUEL + +/datum/gas/proc/isOxidiser() + return gas_flags & IS_OXIDISER + +/datum/gas/oxygen + display_name = "Oxygen" + display_short = "O2" + gas_id = OXYGEN + specific_heat = SPECIFIC_HEAT_AIR + gas_flags = IS_OXIDISER | ALWAYS_SHOW + +/datum/gas/nitrogen + display_name = "Nitrogen" + display_short = "N2" + gas_id = NITROGEN + specific_heat = SPECIFIC_HEAT_AIR + gas_flags = ALWAYS_SHOW + +/datum/gas/plasma + display_name = "Plasma" + display_short = "PL" + gas_id = PLASMA + specific_heat = SPECIFIC_HEAT_PLASMA + gas_flags = IS_FUEL | AUTO_FILTERED | AUTO_LOGGING | ALWAYS_SHOW + fuel_multiplier = 3 + +/datum/gas/co2 + display_name = "Carbon Dioxide" + display_short = "CO2" + gas_id = CARBON_DIOXIDE + specific_heat = SPECIFIC_HEAT_CDO + gas_flags = AUTO_FILTERED | AUTO_LOGGING | ALWAYS_SHOW + +/datum/gas/n2o + display_name = "Nitrous Oxide" + display_short = "N2O" + gas_id = NITROUS_OXIDE + specific_heat = SPECIFIC_HEAT_NIO + gas_flags = AUTO_FILTERED | AUTO_LOGGING + +//ping me when someone figures out what the hell this is for +/* +/datum/gas/oxygen_agent_b + display_name = "Oxygen Agent B" + display_short = "OAB" + gas_id = "oxygen_agent_b" + specific_heat = 300 +*/ + +/datum/gas/volatile_fuel + display_name = "Volatile Fuel" + display_short = "VF" + gas_id = VOLATILE_FUEL + specific_heat = 30 + gas_flags = IS_FUEL | AUTO_LOGGING + fuel_multiplier = 5 + diff --git a/code/ZAS/_gas_mixture.dm b/code/ZAS/_gas_mixture.dm index 9bb1daa958b..8126a7dc275 100644 --- a/code/ZAS/_gas_mixture.dm +++ b/code/ZAS/_gas_mixture.dm @@ -4,14 +4,10 @@ What are the archived variables for? This prevents race conditions that arise based on the order of tile processing. */ -#define SPECIFIC_HEAT_TOXIN 200 -#define SPECIFIC_HEAT_AIR 20 -#define SPECIFIC_HEAT_CDO 30 -#define HEAT_CAPACITY_CALCULATION(oxygen,carbon_dioxide,nitrogen,toxins) \ - max(0, carbon_dioxide * SPECIFIC_HEAT_CDO + (oxygen + nitrogen) * SPECIFIC_HEAT_AIR + toxins * SPECIFIC_HEAT_TOXIN) +#define STANDARD_GAS_ROUNDING 0.0001 #define MINIMUM_HEAT_CAPACITY 0.0003 -#define QUANTIZE(variable) (round(variable,0.0001)) +#define QUANTIZE(variable) (round(variable,STANDARD_GAS_ROUNDING)) #define TRANSFER_FRACTION 5 //What fraction (1/#) of the air difference to try and transfer // /vg/ SHIT @@ -38,27 +34,7 @@ What are the archived variables for? slmaster.mouse_opacity = 0 return 1 -/datum/gas/sleeping_agent/specific_heat = 40 //These are used for the "Trace Gases" stuff, but is buggy. - -/datum/gas/oxygen_agent_b/specific_heat = 300 - -/datum/gas/volatile_fuel/specific_heat = 30 - -/datum/gas - var/moles = 0 - - var/specific_heat = 0 - - var/moles_archived = 0 - -/datum/gas_mixture/ - var/oxygen = 0 //Holds the "moles" of each of the four gases. - var/carbon_dioxide = 0 - var/nitrogen = 0 - var/toxins = 0 - - var/total_moles = 0 //Updated when a reaction occurs. - +/datum/gas_mixture var/volume = CELL_VOLUME var/temperature = 0 //in Kelvin, use calculate_temperature() to modify @@ -67,16 +43,16 @@ What are the archived variables for? //Size of the group this gas_mixture is representing. //=1 for singletons + var/total_moles = 0 + var/total_oxidiser = 0 + var/total_fuel + var/graphics=0 var/pressure=0 - var/list/datum/gas/trace_gases = list() //Seemed to be a good idea that was abandoned - - var/tmp/oxygen_archived //These are variables for use with the archived data - var/tmp/carbon_dioxide_archived - var/tmp/nitrogen_archived - var/tmp/toxins_archived + var/list/gases //stores all the gas numbers for this mixture + var/list/archived_gases //archiving! var/tmp/temperature_archived @@ -84,61 +60,77 @@ What are the archived variables for? var/tmp/fuel_burnt = 0 //var/datum/reagents/aerosols -/* + /datum/gas_mixture/New() - //create_reagents(10) -*/ + gases = list() + if(!gas_datum_list) + for(var/newgas in (typesof(/datum/gas) - /datum/gas)) + var/datum/gas/new_datum_gas = new newgas() + gas_datum_list += list(new_datum_gas.gas_id = new_datum_gas) //associates the gas with its id + + for(var/gasid in gas_datum_list) //initialise the gases themselves + gases += list("[gasid]" = 0) + + archived_gases = gases.Copy() + +//gets a gas in the gas list +/datum/gas_mixture/proc/get_gas_by_id(gasid) + if(gasid in gas_datum_list) + return gas_datum_list[gasid] + else + return null + +//just a shortcut for fetching moles +/datum/gas_mixture/proc/get_moles_by_id(gasid) + if(gasid in gases) + return gases[gasid] + else + return 0 + +/datum/gas_mixture/proc/get_archived_moles_by_id(gasid) + if(gasid in archived_gases) + return archived_gases[gasid] + else + return 0 //FOR THE LOVE OF GOD PLEASE USE THIS PROC //Call it with negative numbers to remove gases. -/datum/gas_mixture/proc/adjust(o2 = 0, co2 = 0, n2 = 0, tx = 0, list/datum/gas/traces = list()) +/datum/gas_mixture/proc/adjust(list/datum/gas/adjusts = list()) //Purpose: Adjusting the gases within a airmix //Called by: Nothing, yet! - //Inputs: The values of the gases to adjust + //Inputs: The values of the gases to adjust done as a list(id = moles) //Outputs: null - oxygen = max(0, oxygen + o2) - carbon_dioxide = max(0, carbon_dioxide + co2) - nitrogen = max(0, nitrogen + n2) - toxins = max(0, toxins + tx) - - //handle trace gasses - for(var/datum/gas/G in traces) - var/datum/gas/T = locate(G.type) in trace_gases - if(T) - T.moles = max(G.moles + T.moles, 0) - else if(G.moles > 0) - trace_gases |= G + for(var/a_gas in adjusts) + adjust_gas(a_gas, adjusts[a_gas], 0, 0) //we delay updating since we do it at the end update_values() return //Takes a gas string, and the amount of moles to adjust by. Calls update_values() if update isn't 0. -/datum/gas_mixture/proc/adjust_gas(gasid, moles, update = 1) +//if use_group is 0, the group_multiplier isn't considered +/datum/gas_mixture/proc/adjust_gas(gasid, moles, update = 1, use_group = 1) if(moles == 0) return - switch(gasid) - if("oxygen") - if (group_multiplier != 1) - oxygen += moles/group_multiplier - else - oxygen += moles - if("plasma") - if (group_multiplier != 1) - toxins += moles/group_multiplier - else - toxins += moles - if("carbon_dioxide") - if (group_multiplier != 1) - carbon_dioxide += moles/group_multiplier - else - carbon_dioxide += moles - if("nitrogen") - if (group_multiplier != 1) - nitrogen += moles/group_multiplier - else - nitrogen += moles + if(!(gasid in gases)) + return + + if(group_multiplier != 1 && use_group) + gases[gasid] = max(0, gases[gasid] + moles/group_multiplier) + else + gases[gasid] = max(0, gases[gasid] + moles) + + + if(update) + update_values() + +//Sets the value of a gas +/datum/gas_mixture/proc/set_gas(gasid, moles, update = 1) + if(!(gasid in gases)) + return + + gases[gasid] = max(0, moles) if(update) update_values() @@ -171,11 +163,11 @@ What are the archived variables for? //Inputs: None //Outputs: Heat capacity - var/heat_capacity = HEAT_CAPACITY_CALCULATION(oxygen,carbon_dioxide,nitrogen,toxins) + var/heat_capacity - if(trace_gases && trace_gases.len) //sanity check because somehow the tracegases gets nulled? - for(var/datum/gas/trace_gas in trace_gases) - heat_capacity += trace_gas.moles*trace_gas.specific_heat + for(var/gasid in gases) + var/datum/gas/gas = get_gas_by_id(gasid) + heat_capacity += get_moles_by_id(gasid)*gas.specific_heat return max(MINIMUM_HEAT_CAPACITY,heat_capacity) @@ -185,15 +177,16 @@ What are the archived variables for? //Inputs: None //Outputs: Archived heat capacity - var/heat_capacity_archived = HEAT_CAPACITY_CALCULATION(oxygen_archived,carbon_dioxide_archived,nitrogen_archived,toxins_archived) + var/heat_capacity_archived - if(trace_gases.len) - for(var/datum/gas/trace_gas in trace_gases) - heat_capacity_archived += trace_gas.moles_archived*trace_gas.specific_heat + for(var/gasid in gases) + var/datum/gas/gas = get_gas_by_id(gasid) + heat_capacity_archived += get_archived_moles_by_id(gasid)*gas.specific_heat return max(MINIMUM_HEAT_CAPACITY,heat_capacity_archived) /datum/gas_mixture/proc/total_moles() +// update_values() return total_moles /*var/moles = oxygen + carbon_dioxide + nitrogen + toxins @@ -230,22 +223,27 @@ What are the archived variables for? // return temperature*heat_capacity() -/datum/gas_mixture/proc/update_values() +/datum/gas_mixture/proc/update_values(var/rounding_error = STANDARD_GAS_ROUNDING) //Purpose: Calculating and storing values which were normally called CONSTANTLY //Called by: Anything that changes values within a gas mix. //Inputs: None //Outputs: None - total_moles = oxygen + carbon_dioxide + nitrogen + toxins + total_moles = 0 + total_oxidiser = 0 //used in get_gas_fuel and get_gas_oxidiser + total_fuel = 0 - if(trace_gases.len) - for(var/datum/gas/trace_gas in trace_gases) - total_moles += trace_gas.moles - -/* - if(aerosols.total_volume) - total_moles += aerosols.total_volume -*/ + for(var/gasid in gases) + var/gas_moles = get_moles_by_id(gasid) + var/datum/gas/current_gas = get_gas_by_id(gasid) + if(!rounding_error || round(gas_moles, rounding_error) > 0) //the fraction isn't small enough to be discarded + total_moles += gas_moles + if(current_gas.isFuel()) + total_fuel += gas_moles + if(current_gas.isOxidiser()) + total_oxidiser += gas_moles + else + set_gas(gasid, 0, 0) //get rid of the remainder if(volume>0) pressure = total_moles()*R_IDEAL_GAS_EQUATION*temperature/volume @@ -274,13 +272,11 @@ What are the archived variables for? //if(was_icy || (!was_icy && prob(25))) graphics |= GRAPHICS_COLD - if(toxins > MOLES_PLASMA_VISIBLE) + if(get_moles_by_id(PLASMA) > MOLES_PLASMA_VISIBLE) graphics |= GRAPHICS_PLASMA - if(length(trace_gases)) - var/datum/gas/sleeping_agent = locate(/datum/gas/sleeping_agent) in trace_gases - if(sleeping_agent && (sleeping_agent.moles > 1)) - graphics |= GRAPHICS_N2O + if(get_moles_by_id(NITROUS_OXIDE) > MOLES_N2O_VISIBLE) + graphics |= GRAPHICS_N2O /* if(aerosols && aerosols.total_volume >= 1) graphics |= GRAPHICS_REAGENTS @@ -363,21 +359,14 @@ What are the archived variables for? //Procs for general gas spread calculations.// ////////////////////////////////////////////// - /datum/gas_mixture/proc/archive() //Purpose: Archives the current gas values //Called by: UNKNOWN //Inputs: None //Outputs: 1 - oxygen_archived = oxygen - carbon_dioxide_archived = carbon_dioxide - nitrogen_archived = nitrogen - toxins_archived = toxins - - if(trace_gases.len) - for(var/datum/gas/trace_gas in trace_gases) - trace_gas.moles_archived = trace_gas.moles + for(var/gasid in gases) + archived_gases[gasid] = gases[gasid] temperature_archived = temperature @@ -394,19 +383,13 @@ What are the archived variables for? if(!giver) return 0 - if(((giver.oxygen > MINIMUM_AIR_TO_SUSPEND) && (giver.oxygen >= oxygen*MINIMUM_AIR_RATIO_TO_SUSPEND)) \ - || ((giver.carbon_dioxide > MINIMUM_AIR_TO_SUSPEND) && (giver.carbon_dioxide >= carbon_dioxide*MINIMUM_AIR_RATIO_TO_SUSPEND)) \ - || ((giver.nitrogen > MINIMUM_AIR_TO_SUSPEND) && (giver.nitrogen >= nitrogen*MINIMUM_AIR_RATIO_TO_SUSPEND)) \ - || ((giver.toxins > MINIMUM_AIR_TO_SUSPEND) && (giver.toxins >= toxins*MINIMUM_AIR_RATIO_TO_SUSPEND))) - return 0 + if(abs(giver.temperature - temperature) > MINIMUM_TEMPERATURE_DELTA_TO_SUSPEND) return 0 - if(giver.trace_gases.len) - for(var/datum/gas/trace_gas in giver.trace_gases) - var/datum/gas/corresponding = locate(trace_gas.type) in trace_gases - if((trace_gas.moles > MINIMUM_AIR_TO_SUSPEND) && (!corresponding || (trace_gas.moles >= corresponding.moles*MINIMUM_AIR_RATIO_TO_SUSPEND))) - return 0 + for(var/gasid in gases) + if((giver.get_moles_by_id(gasid) > MINIMUM_AIR_TO_SUSPEND) && (giver.get_moles_by_id(gasid) >= get_moles_by_id(gasid)*MINIMUM_AIR_RATIO_TO_SUSPEND)) + return 0 return merge(giver) @@ -426,24 +409,13 @@ What are the archived variables for? if(combined_heat_capacity != 0) temperature = (giver.temperature*giver_heat_capacity + temperature*self_heat_capacity)/combined_heat_capacity - if((group_multiplier>1)||(giver.group_multiplier>1)) - oxygen += giver.oxygen*giver.group_multiplier/group_multiplier - carbon_dioxide += giver.carbon_dioxide*giver.group_multiplier/group_multiplier - nitrogen += giver.nitrogen*giver.group_multiplier/group_multiplier - toxins += giver.toxins*giver.group_multiplier/group_multiplier + if(giver.group_multiplier>1) + for(var/gasid in gases) + adjust_gas(gasid, giver.get_moles_by_id(gasid) * giver.group_multiplier, 0) //delay updates else - oxygen += giver.oxygen - carbon_dioxide += giver.carbon_dioxide - nitrogen += giver.nitrogen - toxins += giver.toxins + for(var/gasid in gases) + adjust_gas(gasid, giver.get_moles_by_id(gasid), 0) - if(giver.trace_gases.len) - for(var/datum/gas/trace_gas in giver.trace_gases) - var/datum/gas/corresponding = locate(trace_gas.type) in trace_gases - if(!corresponding) - corresponding = new trace_gas.type() - trace_gases += corresponding - corresponding.moles += trace_gas.moles*giver.group_multiplier/group_multiplier /* if(giver.aerosols.total_volume > 1) giver.aerosols.trans_to_atmos(src,aerosols.total_volume) @@ -460,6 +432,8 @@ What are the archived variables for? //Inputs: How many moles to remove. //Outputs: Removed air. + update_values() + // Fix a singuloth problem if(group_multiplier==0) return null @@ -467,32 +441,15 @@ What are the archived variables for? var/sum = total_moles() amount = min(amount,sum) //Can not take more air than tile has! if(amount <= 0) - return null + return new/datum/gas_mixture var/datum/gas_mixture/removed = new - removed.oxygen = QUANTIZE((oxygen/sum)*amount) - removed.nitrogen = QUANTIZE((nitrogen/sum)*amount) - removed.carbon_dioxide = QUANTIZE((carbon_dioxide/sum)*amount) - removed.toxins = QUANTIZE((toxins/sum)*amount) - - oxygen -= removed.oxygen/group_multiplier - nitrogen -= removed.nitrogen/group_multiplier - carbon_dioxide -= removed.carbon_dioxide/group_multiplier - toxins -= removed.toxins/group_multiplier - - if(trace_gases.len) - for(var/datum/gas/trace_gas in trace_gases) - var/datum/gas/corresponding = new trace_gas.type() - removed.trace_gases += corresponding - - corresponding.moles = (trace_gas.moles/sum)*amount - trace_gas.moles -= corresponding.moles/group_multiplier -/* - if(aerosols.total_volume > 1) - removed.aerosols.trans_to_atmos(src,(aerosols.total_volume/sum)*amount) -*/ + for(var/gasid in gases) + var/taken_gas = QUANTIZE(get_moles_by_id(gasid) / sum) * amount //the gas we lose - not yet subtracted + adjust_gas(gasid, -taken_gas, 0) //don't update just yet - negative subtracts + removed.adjust_gas(gasid, taken_gas, 0) //slap the copied gas in removed.temperature = temperature update_values() @@ -511,31 +468,7 @@ What are the archived variables for? ratio = min(ratio, 1) - var/datum/gas_mixture/removed = new - - removed.oxygen = QUANTIZE(oxygen*ratio) - removed.nitrogen = QUANTIZE(nitrogen*ratio) - removed.carbon_dioxide = QUANTIZE(carbon_dioxide*ratio) - removed.toxins = QUANTIZE(toxins*ratio) - - oxygen -= removed.oxygen/group_multiplier - nitrogen -= removed.nitrogen/group_multiplier - carbon_dioxide -= removed.carbon_dioxide/group_multiplier - toxins -= removed.toxins/group_multiplier - - if(trace_gases.len) - for(var/datum/gas/trace_gas in trace_gases) - var/datum/gas/corresponding = new trace_gas.type() - removed.trace_gases += corresponding - - corresponding.moles = trace_gas.moles*ratio - trace_gas.moles -= corresponding.moles/group_multiplier - - removed.temperature = temperature - update_values() - removed.update_values() - - return removed + return remove(total_moles() * ratio) //use the sum removal /datum/gas_mixture/proc/check_then_remove(amount) //Purpose: Similar to remove(...) but first checks to see if the amount of air removed is small enough @@ -544,7 +477,7 @@ What are the archived variables for? //Inputs: Number of moles to remove //Outputs: Removed air or 0 if it can remove air or not. - amount = min(amount,total_moles()) //Can not take more air than tile has! + amount = Clamp(amount, 0, total_moles()) //Can not take more air than tile has! if((amount > MINIMUM_AIR_RATIO_TO_SUSPEND) && (amount > total_moles()*MINIMUM_AIR_RATIO_TO_SUSPEND)) return 0 @@ -557,22 +490,13 @@ What are the archived variables for? //Inputs: Gas to copy //Outputs: 1 - oxygen = sample.oxygen - carbon_dioxide = sample.carbon_dioxide - nitrogen = sample.nitrogen - toxins = sample.toxins - total_moles = sample.total_moles() - - trace_gases.len=null - if(sample.trace_gases.len > 0) - for(var/datum/gas/trace_gas in sample.trace_gases) - var/datum/gas/corresponding = new trace_gas.type() - trace_gases += corresponding - - corresponding.moles = trace_gas.moles + for(var/gasid in sample.gases) + set_gas(gasid, sample.get_moles_by_id(gasid), 0) temperature = sample.temperature + update_values() + return 1 /datum/gas_mixture/proc/check_gas_mixture(datum/gas_mixture/sharer) @@ -585,82 +509,38 @@ What are the archived variables for? if(!istype(sharer)) return - var/delta_oxygen = QUANTIZE(oxygen_archived - sharer.oxygen_archived)/TRANSFER_FRACTION - var/delta_carbon_dioxide = QUANTIZE(carbon_dioxide_archived - sharer.carbon_dioxide_archived)/TRANSFER_FRACTION - var/delta_nitrogen = QUANTIZE(nitrogen_archived - sharer.nitrogen_archived)/TRANSFER_FRACTION - var/delta_toxins = QUANTIZE(toxins_archived - sharer.toxins_archived)/TRANSFER_FRACTION - - var/delta_temperature = (temperature_archived - sharer.temperature_archived) - - if(((abs(delta_oxygen) > MINIMUM_AIR_TO_SUSPEND) && (abs(delta_oxygen) >= oxygen_archived*MINIMUM_AIR_RATIO_TO_SUSPEND)) \ - || ((abs(delta_carbon_dioxide) > MINIMUM_AIR_TO_SUSPEND) && (abs(delta_carbon_dioxide) >= carbon_dioxide_archived*MINIMUM_AIR_RATIO_TO_SUSPEND)) \ - || ((abs(delta_nitrogen) > MINIMUM_AIR_TO_SUSPEND) && (abs(delta_nitrogen) >= nitrogen_archived*MINIMUM_AIR_RATIO_TO_SUSPEND)) \ - || ((abs(delta_toxins) > MINIMUM_AIR_TO_SUSPEND) && (abs(delta_toxins) >= toxins_archived*MINIMUM_AIR_RATIO_TO_SUSPEND))) + if(abs(temperature_archived - sharer.temperature_archived) > MINIMUM_TEMPERATURE_DELTA_TO_SUSPEND) return 0 - if(abs(delta_temperature) > MINIMUM_TEMPERATURE_DELTA_TO_SUSPEND) - return 0 + for(var/gasid in gases) + var/archived_own_gas = get_archived_moles_by_id(gasid) + var/archived_sharer_gas = sharer.get_archived_moles_by_id(gasid) + var/gas_delta = abs(QUANTIZE(archived_own_gas - archived_sharer_gas)/TRANSFER_FRACTION) //the difference in gas moles - if(sharer.trace_gases.len) - for(var/datum/gas/trace_gas in sharer.trace_gases) - if(trace_gas.moles_archived > MINIMUM_AIR_TO_SUSPEND*4) - var/datum/gas/corresponding = locate(trace_gas.type) in trace_gases - if(corresponding) - if(trace_gas.moles_archived >= corresponding.moles_archived*MINIMUM_AIR_RATIO_TO_SUSPEND*4) - return 0 - else - return 0 + if((gas_delta > MINIMUM_AIR_TO_SUSPEND) && (gas_delta >= archived_own_gas*MINIMUM_AIR_RATIO_TO_SUSPEND)) + return 0 - if(trace_gases.len) - for(var/datum/gas/trace_gas in trace_gases) - if(trace_gas.moles_archived > MINIMUM_AIR_TO_SUSPEND*4) - if(!locate(trace_gas.type) in sharer.trace_gases) - return 0 - - if(((abs(delta_oxygen) > MINIMUM_AIR_TO_SUSPEND) && (abs(delta_oxygen) >= sharer.oxygen_archived*MINIMUM_AIR_RATIO_TO_SUSPEND)) \ - || ((abs(delta_carbon_dioxide) > MINIMUM_AIR_TO_SUSPEND) && (abs(delta_carbon_dioxide) >= sharer.carbon_dioxide_archived*MINIMUM_AIR_RATIO_TO_SUSPEND)) \ - || ((abs(delta_nitrogen) > MINIMUM_AIR_TO_SUSPEND) && (abs(delta_nitrogen) >= sharer.nitrogen_archived*MINIMUM_AIR_RATIO_TO_SUSPEND)) \ - || ((abs(delta_toxins) > MINIMUM_AIR_TO_SUSPEND) && (abs(delta_toxins) >= sharer.toxins_archived*MINIMUM_AIR_RATIO_TO_SUSPEND))) - return -1 - - if(trace_gases.len) - for(var/datum/gas/trace_gas in trace_gases) - if(trace_gas.moles_archived > MINIMUM_AIR_TO_SUSPEND*4) - var/datum/gas/corresponding = locate(trace_gas.type) in sharer.trace_gases - if(corresponding) - if(trace_gas.moles_archived >= corresponding.moles_archived*MINIMUM_AIR_RATIO_TO_SUSPEND*4) - return -1 - else - return -1 + if((gas_delta > MINIMUM_AIR_TO_SUSPEND) && (gas_delta >= archived_sharer_gas*MINIMUM_AIR_RATIO_TO_SUSPEND)) + return -1 return 1 -/datum/gas_mixture/proc/check_turf(turf/model) +/datum/gas_mixture/proc/check_turf(turf/model_turf) //Purpose: Used to compare the gases in an unsimulated turf with the gas in a simulated one. //Called by: Sharing air (mimicing) with adjacent unsimulated turfs //Inputs: Unsimulated turf //Outputs: 1 if safe to mimic, 0 if needs to break airgroup. - var/delta_oxygen = (oxygen_archived - model.oxygen)/TRANSFER_FRACTION - var/delta_carbon_dioxide = (carbon_dioxide_archived - model.carbon_dioxide)/TRANSFER_FRACTION - var/delta_nitrogen = (nitrogen_archived - model.nitrogen)/TRANSFER_FRACTION - var/delta_toxins = (toxins_archived - model.toxins)/TRANSFER_FRACTION + var/datum/gas_mixture/model = model_turf.return_air() - var/delta_temperature = (temperature_archived - model.temperature) - - if(((abs(delta_oxygen) > MINIMUM_AIR_TO_SUSPEND) && (abs(delta_oxygen) >= oxygen_archived*MINIMUM_AIR_RATIO_TO_SUSPEND)) \ - || ((abs(delta_carbon_dioxide) > MINIMUM_AIR_TO_SUSPEND) && (abs(delta_carbon_dioxide) >= carbon_dioxide_archived*MINIMUM_AIR_RATIO_TO_SUSPEND)) \ - || ((abs(delta_nitrogen) > MINIMUM_AIR_TO_SUSPEND) && (abs(delta_nitrogen) >= nitrogen_archived*MINIMUM_AIR_RATIO_TO_SUSPEND)) \ - || ((abs(delta_toxins) > MINIMUM_AIR_TO_SUSPEND) && (abs(delta_toxins) >= toxins_archived*MINIMUM_AIR_RATIO_TO_SUSPEND))) - return 0 - if(abs(delta_temperature) > MINIMUM_TEMPERATURE_DELTA_TO_SUSPEND) + if(abs(temperature_archived - model.temperature) > MINIMUM_TEMPERATURE_DELTA_TO_SUSPEND) return 0 - if(trace_gases.len) - for(var/datum/gas/trace_gas in trace_gases) - if(trace_gas.moles_archived > MINIMUM_AIR_TO_SUSPEND*4) - return 0 - + for(var/gasid in gases) + var/archived_gas = get_archived_moles_by_id(gasid) + var/gas_delta = abs((archived_gas - model.get_moles_by_id(gasid))/TRANSFER_FRACTION) + if((gas_delta > MINIMUM_AIR_TO_SUSPEND) && (gas_delta >= archived_gas*MINIMUM_AIR_RATIO_TO_SUSPEND)) + return 0 return 1 /datum/gas_mixture/proc/share(datum/gas_mixture/sharer) @@ -674,11 +554,6 @@ What are the archived variables for? if(!istype(sharer)) return - var/delta_oxygen = QUANTIZE(oxygen_archived - sharer.oxygen_archived)/TRANSFER_FRACTION - var/delta_carbon_dioxide = QUANTIZE(carbon_dioxide_archived - sharer.carbon_dioxide_archived)/TRANSFER_FRACTION - var/delta_nitrogen = QUANTIZE(nitrogen_archived - sharer.nitrogen_archived)/TRANSFER_FRACTION - var/delta_toxins = QUANTIZE(toxins_archived - sharer.toxins_archived)/TRANSFER_FRACTION - var/delta_temperature = (temperature_archived - sharer.temperature_archived) var/old_self_heat_capacity = 0 @@ -689,107 +564,29 @@ What are the archived variables for? var/heat_sharer_to_self = 0 var/heat_capacity_sharer_to_self = 0 + var/moved_moles = 0 + + for(var/gasid in gases) + var/gas_delta = QUANTIZE(get_archived_moles_by_id(gasid) - sharer.get_archived_moles_by_id(gasid))/TRANSFER_FRACTION + if(gas_delta && abs(delta_temperature) > MINIMUM_TEMPERATURE_DELTA_TO_CONSIDER) //difference in gases and temperature + var/datum/gas/current_gas = get_gas_by_id(gasid) + var/gas_heat_capacity = current_gas.specific_heat + if(gas_delta > 0) + heat_self_to_sharer += gas_heat_capacity * temperature_archived + heat_capacity_self_to_sharer += gas_heat_capacity + else + heat_sharer_to_self -= gas_heat_capacity * temperature_archived + heat_capacity_sharer_to_self -= gas_heat_capacity + + adjust_gas(gasid, -gas_delta, 0) //delay update - adjust_gas handles the group multiplier + sharer.adjust_gas(gasid, gas_delta, 0) + + moved_moles += gas_delta + if(abs(delta_temperature) > MINIMUM_TEMPERATURE_DELTA_TO_CONSIDER) - - var/delta_air = delta_oxygen+delta_nitrogen - if(delta_air) - var/air_heat_capacity = SPECIFIC_HEAT_AIR*delta_air - if(delta_air > 0) - heat_self_to_sharer += air_heat_capacity*temperature_archived - heat_capacity_self_to_sharer += air_heat_capacity - else - heat_sharer_to_self -= air_heat_capacity*sharer.temperature_archived - heat_capacity_sharer_to_self -= air_heat_capacity - - if(delta_carbon_dioxide) - var/carbon_dioxide_heat_capacity = SPECIFIC_HEAT_CDO*delta_carbon_dioxide - if(delta_carbon_dioxide > 0) - heat_self_to_sharer += carbon_dioxide_heat_capacity*temperature_archived - heat_capacity_self_to_sharer += carbon_dioxide_heat_capacity - else - heat_sharer_to_self -= carbon_dioxide_heat_capacity*sharer.temperature_archived - heat_capacity_sharer_to_self -= carbon_dioxide_heat_capacity - - if(delta_toxins) - var/toxins_heat_capacity = SPECIFIC_HEAT_TOXIN*delta_toxins - if(delta_toxins > 0) - heat_self_to_sharer += toxins_heat_capacity*temperature_archived - heat_capacity_self_to_sharer += toxins_heat_capacity - else - heat_sharer_to_self -= toxins_heat_capacity*sharer.temperature_archived - heat_capacity_sharer_to_self -= toxins_heat_capacity - old_self_heat_capacity = heat_capacity()*group_multiplier old_sharer_heat_capacity = sharer.heat_capacity()*sharer.group_multiplier - oxygen -= delta_oxygen/group_multiplier - sharer.oxygen += delta_oxygen/sharer.group_multiplier - - carbon_dioxide -= delta_carbon_dioxide/group_multiplier - sharer.carbon_dioxide += delta_carbon_dioxide/sharer.group_multiplier - - nitrogen -= delta_nitrogen/group_multiplier - sharer.nitrogen += delta_nitrogen/sharer.group_multiplier - - toxins -= delta_toxins/group_multiplier - sharer.toxins += delta_toxins/sharer.group_multiplier - - var/moved_moles = (delta_oxygen + delta_carbon_dioxide + delta_nitrogen + delta_toxins) - - var/list/trace_types_considered = list() - - if(trace_gases.len) - for(var/datum/gas/trace_gas in trace_gases) - - var/datum/gas/corresponding = locate(trace_gas.type) in sharer.trace_gases - var/delta = 0 - - if(corresponding) - delta = QUANTIZE(trace_gas.moles_archived - corresponding.moles_archived)/TRANSFER_FRACTION - else - corresponding = new trace_gas.type() - sharer.trace_gases += corresponding - - delta = trace_gas.moles_archived/TRANSFER_FRACTION - - trace_gas.moles -= delta/group_multiplier - corresponding.moles += delta/sharer.group_multiplier - - if(delta) - var/individual_heat_capacity = trace_gas.specific_heat*delta - if(delta > 0) - heat_self_to_sharer += individual_heat_capacity*temperature_archived - heat_capacity_self_to_sharer += individual_heat_capacity - else - heat_sharer_to_self -= individual_heat_capacity*sharer.temperature_archived - heat_capacity_sharer_to_self -= individual_heat_capacity - - moved_moles += delta - - trace_types_considered += trace_gas.type - - - if(sharer.trace_gases.len) - for(var/datum/gas/trace_gas in sharer.trace_gases) - if(trace_gas.type in trace_types_considered) continue - else - var/datum/gas/corresponding - var/delta = 0 - - corresponding = new trace_gas.type() - trace_gases += corresponding - - delta = trace_gas.moles_archived/TRANSFER_FRACTION - - trace_gas.moles -= delta/sharer.group_multiplier - corresponding.moles += delta/group_multiplier - - //Guaranteed transfer from sharer to self - var/individual_heat_capacity = trace_gas.specific_heat*delta - heat_sharer_to_self += individual_heat_capacity*sharer.temperature_archived - heat_capacity_sharer_to_self += individual_heat_capacity - - moved_moles += -delta update_values() sharer.update_values() @@ -814,16 +611,13 @@ What are the archived variables for? else return 0 -/datum/gas_mixture/proc/mimic(turf/model, border_multiplier) +/datum/gas_mixture/proc/mimic(turf/model_turf, border_multiplier) //Purpose: Used transfer gas from a more pressurised tile to a less presurised unsimulated tile. //Called by: "sharing" from unsimulated to simulated turfs. //Inputs: Unsimulated turf, Multiplier for gas transfer (optional) //Outputs: Amount of gas exchanged - var/delta_oxygen = QUANTIZE(oxygen_archived - model.oxygen)/TRANSFER_FRACTION - var/delta_carbon_dioxide = QUANTIZE(carbon_dioxide_archived - model.carbon_dioxide)/TRANSFER_FRACTION - var/delta_nitrogen = QUANTIZE(nitrogen_archived - model.nitrogen)/TRANSFER_FRACTION - var/delta_toxins = QUANTIZE(toxins_archived - model.toxins)/TRANSFER_FRACTION + var/datum/gas_mixture/model = model_turf.return_air() var/delta_temperature = (temperature_archived - model.temperature) @@ -831,54 +625,28 @@ What are the archived variables for? var/old_self_heat_capacity = 0 var/heat_capacity_transferred = 0 + var/moved_moles + + for(var/gasid in gases) + var/gas_delta = QUANTIZE(get_archived_moles_by_id(gasid) - model.get_moles_by_id(gasid))/TRANSFER_FRACTION + + if(abs(delta_temperature) > MINIMUM_TEMPERATURE_DELTA_TO_CONSIDER) + var/datum/gas/current_gas = get_gas_by_id(gasid) + var/gas_heat_capacity = current_gas.specific_heat * gas_delta + heat_transferred -= gas_heat_capacity * model.temperature + heat_capacity_transferred -= gas_heat_capacity + + if(border_multiplier) + adjust_gas(gasid, -gas_delta*border_multiplier, 0) //the 0 delays updates + else + adjust_gas(gasid, -gas_delta, 0) + + moved_moles += gas_delta + + if(abs(delta_temperature) > MINIMUM_TEMPERATURE_DELTA_TO_CONSIDER) - - var/delta_air = delta_oxygen+delta_nitrogen - if(delta_air) - var/air_heat_capacity = SPECIFIC_HEAT_AIR*delta_air - heat_transferred -= air_heat_capacity*model.temperature - heat_capacity_transferred -= air_heat_capacity - - if(delta_carbon_dioxide) - var/carbon_dioxide_heat_capacity = SPECIFIC_HEAT_CDO*delta_carbon_dioxide - heat_transferred -= carbon_dioxide_heat_capacity*model.temperature - heat_capacity_transferred -= carbon_dioxide_heat_capacity - - if(delta_toxins) - var/toxins_heat_capacity = SPECIFIC_HEAT_TOXIN*delta_toxins - heat_transferred -= toxins_heat_capacity*model.temperature - heat_capacity_transferred -= toxins_heat_capacity - old_self_heat_capacity = heat_capacity()*group_multiplier - if(border_multiplier) - oxygen -= delta_oxygen*border_multiplier/group_multiplier - carbon_dioxide -= delta_carbon_dioxide*border_multiplier/group_multiplier - nitrogen -= delta_nitrogen*border_multiplier/group_multiplier - toxins -= delta_toxins*border_multiplier/group_multiplier - else - oxygen -= delta_oxygen/group_multiplier - carbon_dioxide -= delta_carbon_dioxide/group_multiplier - nitrogen -= delta_nitrogen/group_multiplier - toxins -= delta_toxins/group_multiplier - - var/moved_moles = (delta_oxygen + delta_carbon_dioxide + delta_nitrogen + delta_toxins) - - if(trace_gases.len) - for(var/datum/gas/trace_gas in trace_gases) - var/delta = 0 - - delta = trace_gas.moles_archived/TRANSFER_FRACTION - - if(border_multiplier) - trace_gas.moles -= delta*border_multiplier/group_multiplier - else - trace_gas.moles -= delta/group_multiplier - - var/heat_cap_transferred = delta*trace_gas.specific_heat - heat_transferred += heat_cap_transferred*temperature_archived - heat_capacity_transferred += heat_cap_transferred - moved_moles += delta update_values() if(abs(delta_temperature) > MINIMUM_TEMPERATURE_DELTA_TO_CONSIDER) @@ -889,10 +657,10 @@ What are the archived variables for? else temperature = (old_self_heat_capacity*temperature - heat_capacity_transferred*border_multiplier*temperature_archived)/new_self_heat_capacity - temperature_mimic(model, model.thermal_conductivity, border_multiplier) + temperature_mimic(model, model_turf.thermal_conductivity, border_multiplier) if((delta_temperature > MINIMUM_TEMPERATURE_TO_MOVE) || abs(moved_moles) > MINIMUM_MOLES_DELTA_TO_MOVE) - var/delta_pressure = temperature_archived*(total_moles() + moved_moles) - model.temperature*(model.oxygen+model.carbon_dioxide+model.nitrogen+model.toxins) + var/delta_pressure = temperature_archived*(total_moles() + moved_moles) - model.temperature*(model.total_moles()) return delta_pressure*R_IDEAL_GAS_EQUATION/volume else return 0 @@ -1059,66 +827,26 @@ What are the archived variables for? //Outputs: 1 if can rebuild, 0 if not. if(!sample) return 0 - if((abs(oxygen-sample.oxygen) > MINIMUM_AIR_TO_SUSPEND) && \ - ((oxygen < (1-MINIMUM_AIR_RATIO_TO_SUSPEND)*sample.oxygen) || (oxygen > (1+MINIMUM_AIR_RATIO_TO_SUSPEND)*sample.oxygen))) - return 0 - if((abs(nitrogen-sample.nitrogen) > MINIMUM_AIR_TO_SUSPEND) && \ - ((nitrogen < (1-MINIMUM_AIR_RATIO_TO_SUSPEND)*sample.nitrogen) || (nitrogen > (1+MINIMUM_AIR_RATIO_TO_SUSPEND)*sample.nitrogen))) - return 0 - if((abs(carbon_dioxide-sample.carbon_dioxide) > MINIMUM_AIR_TO_SUSPEND) && \ - ((carbon_dioxide < (1-MINIMUM_AIR_RATIO_TO_SUSPEND)*sample.carbon_dioxide) || (carbon_dioxide > (1+MINIMUM_AIR_RATIO_TO_SUSPEND)*sample.carbon_dioxide))) - return 0 - if((abs(toxins-sample.toxins) > MINIMUM_AIR_TO_SUSPEND) && \ - ((toxins < (1-MINIMUM_AIR_RATIO_TO_SUSPEND)*sample.toxins) || (toxins > (1+MINIMUM_AIR_RATIO_TO_SUSPEND)*sample.toxins))) - return 0 + for(var/gasid in gases) + var/current_gas = get_moles_by_id(gasid) + var/sample_gas = sample.get_moles_by_id(gasid) + if((abs(current_gas - sample_gas) > MINIMUM_AIR_TO_SUSPEND) && \ + ((current_gas < (1-MINIMUM_AIR_RATIO_TO_SUSPEND)*sample_gas) || (current_gas > (1+MINIMUM_AIR_RATIO_TO_SUSPEND)*sample_gas))) + return 0 if(total_moles() > MINIMUM_AIR_TO_SUSPEND) if((abs(temperature-sample.temperature) > MINIMUM_TEMPERATURE_DELTA_TO_SUSPEND) && \ ((temperature < (1-MINIMUM_TEMPERATURE_RATIO_TO_SUSPEND)*sample.temperature) || (temperature > (1+MINIMUM_TEMPERATURE_RATIO_TO_SUSPEND)*sample.temperature))) //world << "temp fail [temperature] & [sample.temperature]" return 0 - var/check_moles - if(sample.trace_gases.len) - for(var/datum/gas/trace_gas in sample.trace_gases) - var/datum/gas/corresponding = locate(trace_gas.type) in trace_gases - if(corresponding) - check_moles = corresponding.moles - else - check_moles = 0 - - if((abs(trace_gas.moles - check_moles) > MINIMUM_AIR_TO_SUSPEND) && \ - ((check_moles < (1-MINIMUM_AIR_RATIO_TO_SUSPEND)*trace_gas.moles) || (check_moles > (1+MINIMUM_AIR_RATIO_TO_SUSPEND)*trace_gas.moles))) - return 0 - - if(trace_gases.len) - for(var/datum/gas/trace_gas in trace_gases) - var/datum/gas/corresponding = locate(trace_gas.type) in trace_gases - if(corresponding) - check_moles = corresponding.moles - else - check_moles = 0 - - if((abs(trace_gas.moles - check_moles) > MINIMUM_AIR_TO_SUSPEND) && \ - ((trace_gas.moles < (1-MINIMUM_AIR_RATIO_TO_SUSPEND)*check_moles) || (trace_gas.moles > (1+MINIMUM_AIR_RATIO_TO_SUSPEND)*check_moles))) - return 0 - return 1 /datum/gas_mixture/proc/add(datum/gas_mixture/right_side) if(!right_side) return 0 - oxygen += right_side.oxygen - carbon_dioxide += right_side.carbon_dioxide - nitrogen += right_side.nitrogen - toxins += right_side.toxins - if(trace_gases.len || right_side.trace_gases.len) - for(var/datum/gas/trace_gas in right_side.trace_gases) - var/datum/gas/corresponding = locate(trace_gas.type) in trace_gases - if(!corresponding) - corresponding = new trace_gas.type() - trace_gases += corresponding - corresponding.moles += trace_gas.moles + for(var/gasid in right_side.gases) + adjust_gas(gasid, right_side.get_moles_by_id(gasid), 0, 0) update_values() return 1 @@ -1129,42 +857,19 @@ What are the archived variables for? //Inputs: Gas mix to remove //Outputs: 1 - oxygen = max(oxygen - right_side.oxygen) - carbon_dioxide = max(carbon_dioxide - right_side.carbon_dioxide) - nitrogen = max(nitrogen - right_side.nitrogen) - toxins = max(toxins - right_side.toxins) - - if(trace_gases.len || right_side.trace_gases.len) - for(var/datum/gas/trace_gas in right_side.trace_gases) - var/datum/gas/corresponding = locate(trace_gas.type) in trace_gases - if(corresponding) - corresponding.moles = max(0, corresponding.moles - trace_gas.moles) + for(var/gasid in right_side.gases) + adjust_gas(gasid, -right_side.get_moles_by_id(gasid), 0, 0) update_values() return 1 /datum/gas_mixture/proc/multiply(factor) - oxygen *= factor - carbon_dioxide *= factor - nitrogen *= factor - toxins *= factor - if(trace_gases && trace_gases.len) - for(var/datum/gas/trace_gas in trace_gases) - trace_gas.moles *= factor + for(var/gasid in gases) + adjust_gas(gasid, (factor - 1) * get_moles_by_id(gasid), 0, 0) update_values() return 1 /datum/gas_mixture/proc/divide(factor) - oxygen /= factor - carbon_dioxide /= factor - nitrogen /= factor - toxins /= factor - - if(trace_gases && trace_gases.len) - for(var/datum/gas/trace_gas in trace_gases) - trace_gas.moles /= factor - - update_values() - return 1 + return multiply(1/factor) diff --git a/code/_onclick/hud/screen_objects.dm b/code/_onclick/hud/screen_objects.dm index b2f2fc955d4..cbf8c36872d 100644 --- a/code/_onclick/hud/screen_objects.dm +++ b/code/_onclick/hud/screen_objects.dm @@ -285,8 +285,8 @@ else var/list/nicename = null var/list/tankcheck = null - var/breathes = "oxygen" //default, we'll check later - var/list/contents = list() + var/breathes = OXYGEN //default, we'll check later + var/list/tank_contents = list() if(ishuman(C)) var/mob/living/carbon/human/H = C @@ -305,50 +305,31 @@ if (!isnull(t.manipulated_by) && t.manipulated_by != C.real_name && findtext(t.desc,breathes)) contents.Add(t.air_contents.total_moles) //Someone messed with the tank and put unknown gasses continue //in it, so we're going to believe the tank is what it says it is - switch(breathes) - //These tanks we're sure of their contents - if("nitrogen") //So we're a bit more picky about them. - - if(t.air_contents.nitrogen && !t.air_contents.oxygen) - contents.Add(t.air_contents.nitrogen) - else - contents.Add(0) - - if ("oxygen") - if(t.air_contents.oxygen && !t.air_contents.toxins) - contents.Add(t.air_contents.oxygen) - else - contents.Add(0) - - // No races breath this, but never know about downstream servers. - if ("carbon dioxide") - if(t.air_contents.carbon_dioxide && !t.air_contents.toxins) - contents.Add(t.air_contents.carbon_dioxide) - else - contents.Add(0) - - // ACK ACK ACK Plasmen - if ("plasma") - if(t.air_contents.toxins) - contents.Add(t.air_contents.toxins) - else - contents.Add(0) + if(t.air_contents.get_moles_by_id(breathes)) + var/toxic_found + for(var/toxicid in C.toxic_to_breathe) + if(t.air_contents.get_moles_by_id(toxicid)) + tank_contents.Add(0) + toxic_found = 1 + break + if(!toxic_found) + tank_contents.Add(t.air_contents.get_moles_by_id(breathes)) else //no tank so we set contents to 0 - contents.Add(0) + tank_contents.Add(0) //Alright now we know the contents of the tanks so we have to pick the best one. var/best = 0 var/bestcontents = 0 - for(var/i=1, i < contents.len + 1 , ++i) - if(!contents[i]) + for(var/i=1, i < tank_contents.len + 1 , ++i) + if(!tank_contents[i]) continue - if(contents[i] > bestcontents) + if(tank_contents[i] > bestcontents) best = i - bestcontents = contents[i] + bestcontents = tank_contents[i] //We've determined the best container now we set it as our internals @@ -362,7 +343,7 @@ if(C.internals) C.internals.icon_state = "internal1" else - C << "You don't have a[breathes=="oxygen" ? "n oxygen" : addtext(" ",breathes)] tank." + C << "You don't have a[breathes==OXYGEN ? "n oxygen" : addtext(" ",breathes)] tank." if("act_intent") usr.a_intent_change("right") if("help") diff --git a/code/controllers/_DynamicAreaLighting_TG.dm b/code/controllers/_DynamicAreaLighting_TG.dm index 3f898980741..06d093d7994 100644 --- a/code/controllers/_DynamicAreaLighting_TG.dm +++ b/code/controllers/_DynamicAreaLighting_TG.dm @@ -139,12 +139,6 @@ atom //Turfs with opacity when they are constructed will trigger nearby lights to update //Turfs and atoms with luminosity when they are constructed will create a light_source automatically -turf/New() - ..() - if(luminosity) - if(light) WARNING("[type] - Don't set lights up manually during New(), We do it automatically.") - trueLuminosity = luminosity * luminosity - light = new(src) //Movable atoms with opacity when they are constructed will trigger nearby lights to update //Movable atoms with luminosity when they are constructed will create a light_source automatically diff --git a/code/game/gamemodes/events/ninja_equipment.dm b/code/game/gamemodes/events/ninja_equipment.dm index 38b6caf53eb..ca83fab7591 100644 --- a/code/game/gamemodes/events/ninja_equipment.dm +++ b/code/game/gamemodes/events/ninja_equipment.dm @@ -318,22 +318,12 @@ ________________________________________________________________________________ dat += "Air Pressure: [round(pressure,0.1)] kPa" - if (total_moles) - var/o2_level = environment.oxygen/total_moles - var/n2_level = environment.nitrogen/total_moles - var/co2_level = environment.carbon_dioxide/total_moles - var/plasma_level = environment.toxins/total_moles - var/unknown_level = 1-(o2_level+n2_level+co2_level+plasma_level) - dat += {""} - if(unknown_level > 0.01) - dat += "OTHER: [round(unknown_level)]%
" + dat += "