diff --git a/code/__DEFINES/atmospherics.dm b/code/__DEFINES/atmospherics.dm index f9c3b0d427..881f8d064b 100644 --- a/code/__DEFINES/atmospherics.dm +++ b/code/__DEFINES/atmospherics.dm @@ -270,16 +270,9 @@ T.pixel_x = (PipingLayer - PIPING_LAYER_DEFAULT) * PIPING_LAYER_P_X;\ T.pixel_y = (PipingLayer - PIPING_LAYER_DEFAULT) * PIPING_LAYER_P_Y; -#define THERMAL_ENERGY(gas) (gas.temperature * gas.heat_capacity()) #define QUANTIZE(variable) (round(variable,0.0000001))/*I feel the need to document what happens here. Basically this is used to catch most rounding errors, however it's previous value made it so that once gases got hot enough, most procedures wouldnt occur due to the fact that the mole counts would get rounded away. Thus, we lowered it a few orders of magnititude */ -//prefer this to gas_mixture/total_moles in performance critical areas -#define TOTAL_MOLES(cached_gases, out_var)\ - out_var = 0;\ - for(var/total_moles_id in cached_gases){\ - out_var += cached_gases[total_moles_id];\ - } #ifdef TESTING GLOBAL_LIST_INIT(atmos_adjacent_savings, list(0,0)) @@ -288,6 +281,17 @@ GLOBAL_LIST_INIT(atmos_adjacent_savings, list(0,0)) #define CALCULATE_ADJACENT_TURFS(T) SSadjacent_air.queue[T] = 1 #endif +GLOBAL_VAR(atmos_extools_initialized) // this must be an uninitialized (null) one or init_fastmos will be called twice because reasons +#define ATMOS_EXTOOLS_CHECK if(!GLOB.atmos_extools_initialized){\ + GLOB.atmos_extools_initialized=TRUE;\ + if(fexists(world.system_type == MS_WINDOWS ? "byond-extools.dll" : "libbyond-extools.so")){\ + var/result = call((world.system_type == MS_WINDOWS ? "byond-extools.dll" : "libbyond-extools.so"),"init_fastmos")();\ + if(result != "ok") {CRASH(result);}\ + } else {\ + CRASH("byond-extools.dll does not exist!");\ + }\ +} + //Unomos - So for whatever reason, garbage collection actually drastically decreases the cost of atmos later in the round. Turning this into a define yields massively improved performance. #define GAS_GARBAGE_COLLECT(GASGASGAS)\ var/list/CACHE_GAS = GASGASGAS;\ @@ -296,8 +300,6 @@ GLOBAL_LIST_INIT(atmos_adjacent_savings, list(0,0)) CACHE_GAS -= id;\ } -#define ARCHIVE_TEMPERATURE(gas) gas.temperature_archived = gas.temperature - GLOBAL_LIST_INIT(pipe_paint_colors, list( "amethyst" = rgb(130,43,255), //supplymain "blue" = rgb(0,0,255), diff --git a/code/datums/components/wet_floor.dm b/code/datums/components/wet_floor.dm index 0fbbcd59b0..e2c3cbff86 100644 --- a/code/datums/components/wet_floor.dm +++ b/code/datums/components/wet_floor.dm @@ -121,7 +121,7 @@ if(-INFINITY to T0C) add_wet(TURF_WET_ICE, max_time_left()) //Water freezes into ice! if(T0C to T0C + 100) - decrease = ((T.air.temperature - T0C) / SSwet_floors.temperature_coeff) * (diff / SSwet_floors.time_ratio) + decrease = ((T.air.return_temperature() - T0C) / SSwet_floors.temperature_coeff) * (diff / SSwet_floors.time_ratio) if(T0C + 100 to INFINITY) decrease = INFINITY decrease = max(0, decrease) diff --git a/code/datums/diseases/advance/symptoms/heal.dm b/code/datums/diseases/advance/symptoms/heal.dm index 59afe163b4..ae7a007321 100644 --- a/code/datums/diseases/advance/symptoms/heal.dm +++ b/code/datums/diseases/advance/symptoms/heal.dm @@ -404,7 +404,7 @@ if(M.loc) environment = M.loc.return_air() if(environment) - plasmamount = environment.gases[/datum/gas/plasma] + plasmamount = environment.get_moles(/datum/gas/plasma) if(plasmamount && plasmamount > GLOB.meta_gas_visibility[/datum/gas/plasma]) //if there's enough plasma in the air to see . += power * 0.5 if(M.reagents.has_reagent(/datum/reagent/toxin/plasma)) diff --git a/code/datums/helper_datums/teleport.dm b/code/datums/helper_datums/teleport.dm index c46a03a986..5e9371f754 100644 --- a/code/datums/helper_datums/teleport.dm +++ b/code/datums/helper_datums/teleport.dm @@ -117,9 +117,8 @@ continue var/datum/gas_mixture/A = F.air - var/list/A_gases = A.gases var/trace_gases - for(var/id in A_gases) + for(var/id in A.get_gases()) if(id in GLOB.hardcoded_gases) continue trace_gases = TRUE @@ -128,15 +127,15 @@ // Can most things breathe? if(trace_gases) continue - if(A_gases[/datum/gas/oxygen] <= 16) + if(A.get_moles(/datum/gas/oxygen) < 16) continue - if(A_gases[/datum/gas/plasma]) + if(A.get_moles(/datum/gas/plasma)) continue - if(A_gases[/datum/gas/carbon_dioxide] >= 10) + if(A.get_moles(/datum/gas/carbon_dioxide) >= 10) continue // Aim for goldilocks temperatures and pressure - if((A.temperature <= 270) || (A.temperature >= 360)) + if((A.return_temperature() <= 270) || (A.return_temperature() >= 360)) continue var/pressure = A.return_pressure() if((pressure <= 20) || (pressure >= 550)) diff --git a/code/datums/mutations/actions.dm b/code/datums/mutations/actions.dm index e933e02c15..2c10838314 100644 --- a/code/datums/mutations/actions.dm +++ b/code/datums/mutations/actions.dm @@ -222,9 +222,8 @@ /obj/effect/proc_holder/spell/targeted/olfaction/cast(list/targets, mob/living/user = usr) //can we sniff? is there miasma in the air? var/datum/gas_mixture/air = user.loc.return_air() - var/list/cached_gases = air.gases - if(cached_gases[/datum/gas/miasma]) + if(air.get_moles(/datum/gas/miasma)) user.adjust_disgust(sensitivity * 45) to_chat(user, "With your overly sensitive nose, you get a whiff of stench and feel sick! Try moving to a cleaner area!") return diff --git a/code/game/gamemodes/objective_items.dm b/code/game/gamemodes/objective_items.dm index 2e5dae3e04..7e25b69d15 100644 --- a/code/game/gamemodes/objective_items.dm +++ b/code/game/gamemodes/objective_items.dm @@ -124,7 +124,7 @@ /datum/objective_item/steal/plasma/check_special_completion(obj/item/tank/T) var/target_amount = text2num(name) var/found_amount = 0 - found_amount += T.air_contents.gases[/datum/gas/plasma] + found_amount += T.air_contents.get_moles(/datum/gas/plasma) return found_amount>=target_amount diff --git a/code/game/machinery/computer/atmos_control.dm b/code/game/machinery/computer/atmos_control.dm index 79ea51eca4..2faf76ca94 100644 --- a/code/game/machinery/computer/atmos_control.dm +++ b/code/game/machinery/computer/atmos_control.dm @@ -53,14 +53,14 @@ "id_tag" = id_tag, "timestamp" = world.time, "pressure" = air_sample.return_pressure(), - "temperature" = air_sample.temperature, + "temperature" = air_sample.return_temperature(), "gases" = list() )) var/total_moles = air_sample.total_moles() if(total_moles) - for(var/gas_id in air_sample.gases) + for(var/gas_id in air_sample.get_gases()) var/gas_name = GLOB.meta_gas_names[gas_id] - signal.data["gases"][gas_name] = air_sample.gases[gas_id] / total_moles * 100 + signal.data["gases"][gas_name] = air_sample.get_moles(gas_id) / total_moles * 100 radio_connection.post_signal(src, signal, filter = RADIO_ATMOSIA) diff --git a/code/game/machinery/spaceheater.dm b/code/game/machinery/spaceheater.dm index f9f4eb3e80..01d236a534 100644 --- a/code/game/machinery/spaceheater.dm +++ b/code/game/machinery/spaceheater.dm @@ -83,9 +83,9 @@ var/datum/gas_mixture/env = L.return_air() var/newMode = HEATER_MODE_STANDBY - if(setMode != HEATER_MODE_COOL && env.temperature < targetTemperature - temperatureTolerance) + if(setMode != HEATER_MODE_COOL && env.return_temperature() < targetTemperature - temperatureTolerance) newMode = HEATER_MODE_HEAT - else if(setMode != HEATER_MODE_HEAT && env.temperature > targetTemperature + temperatureTolerance) + else if(setMode != HEATER_MODE_HEAT && env.return_temperature() > targetTemperature + temperatureTolerance) newMode = HEATER_MODE_COOL if(mode != newMode) @@ -96,7 +96,7 @@ return var/heat_capacity = env.heat_capacity() - var/requiredPower = abs(env.temperature - targetTemperature) * heat_capacity + var/requiredPower = abs(env.return_temperature() - targetTemperature) * heat_capacity requiredPower = min(requiredPower, heatingPower) if(requiredPower < 1) @@ -106,7 +106,7 @@ if(mode == HEATER_MODE_COOL) deltaTemperature *= -1 if(deltaTemperature) - env.temperature += deltaTemperature + env.set_temperature(env.return_temperature() + deltaTemperature) air_update_turf() cell.use(requiredPower / efficiency) else @@ -189,9 +189,9 @@ var/curTemp if(istype(L)) var/datum/gas_mixture/env = L.return_air() - curTemp = env.temperature + curTemp = env.return_temperature() else if(isturf(L)) - curTemp = L.temperature + curTemp = L.return_temperature() if(isnull(curTemp)) data["currentTemp"] = "N/A" else diff --git a/code/game/mecha/combat/honker.dm b/code/game/mecha/combat/honker.dm index 717884e9a4..89b641ccc6 100644 --- a/code/game/mecha/combat/honker.dm +++ b/code/game/mecha/combat/honker.dm @@ -21,7 +21,7 @@ var/cell_charge = get_charge() var/datum/gas_mixture/int_tank_air = internal_tank.return_air() var/tank_pressure = internal_tank ? round(int_tank_air.return_pressure(),0.01) : "None" - var/tank_temperature = internal_tank ? int_tank_air.temperature : "Unknown" + var/tank_temperature = internal_tank ? int_tank_air.return_temperature() : "Unknown" var/cabin_pressure = round(return_pressure(),0.01) var/output = {"[report_internal_damage()] [integrity<30?"DAMAGE LEVEL CRITICAL
":null] @@ -155,4 +155,4 @@ var/color="" for (var/i=0;i<6;i++) color = color+pick(colors) - return color \ No newline at end of file + return color diff --git a/code/game/mecha/equipment/tools/other_tools.dm b/code/game/mecha/equipment/tools/other_tools.dm index 4ddb5281ea..f5a8965716 100644 --- a/code/game/mecha/equipment/tools/other_tools.dm +++ b/code/game/mecha/equipment/tools/other_tools.dm @@ -422,13 +422,13 @@ return var/datum/gas_mixture/GM = new if(prob(10)) - GM.gases[/datum/gas/plasma] += 100 - GM.temperature = 1500+T0C //should be enough to start a fire + GM.adjust_moles(/datum/gas/plasma,100) + GM.set_temperature(1500+T0C) //should be enough to start a fire T.visible_message("[src] suddenly disgorges a cloud of heated plasma.") qdel(src) else - GM.gases[/datum/gas/plasma] += 5 - GM.temperature = istype(T) ? T.air.return_temperature() : T20C + GM.adjust_moles(/datum/gas/plasma,5) + GM.set_temperature(istype(T) ? T.air.return_temperature() : T20C) T.visible_message("[src] suddenly disgorges a cloud of plasma.") T.assume_air(GM) return diff --git a/code/game/mecha/mecha.dm b/code/game/mecha/mecha.dm index 02115d3e30..e71276d1b1 100644 --- a/code/game/mecha/mecha.dm +++ b/code/game/mecha/mecha.dm @@ -247,10 +247,10 @@ /obj/mecha/proc/add_cabin() cabin_air = new - cabin_air.temperature = T20C - cabin_air.volume = 200 - cabin_air.gases[/datum/gas/oxygen] = O2STANDARD*cabin_air.volume/(R_IDEAL_GAS_EQUATION*cabin_air.temperature) - cabin_air.gases[/datum/gas/nitrogen] = N2STANDARD*cabin_air.volume/(R_IDEAL_GAS_EQUATION*cabin_air.temperature) + cabin_air.set_temperature(T20C) + cabin_air.set_volume(200) + cabin_air.set_moles(/datum/gas/oxygen,O2STANDARD*cabin_air.return_volume()/(R_IDEAL_GAS_EQUATION*cabin_air.return_temperature())) + cabin_air.set_moles(/datum/gas/nitrogen,N2STANDARD*cabin_air.return_volume()/(R_IDEAL_GAS_EQUATION*cabin_air.return_temperature())) return cabin_air /obj/mecha/proc/add_radio() @@ -302,9 +302,9 @@ if(int_tank_air.return_pressure() > internal_tank.maximum_pressure && !(internal_damage & MECHA_INT_TANK_BREACH)) setInternalDamage(MECHA_INT_TANK_BREACH) if(int_tank_air && int_tank_air.return_volume() > 0) //heat the air_contents - int_tank_air.temperature = min(6000+T0C, int_tank_air.temperature+rand(10,15)) + int_tank_air.set_temperature(min(6000+T0C, int_tank_air.return_temperature()+rand(10,15))) if(cabin_air && cabin_air.return_volume()>0) - cabin_air.temperature = min(6000+T0C, cabin_air.return_temperature()+rand(10,15)) + cabin_air.set_temperature(min(6000+T0C, cabin_air.return_temperature()+rand(10,15))) if(cabin_air.return_temperature() > max_temperature/2) take_damage(4/round(max_temperature/cabin_air.return_temperature(),0.1), BURN, 0, 0) @@ -329,8 +329,8 @@ if(internal_temp_regulation) if(cabin_air && cabin_air.return_volume() > 0) - var/delta = cabin_air.temperature - T20C - cabin_air.temperature -= max(-10, min(10, round(delta/4,0.1))) + var/delta = cabin_air.return_temperature() - T20C + cabin_air.set_temperature(cabin_air.return_temperature() - max(-10, min(10, round(delta/4,0.1)))) if(internal_tank) var/datum/gas_mixture/tank_air = internal_tank.return_air() diff --git a/code/game/mecha/mecha_topic.dm b/code/game/mecha/mecha_topic.dm index 8d6328cf08..0d921dae0a 100644 --- a/code/game/mecha/mecha_topic.dm +++ b/code/game/mecha/mecha_topic.dm @@ -75,7 +75,7 @@ var/cell_charge = get_charge() var/datum/gas_mixture/int_tank_air = internal_tank.return_air() var/tank_pressure = internal_tank ? round(int_tank_air.return_pressure(),0.01) : "None" - var/tank_temperature = internal_tank ? int_tank_air.temperature : "Unknown" + var/tank_temperature = internal_tank ? int_tank_air.return_temperature() : "Unknown" var/cabin_pressure = round(return_pressure(),0.01) . = {"[report_internal_damage()] [integrity<30?"DAMAGE LEVEL CRITICAL
":null] diff --git a/code/game/objects/effects/effect_system/effects_foam.dm b/code/game/objects/effects/effect_system/effects_foam.dm index f98b4937ef..23c5822727 100644 --- a/code/game/objects/effects/effect_system/effects_foam.dm +++ b/code/game/objects/effects/effect_system/effects_foam.dm @@ -40,12 +40,11 @@ if(hotspot && istype(T) && T.air) qdel(hotspot) var/datum/gas_mixture/G = T.air - var/plas_amt = min(30,G.gases[/datum/gas/plasma]) //Absorb some plasma - G.gases[/datum/gas/plasma] -= plas_amt + var/plas_amt = min(30,G.get_moles(/datum/gas/plasma)) //Absorb some plasma + G.adjust_moles(/datum/gas/plasma,-plas_amt) absorbed_plasma += plas_amt - if(G.temperature > T20C) - G.temperature = max(G.temperature/2,T20C) - GAS_GARBAGE_COLLECT(G.gases) + if(G.return_temperature() > T20C) + G.set_temperature(max(G.return_temperature()/2,T20C)) T.air_update_turf() /obj/effect/particle_effect/foam/firefighting/kill_foam() @@ -317,15 +316,13 @@ O.ClearWet() if(O.air) var/datum/gas_mixture/G = O.air - G.temperature = 293.15 + G.set_temperature(293.15) for(var/obj/effect/hotspot/H in O) qdel(H) - var/list/G_gases = G.gases - for(var/I in G_gases) + for(var/I in G.get_gases()) if(I == /datum/gas/oxygen || I == /datum/gas/nitrogen) continue - G_gases[I] = 0 - GAS_GARBAGE_COLLECT(G.gases) + G.set_moles(I, 0) O.air_update_turf() for(var/obj/machinery/atmospherics/components/unary/U in O) if(!U.welded) diff --git a/code/game/objects/effects/effect_system/effects_smoke.dm b/code/game/objects/effects/effect_system/effects_smoke.dm index 80c0db2b7d..9a11f0e1d7 100644 --- a/code/game/objects/effects/effect_system/effects_smoke.dm +++ b/code/game/objects/effects/effect_system/effects_smoke.dm @@ -166,15 +166,13 @@ if(T.air) var/datum/gas_mixture/G = T.air if(!distcheck || get_dist(T, location) < blast) // Otherwise we'll get silliness like people using Nanofrost to kill people through walls with cold air - G.temperature = temperature + G.set_temperature(temperature) T.air_update_turf() for(var/obj/effect/hotspot/H in T) qdel(H) - var/list/G_gases = G.gases - if(G_gases[/datum/gas/plasma]) - G_gases[/datum/gas/nitrogen] += (G_gases[/datum/gas/plasma]) - G_gases[/datum/gas/plasma] = 0 - GAS_GARBAGE_COLLECT(G.gases) + if(G.get_moles(/datum/gas/plasma)) + G.adjust_moles(/datum/gas/nitrogen, G.get_moles(/datum/gas/plasma)) + G.set_moles(/datum/gas/plasma, 0) if (weldvents) for(var/obj/machinery/atmospherics/components/unary/U in T) if(!isnull(U.welded) && !U.welded) //must be an unwelded vent pump or vent scrubber. diff --git a/code/game/objects/effects/spawners/bombspawner.dm b/code/game/objects/effects/spawners/bombspawner.dm index a0ae300c79..b5aaff5746 100644 --- a/code/game/objects/effects/spawners/bombspawner.dm +++ b/code/game/objects/effects/spawners/bombspawner.dm @@ -19,11 +19,11 @@ var/obj/item/tank/internals/plasma/PT = new(V) var/obj/item/tank/internals/oxygen/OT = new(V) - PT.air_contents.gases[/datum/gas/plasma] = pressure_p*PT.volume/(R_IDEAL_GAS_EQUATION*CELSIUS_TO_KELVIN(temp_p)) - PT.air_contents.temperature = CELSIUS_TO_KELVIN(temp_p) + PT.air_contents.set_moles(/datum/gas/plasma, pressure_p*PT.volume/(R_IDEAL_GAS_EQUATION*CELSIUS_TO_KELVIN(temp_p))) + PT.air_contents.set_temperature(CELSIUS_TO_KELVIN(temp_p)) - OT.air_contents.gases[/datum/gas/oxygen] = pressure_o*OT.volume/(R_IDEAL_GAS_EQUATION*CELSIUS_TO_KELVIN(temp_o)) - OT.air_contents.temperature = CELSIUS_TO_KELVIN(temp_o) + OT.air_contents.set_moles(/datum/gas/oxygen, pressure_o*OT.volume/(R_IDEAL_GAS_EQUATION*CELSIUS_TO_KELVIN(temp_o))) + OT.air_contents.set_temperature(CELSIUS_TO_KELVIN(temp_o)) V.tank_one = PT V.tank_two = OT diff --git a/code/game/objects/items/chrono_eraser.dm b/code/game/objects/items/chrono_eraser.dm index c3b6c0312f..a9f655a2c2 100644 --- a/code/game/objects/items/chrono_eraser.dm +++ b/code/game/objects/items/chrono_eraser.dm @@ -246,9 +246,9 @@ /obj/effect/chrono_field/return_air() //we always have nominal air and temperature var/datum/gas_mixture/GM = new - GM.gases[/datum/gas/oxygen] = MOLES_O2STANDARD - GM.gases[/datum/gas/nitrogen] = MOLES_N2STANDARD - GM.temperature = T20C + GM.set_moles(/datum/gas/oxygen, MOLES_O2STANDARD) + GM.set_moles(/datum/gas/nitrogen, MOLES_N2STANDARD) + GM.set_temperature(T20C) return GM /obj/effect/chrono_field/Move() diff --git a/code/game/objects/items/devices/PDA/PDA.dm b/code/game/objects/items/devices/PDA/PDA.dm index 2dabcca29f..d706f5468a 100644 --- a/code/game/objects/items/devices/PDA/PDA.dm +++ b/code/game/objects/items/devices/PDA/PDA.dm @@ -437,7 +437,6 @@ GLOBAL_LIST_EMPTY(PDAs) dat += "Unable to obtain a reading.
" else var/datum/gas_mixture/environment = T.return_air() - var/list/env_gases = environment.gases var/pressure = environment.return_pressure() var/total_moles = environment.total_moles() @@ -445,12 +444,12 @@ GLOBAL_LIST_EMPTY(PDAs) dat += "Air Pressure: [round(pressure,0.1)] kPa
" if (total_moles) - for(var/id in env_gases) - var/gas_level = env_gases[id]/total_moles + for(var/id in environment.get_gases()) + var/gas_level = environment.get_moles(id)/total_moles if(gas_level > 0) dat += "[GLOB.meta_gas_names[id]]: [round(gas_level*100, 0.01)]%
" - dat += "Temperature: [round(environment.temperature-T0C)]°C
" + dat += "Temperature: [round(environment.return_temperature()-T0C)]°C
" dat += "
" else//Else it links to the cart menu proc. Although, it really uses menu hub 4--menu 4 doesn't really exist as it simply redirects to hub. dat += cartridge.generate_menu() diff --git a/code/game/objects/items/devices/scanners.dm b/code/game/objects/items/devices/scanners.dm index b6cab8b438..d8f1790dec 100644 --- a/code/game/objects/items/devices/scanners.dm +++ b/code/game/objects/items/devices/scanners.dm @@ -553,41 +553,38 @@ SLIME SCANNER else to_chat(user, "Pressure: [round(pressure, 0.01)] kPa") if(total_moles) - var/list/env_gases = environment.gases - var/o2_concentration = env_gases[/datum/gas/oxygen]/total_moles - var/n2_concentration = env_gases[/datum/gas/nitrogen]/total_moles - var/co2_concentration = env_gases[/datum/gas/carbon_dioxide]/total_moles - var/plasma_concentration = env_gases[/datum/gas/plasma]/total_moles + var/o2_concentration = environment.get_moles(/datum/gas/oxygen)/total_moles + var/n2_concentration = environment.get_moles(/datum/gas/nitrogen)/total_moles + var/co2_concentration = environment.get_moles(/datum/gas/carbon_dioxide)/total_moles + var/plasma_concentration = environment.get_moles(/datum/gas/plasma)/total_moles if(abs(n2_concentration - N2STANDARD) < 20) - to_chat(user, "Nitrogen: [round(n2_concentration*100, 0.01)] % ([round(env_gases[/datum/gas/nitrogen], 0.01)] mol)") + to_chat(user, "Nitrogen: [round(n2_concentration*100, 0.01)] % ([round(environment.get_moles(/datum/gas/nitrogen), 0.01)] mol)") else - to_chat(user, "Nitrogen: [round(n2_concentration*100, 0.01)] % ([round(env_gases[/datum/gas/nitrogen], 0.01)] mol)") + to_chat(user, "Nitrogen: [round(n2_concentration*100, 0.01)] % ([round(environment.get_moles(/datum/gas/nitrogen), 0.01)] mol)") if(abs(o2_concentration - O2STANDARD) < 2) - to_chat(user, "Oxygen: [round(o2_concentration*100, 0.01)] % ([round(env_gases[/datum/gas/oxygen], 0.01)] mol)") + to_chat(user, "Oxygen: [round(o2_concentration*100, 0.01)] % ([round(environment.get_moles(/datum/gas/oxygen), 0.01)] mol)") else - to_chat(user, "Oxygen: [round(o2_concentration*100, 0.01)] % ([round(env_gases[/datum/gas/oxygen], 0.01)] mol)") + to_chat(user, "Oxygen: [round(o2_concentration*100, 0.01)] % ([round(environment.get_moles(/datum/gas/oxygen), 0.01)] mol)") if(co2_concentration > 0.01) - to_chat(user, "CO2: [round(co2_concentration*100, 0.01)] % ([round(env_gases[/datum/gas/carbon_dioxide], 0.01)] mol)") + to_chat(user, "CO2: [round(co2_concentration*100, 0.01)] % ([round(environment.get_moles(/datum/gas/carbon_dioxide), 0.01)] mol)") else - to_chat(user, "CO2: [round(co2_concentration*100, 0.01)] % ([round(env_gases[/datum/gas/carbon_dioxide], 0.01)] mol)") + to_chat(user, "CO2: [round(co2_concentration*100, 0.01)] % ([round(environment.get_moles(/datum/gas/carbon_dioxide), 0.01)] mol)") if(plasma_concentration > 0.005) - to_chat(user, "Plasma: [round(plasma_concentration*100, 0.01)] % ([round(env_gases[/datum/gas/plasma], 0.01)] mol)") + to_chat(user, "Plasma: [round(plasma_concentration*100, 0.01)] % ([round(environment.get_moles(/datum/gas/plasma), 0.01)] mol)") else - to_chat(user, "Plasma: [round(plasma_concentration*100, 0.01)] % ([round(env_gases[/datum/gas/plasma], 0.01)] mol)") + to_chat(user, "Plasma: [round(plasma_concentration*100, 0.01)] % ([round(environment.get_moles(/datum/gas/plasma), 0.01)] mol)") - GAS_GARBAGE_COLLECT(environment.gases) - - for(var/id in env_gases) + for(var/id in environment.get_gases()) if(id in GLOB.hardcoded_gases) continue - var/gas_concentration = env_gases[id]/total_moles - to_chat(user, "[GLOB.meta_gas_names[id]]: [round(gas_concentration*100, 0.01)] % ([round(env_gases[id], 0.01)] mol)") - to_chat(user, "Temperature: [round(environment.temperature-T0C, 0.01)] °C ([round(environment.temperature, 0.01)] K)") + var/gas_concentration = environment.get_moles(id)/total_moles + to_chat(user, "[GLOB.meta_gas_names[id]]: [round(gas_concentration*100, 0.01)] % ([round(environment.get_moles(id), 0.01)] mol)") + to_chat(user, "Temperature: [round(environment.return_temperature()-T0C, 0.01)] °C ([round(environment.return_temperature(), 0.01)] K)") /obj/item/analyzer/AltClick(mob/user) //Barometer output for measuring when the next storm happens . = ..() @@ -665,8 +662,8 @@ SLIME SCANNER var/total_moles = air_contents.total_moles() var/pressure = air_contents.return_pressure() - var/volume = air_contents.return_volume() //could just do mixture.volume... but safety, I guess? - var/temperature = air_contents.temperature + var/volume = air_contents.return_volume() + var/temperature = air_contents.return_temperature() var/cached_scan_results = air_contents.analyzer_results if(total_moles > 0) @@ -674,10 +671,9 @@ SLIME SCANNER to_chat(user, "Volume: [volume] L") to_chat(user, "Pressure: [round(pressure,0.01)] kPa") - var/list/cached_gases = air_contents.gases - for(var/id in cached_gases) - var/gas_concentration = cached_gases[id]/total_moles - to_chat(user, "[GLOB.meta_gas_names[id]]: [round(gas_concentration*100, 0.01)] % ([round(cached_gases[id], 0.01)] mol)") + for(var/id in air_contents.get_gases()) + var/gas_concentration = air_contents.get_moles(id)/total_moles + to_chat(user, "[GLOB.meta_gas_names[id]]: [round(gas_concentration*100, 0.01)] % ([round(air_contents.get_moles(id), 0.01)] mol)") to_chat(user, "Temperature: [round(temperature - T0C,0.01)] °C ([round(temperature, 0.01)] K)") else diff --git a/code/game/objects/items/devices/transfer_valve.dm b/code/game/objects/items/devices/transfer_valve.dm index b929642f33..9d5b6d5b6c 100644 --- a/code/game/objects/items/devices/transfer_valve.dm +++ b/code/game/objects/items/devices/transfer_valve.dm @@ -168,8 +168,8 @@ target_self = TRUE if(change_volume) if(!target_self) - target.volume += tank_two.volume - target.volume += tank_one.air_contents.volume + target.set_volume(target.return_volume() + tank_two.volume) + target.set_volume(target.return_volume() + tank_one.air_contents.return_volume()) var/datum/gas_mixture/temp temp = tank_one.air_contents.remove_ratio(1) target.merge(temp) @@ -180,11 +180,11 @@ /obj/item/transfer_valve/proc/split_gases() if (!valve_open || !tank_one || !tank_two) return - var/ratio1 = tank_one.air_contents.volume/tank_two.air_contents.volume + var/ratio1 = tank_one.air_contents.return_volume()/tank_two.air_contents.return_volume() var/datum/gas_mixture/temp temp = tank_two.air_contents.remove_ratio(ratio1) tank_one.air_contents.merge(temp) - tank_two.air_contents.volume -= tank_one.air_contents.volume + tank_two.air_contents.set_volume(tank_two.air_contents.return_volume() - tank_one.air_contents.return_volume()) /* Exadv1: I know this isn't how it's going to work, but this was just to check diff --git a/code/game/objects/items/flamethrower.dm b/code/game/objects/items/flamethrower.dm index e2140bd0fd..156b26e659 100644 --- a/code/game/objects/items/flamethrower.dm +++ b/code/game/objects/items/flamethrower.dm @@ -205,11 +205,10 @@ //TODO: DEFERRED Consider checking to make sure tank pressure is high enough before doing this... //Transfer 5% of current tank air contents to turf var/datum/gas_mixture/air_transfer = ptank.air_contents.remove_ratio(release_amount) - if(air_transfer.gases[/datum/gas/plasma]) - air_transfer.gases[/datum/gas/plasma] *= 5 + air_transfer.set_moles(/datum/gas/plasma, air_transfer.get_moles(/datum/gas/plasma) * 5) target.assume_air(air_transfer) //Burn it based on transfered gas - target.hotspot_expose((ptank.air_contents.temperature*2) + 380,500) + target.hotspot_expose((ptank.air_contents.return_temperature()*2) + 380,500) //location.hotspot_expose(1000,500,1) SSair.add_to_active(target, 0) diff --git a/code/game/objects/items/tanks/jetpack.dm b/code/game/objects/items/tanks/jetpack.dm index e81294ceea..ecd9708ea5 100644 --- a/code/game/objects/items/tanks/jetpack.dm +++ b/code/game/objects/items/tanks/jetpack.dm @@ -17,7 +17,7 @@ /obj/item/tank/jetpack/New() ..() if(gas_type) - air_contents.gases[gas_type] = ((6 * ONE_ATMOSPHERE) * volume / (R_IDEAL_GAS_EQUATION * T20C)) + air_contents.set_moles(gas_type, ((6 * ONE_ATMOSPHERE) * volume / (R_IDEAL_GAS_EQUATION * T20C))) ion_trail = new ion_trail.set_up(src) diff --git a/code/game/objects/items/tanks/tank_types.dm b/code/game/objects/items/tanks/tank_types.dm index 0e6dfaa1b3..6d4a7dc253 100644 --- a/code/game/objects/items/tanks/tank_types.dm +++ b/code/game/objects/items/tanks/tank_types.dm @@ -21,7 +21,7 @@ /obj/item/tank/internals/oxygen/New() ..() - air_contents.gases[/datum/gas/oxygen] = (6*ONE_ATMOSPHERE)*volume/(R_IDEAL_GAS_EQUATION*T20C) + air_contents.set_moles(/datum/gas/oxygen, (6*ONE_ATMOSPHERE)*volume/(R_IDEAL_GAS_EQUATION*T20C)) return @@ -48,8 +48,8 @@ /obj/item/tank/internals/anesthetic/New() ..() - air_contents.gases[/datum/gas/oxygen] = (3*ONE_ATMOSPHERE)*volume/(R_IDEAL_GAS_EQUATION*T20C) * O2STANDARD - air_contents.gases[/datum/gas/nitrous_oxide] = (3*ONE_ATMOSPHERE)*volume/(R_IDEAL_GAS_EQUATION*T20C) * N2STANDARD + air_contents.set_moles(/datum/gas/oxygen, (3*ONE_ATMOSPHERE)*volume/(R_IDEAL_GAS_EQUATION*T20C) * O2STANDARD) + air_contents.set_moles(/datum/gas/nitrous_oxide, (3*ONE_ATMOSPHERE)*volume/(R_IDEAL_GAS_EQUATION*T20C) * N2STANDARD) return /* @@ -65,8 +65,8 @@ /obj/item/tank/internals/air/New() ..() - air_contents.gases[/datum/gas/oxygen] = (6*ONE_ATMOSPHERE)*volume/(R_IDEAL_GAS_EQUATION*T20C) * O2STANDARD - air_contents.gases[/datum/gas/nitrogen] = (6*ONE_ATMOSPHERE)*volume/(R_IDEAL_GAS_EQUATION*T20C) * N2STANDARD + air_contents.set_moles(/datum/gas/oxygen, (6*ONE_ATMOSPHERE)*volume/(R_IDEAL_GAS_EQUATION*T20C) * O2STANDARD) + air_contents.set_moles(/datum/gas/nitrogen, (6*ONE_ATMOSPHERE)*volume/(R_IDEAL_GAS_EQUATION*T20C) * N2STANDARD) return @@ -84,7 +84,7 @@ /obj/item/tank/internals/plasma/New() ..() - air_contents.gases[/datum/gas/plasma] = (3*ONE_ATMOSPHERE)*volume/(R_IDEAL_GAS_EQUATION*T20C) + air_contents.set_moles(/datum/gas/plasma, (3*ONE_ATMOSPHERE)*volume/(R_IDEAL_GAS_EQUATION*T20C)) return /obj/item/tank/internals/plasma/attackby(obj/item/W, mob/user, params) @@ -101,8 +101,8 @@ return ..() /obj/item/tank/internals/plasma/full/New() - ..() // Plasma asserted in parent - air_contents.gases[/datum/gas/plasma] = (10*ONE_ATMOSPHERE)*volume/(R_IDEAL_GAS_EQUATION*T20C) + ..() + air_contents.set_moles(/datum/gas/plasma, (10*ONE_ATMOSPHERE)*volume/(R_IDEAL_GAS_EQUATION*T20C)) return @@ -120,12 +120,12 @@ /obj/item/tank/internals/plasmaman/New() ..() - air_contents.gases[/datum/gas/plasma] = (3*ONE_ATMOSPHERE)*volume/(R_IDEAL_GAS_EQUATION*T20C) + air_contents.set_moles(/datum/gas/plasma, (3*ONE_ATMOSPHERE)*volume/(R_IDEAL_GAS_EQUATION*T20C)) return /obj/item/tank/internals/plasmaman/full/New() ..() // Plasma asserted in parent - air_contents.gases[/datum/gas/plasma] = (10*ONE_ATMOSPHERE)*volume/(R_IDEAL_GAS_EQUATION*T20C) + air_contents.set_moles(/datum/gas/plasma, (10*ONE_ATMOSPHERE)*volume/(R_IDEAL_GAS_EQUATION*T20C)) return @@ -139,7 +139,7 @@ /obj/item/tank/internals/plasmaman/belt/full/New() ..() // Plasma asserted in parent - air_contents.gases[/datum/gas/plasma] = (10*ONE_ATMOSPHERE)*volume/(R_IDEAL_GAS_EQUATION*T20C) + air_contents.set_moles(/datum/gas/plasma, (10*ONE_ATMOSPHERE)*volume/(R_IDEAL_GAS_EQUATION*T20C)) return @@ -161,7 +161,7 @@ /obj/item/tank/internals/emergency_oxygen/New() ..() - air_contents.gases[/datum/gas/oxygen] = (3*ONE_ATMOSPHERE)*volume/(R_IDEAL_GAS_EQUATION*T20C) + air_contents.set_moles(/datum/gas/oxygen, (3*ONE_ATMOSPHERE)*volume/(R_IDEAL_GAS_EQUATION*T20C)) return /obj/item/tank/internals/emergency_oxygen/engi diff --git a/code/game/objects/items/tanks/tanks.dm b/code/game/objects/items/tanks/tanks.dm index 1c92ed4e61..ac3404ec5c 100644 --- a/code/game/objects/items/tanks/tanks.dm +++ b/code/game/objects/items/tanks/tanks.dm @@ -64,7 +64,7 @@ ..() air_contents = new(volume) //liters - air_contents.temperature = T20C + air_contents.set_temperature(T20C) START_PROCESSING(SSobj, src) @@ -87,7 +87,7 @@ . += "The pressure gauge reads [round(src.air_contents.return_pressure(),0.01)] kPa." - var/celsius_temperature = src.air_contents.temperature-T0C + var/celsius_temperature = src.air_contents.return_temperature()-T0C var/descriptive if (celsius_temperature < 20) @@ -226,7 +226,7 @@ if(tank_pressure < distribute_pressure) distribute_pressure = tank_pressure - var/moles_needed = distribute_pressure*volume_to_return/(R_IDEAL_GAS_EQUATION*air_contents.temperature) + var/moles_needed = distribute_pressure*volume_to_return/(R_IDEAL_GAS_EQUATION*air_contents.return_temperature()) return remove_air(moles_needed) diff --git a/code/game/objects/structures/transit_tubes/station.dm b/code/game/objects/structures/transit_tubes/station.dm index 17ca178cd9..ba23878168 100644 --- a/code/game/objects/structures/transit_tubes/station.dm +++ b/code/game/objects/structures/transit_tubes/station.dm @@ -152,8 +152,8 @@ pod_moving = 0 if(!QDELETED(pod)) var/datum/gas_mixture/floor_mixture = loc.return_air() - ARCHIVE_TEMPERATURE(floor_mixture) - ARCHIVE_TEMPERATURE(pod.air_contents) + floor_mixture.archive() + pod.air_contents.archive() pod.air_contents.share(floor_mixture, 1) //mix the pod's gas mixture with the tile it's on air_update_turf() diff --git a/code/game/objects/structures/transit_tubes/transit_tube_pod.dm b/code/game/objects/structures/transit_tubes/transit_tube_pod.dm index 04f113a0c8..36539ae1e4 100644 --- a/code/game/objects/structures/transit_tubes/transit_tube_pod.dm +++ b/code/game/objects/structures/transit_tubes/transit_tube_pod.dm @@ -10,9 +10,9 @@ /obj/structure/transit_tube_pod/Initialize() . = ..() - air_contents.gases[/datum/gas/oxygen] = MOLES_O2STANDARD - air_contents.gases[/datum/gas/nitrogen] = MOLES_N2STANDARD - air_contents.temperature = T20C + air_contents.set_moles(/datum/gas/oxygen, MOLES_O2STANDARD) + air_contents.set_moles(/datum/gas/nitrogen, MOLES_N2STANDARD) + air_contents.set_temperature(T20C) /obj/structure/transit_tube_pod/Destroy() @@ -181,4 +181,4 @@ return /obj/structure/transit_tube_pod/return_temperature() - return air_contents.temperature + return air_contents.return_temperature() diff --git a/code/game/turfs/change_turf.dm b/code/game/turfs/change_turf.dm index 3a719d05b9..80e542dad8 100644 --- a/code/game/turfs/change_turf.dm +++ b/code/game/turfs/change_turf.dm @@ -302,24 +302,14 @@ GLOBAL_LIST_INIT(blacklisted_automated_baseturfs, typecacheof(list( return var/datum/gas_mixture/total = new//Holders to assimilate air from nearby turfs - var/list/total_gases = total.gases for(var/T in atmos_adjacent_turfs) var/turf/open/S = T if(!S.air) continue - var/list/S_gases = S.air.gases - for(var/id in S_gases) - total_gases[id] += S_gases[id] - total.temperature += S.air.temperature + total.merge(S.air) - air.copy_from(total) - - var/list/air_gases = air.gases - for(var/id in air_gases) - air_gases[id] /= turf_count //Averages contents of the turfs, ignoring walls and the like - - air.temperature /= turf_count + air.copy_from(total.remove_ratio(1/turf_count)) SSair.add_to_active(src) /turf/proc/ReplaceWithLattice() diff --git a/code/game/turfs/open.dm b/code/game/turfs/open.dm index b81c5be44c..6a17b02d66 100644 --- a/code/game/turfs/open.dm +++ b/code/game/turfs/open.dm @@ -216,10 +216,10 @@ . = air.heat_capacity() /turf/open/proc/GetTemperature() - . = air.temperature + . = air.return_temperature() /turf/open/proc/TakeTemperature(temp) - air.temperature += temp + air.set_temperature(air.return_temperature() + temp) air_update_turf() /turf/open/proc/freon_gas_act() @@ -304,9 +304,8 @@ /turf/open/rad_act(pulse_strength) . = ..() - if (air.gases[/datum/gas/carbon_dioxide] && air.gases[/datum/gas/oxygen]) - pulse_strength = min(pulse_strength,air.gases[/datum/gas/carbon_dioxide]*1000,air.gases[/datum/gas/oxygen]*2000) //Ensures matter is conserved properly - air.gases[/datum/gas/carbon_dioxide]=max(air.gases[/datum/gas/carbon_dioxide]-(pulse_strength/1000),0) - air.gases[/datum/gas/oxygen]=max(air.gases[/datum/gas/oxygen]-(pulse_strength/2000),0) - air.gases[/datum/gas/pluoxium]+=(pulse_strength/4000) - GAS_GARBAGE_COLLECT(air.gases) + if (air.get_moles(/datum/gas/carbon_dioxide) && air.get_moles(/datum/gas/oxygen)) + pulse_strength = min(pulse_strength,air.get_moles(/datum/gas/carbon_dioxide)*1000,air.get_moles(/datum/gas/oxygen)*2000) //Ensures matter is conserved properly + air.set_moles(/datum/gas/carbon_dioxide, max(air.get_moles(/datum/gas/carbon_dioxide)-(pulse_strength/1000),0)) + air.set_moles(/datum/gas/oxygen, max(air.get_moles(/datum/gas/oxygen)-(pulse_strength/2000),0)) + air.adjust_moles(/datum/gas/pluoxium, pulse_strength/4000) diff --git a/code/game/turfs/turf.dm b/code/game/turfs/turf.dm index 88f6dd6962..72d9f88d8e 100755 --- a/code/game/turfs/turf.dm +++ b/code/game/turfs/turf.dm @@ -274,7 +274,7 @@ /turf/open/Entered(atom/movable/AM) ..() //melting - if(isobj(AM) && air && air.temperature > T0C) + if(isobj(AM) && air && air.return_temperature() > T0C) var/obj/O = AM if(O.obj_flags & FROZEN) O.make_unfrozen() diff --git a/code/modules/admin/verbs/debug.dm b/code/modules/admin/verbs/debug.dm index 8406248164..f068f05a4a 100644 --- a/code/modules/admin/verbs/debug.dm +++ b/code/modules/admin/verbs/debug.dm @@ -573,7 +573,7 @@ if(Rad.anchored) if(!Rad.loaded_tank) var/obj/item/tank/internals/plasma/Plasma = new/obj/item/tank/internals/plasma(Rad) - Plasma.air_contents.gases[/datum/gas/plasma] = 70 + Plasma.air_contents.set_moles(/datum/gas/plasma,70) Rad.drainratio = 0 Rad.loaded_tank = Plasma Plasma.forceMove(Rad) diff --git a/code/modules/admin/verbs/diagnostics.dm b/code/modules/admin/verbs/diagnostics.dm index 072fbaa123..b3bea2201c 100644 --- a/code/modules/admin/verbs/diagnostics.dm +++ b/code/modules/admin/verbs/diagnostics.dm @@ -1,15 +1,14 @@ /proc/show_air_status_to(turf/target, mob/user) var/datum/gas_mixture/env = target.return_air() - var/list/env_gases = env.gases var/burning = FALSE if(isopenturf(target)) var/turf/open/T = target if(T.active_hotspot) burning = TRUE - var/list/lines = list("[AREACOORD(target)]: [env.temperature] K ([env.temperature - T0C] C), [env.return_pressure()] kPa[(burning)?(", burning"):(null)]") - for(var/id in env_gases) - var/moles = env_gases[id] + var/list/lines = list("[AREACOORD(target)]: [env.return_temperature()] K ([env.return_temperature() - T0C] C), [env.return_pressure()] kPa[(burning)?(", burning"):(null)]") + for(var/id in env.get_gases()) + var/moles = env.get_moles(id) if (moles >= 0.00001) lines += "[GLOB.meta_gas_names[id]]: [moles] mol" to_chat(usr, lines.Join("\n")) diff --git a/code/modules/assembly/bomb.dm b/code/modules/assembly/bomb.dm index a40a4c1a42..36c444f02d 100644 --- a/code/modules/assembly/bomb.dm +++ b/code/modules/assembly/bomb.dm @@ -53,8 +53,8 @@ return if(I.use_tool(src, user, 0, volume=40)) status = TRUE - GLOB.bombers += "[key_name(user)] welded a single tank bomb. Temp: [bombtank.air_contents.temperature-T0C]" - message_admins("[ADMIN_LOOKUPFLW(user)] welded a single tank bomb. Temp: [bombtank.air_contents.temperature-T0C]") + GLOB.bombers += "[key_name(user)] welded a single tank bomb. Temp: [bombtank.air_contents.return_temperature()-T0C]" + message_admins("[ADMIN_LOOKUPFLW(user)] welded a single tank bomb. Temp: [bombtank.air_contents.return_temperature()-T0C]") to_chat(user, "A pressure hole has been bored to [bombtank] valve. \The [bombtank] can now be ignited.") add_fingerprint(user) return TRUE @@ -145,8 +145,7 @@ return /obj/item/tank/proc/ignite() //This happens when a bomb is told to explode - var/fuel_moles = air_contents.gases[/datum/gas/plasma] + air_contents.gases[/datum/gas/oxygen]/6 - GAS_GARBAGE_COLLECT(air_contents.gases) + var/fuel_moles = air_contents.get_moles(/datum/gas/plasma) + air_contents.get_moles(/datum/gas/oxygen)/6 var/datum/gas_mixture/bomb_mixture = air_contents.copy() var/strength = 1 @@ -156,7 +155,7 @@ qdel(master) qdel(src) - if(bomb_mixture.temperature > (T0C + 400)) + if(bomb_mixture.return_temperature() > (T0C + 400)) strength = (fuel_moles/15) if(strength >=1) @@ -169,7 +168,7 @@ ground_zero.assume_air(bomb_mixture) ground_zero.hotspot_expose(1000, 125) - else if(bomb_mixture.temperature > (T0C + 250)) + else if(bomb_mixture.return_temperature() > (T0C + 250)) strength = (fuel_moles/20) if(strength >=1) @@ -180,7 +179,7 @@ ground_zero.assume_air(bomb_mixture) ground_zero.hotspot_expose(1000, 125) - else if(bomb_mixture.temperature > (T0C + 100)) + else if(bomb_mixture.return_temperature() > (T0C + 100)) strength = (fuel_moles/25) if (strength >=1) diff --git a/code/modules/atmospherics/environmental/LINDA_fire.dm b/code/modules/atmospherics/environmental/LINDA_fire.dm index 06d73867f8..40b91ed74c 100644 --- a/code/modules/atmospherics/environmental/LINDA_fire.dm +++ b/code/modules/atmospherics/environmental/LINDA_fire.dm @@ -14,9 +14,9 @@ if(!air_contents) return 0 - var/oxy = air_contents.gases[/datum/gas/oxygen] - var/tox = air_contents.gases[/datum/gas/plasma] - var/trit = air_contents.gases[/datum/gas/tritium] + var/oxy = air_contents.get_moles(/datum/gas/oxygen) + var/tox = air_contents.get_moles(/datum/gas/plasma) + var/trit = air_contents.get_moles(/datum/gas/tritium) if(active_hotspot) if(soh) if((tox > 0.5 || trit > 0.5) && oxy > 0.5) @@ -43,8 +43,8 @@ //remove just_spawned protection if no longer processing this cell SSair.add_to_active(src, 0) else - var/datum/gas_mixture/heating = air_contents.remove_ratio(exposed_volume/air_contents.volume) - heating.temperature = exposed_temperature + var/datum/gas_mixture/heating = air_contents.remove_ratio(exposed_volume/air_contents.return_volume()) + heating.set_temperature(exposed_temperature) heating.react() assume_air(heating) air_update_turf() @@ -91,12 +91,12 @@ if(bypassing) if(!just_spawned) volume = location.air.reaction_results["fire"]*FIRE_GROWTH_RATE - temperature = location.air.temperature + temperature = location.air.return_temperature() else - var/datum/gas_mixture/affected = location.air.remove_ratio(volume/location.air.volume) - affected.temperature = temperature + var/datum/gas_mixture/affected = location.air.remove_ratio(volume/location.air.return_volume()) + affected.set_temperature(temperature) affected.react(src) - temperature = affected.temperature + temperature = affected.return_temperature() volume = affected.reaction_results["fire"]*FIRE_GROWTH_RATE location.assume_air(affected) @@ -164,7 +164,7 @@ color = list(LERP(0.3, 1, 1-greyscale_fire) * heat_r,0.3 * heat_g * greyscale_fire,0.3 * heat_b * greyscale_fire, 0.59 * heat_r * greyscale_fire,LERP(0.59, 1, 1-greyscale_fire) * heat_g,0.59 * heat_b * greyscale_fire, 0.11 * heat_r * greyscale_fire,0.11 * heat_g * greyscale_fire,LERP(0.11, 1, 1-greyscale_fire) * heat_b, 0,0,0) alpha = heat_a -#define INSUFFICIENT(path) (location.air.gases[path] < 0.5) +#define INSUFFICIENT(path) (location.air.get_moles(path) < 0.5) /obj/effect/hotspot/process() if(just_spawned) just_spawned = FALSE @@ -185,11 +185,6 @@ qdel(src) return - //Not enough to burn - if((location.air.gases[/datum/gas/plasma] < 0.5 && location.air.gases[/datum/gas/tritium] < 0.5) || location.air.gases[/datum/gas/oxygen] < 0.5) - qdel(src) - return - perform_exposure() if(bypassing) @@ -198,8 +193,8 @@ location.burn_tile() //Possible spread due to radiated heat - if(location.air.temperature > FIRE_MINIMUM_TEMPERATURE_TO_SPREAD) - var/radiated_temperature = location.air.temperature*FIRE_SPREAD_RADIOSITY_SCALE + if(location.air.return_temperature() > FIRE_MINIMUM_TEMPERATURE_TO_SPREAD) + var/radiated_temperature = location.air.return_temperature()*FIRE_SPREAD_RADIOSITY_SCALE for(var/t in location.atmos_adjacent_turfs) var/turf/open/T = t if(!T.active_hotspot) diff --git a/code/modules/atmospherics/environmental/LINDA_turf_tile.dm b/code/modules/atmospherics/environmental/LINDA_turf_tile.dm index 632542f605..5a2c46a6dc 100644 --- a/code/modules/atmospherics/environmental/LINDA_turf_tile.dm +++ b/code/modules/atmospherics/environmental/LINDA_turf_tile.dm @@ -89,7 +89,7 @@ temperature_archived = temperature /turf/open/archive() - ARCHIVE_TEMPERATURE(air) + air.archive() archived_cycle = SSair.times_fired temperature_archived = temperature @@ -117,11 +117,10 @@ if(!air) return . = new /list - var/list/gases = air.gases - for(var/id in gases) + for(var/id in air.get_gases()) if (nonoverlaying_gases[id]) continue - var/gas = gases[id] + var/gas = air.get_moles(id) var/gas_overlay = GLOB.meta_gas_overlays[id] if(gas_overlay && gas > GLOB.meta_gas_visibility[id]) . += gas_overlay[min(FACTOR_GAS_VISIBLE_MAX, CEILING(gas / MOLES_GAS_VISIBLE_STEP, 1))] @@ -136,7 +135,7 @@ /////////////////////////////SIMULATION/////////////////////////////////// #define LAST_SHARE_CHECK \ - var/last_share = our_air.last_share;\ + var/last_share = our_air.get_last_share();\ if(last_share > MINIMUM_AIR_TO_SUSPEND){\ our_excited_group.reset_cooldowns();\ cached_atmos_cooldown = 0;\ @@ -215,7 +214,7 @@ if (planet_atmos) //share our air with the "atmosphere" "above" the turf var/datum/gas_mixture/G = new G.copy_from_turf(src) - ARCHIVE_TEMPERATURE(G) + G.archive() if(our_air.compare(G)) if(!our_excited_group) var/datum/excited_group/EG = new @@ -226,17 +225,12 @@ SSair.add_to_react_queue(src) - if((!our_excited_group && !(our_air.temperature > MINIMUM_TEMPERATURE_START_SUPERCONDUCTION && consider_superconductivity(starting = TRUE))) \ + if((!our_excited_group && !(our_air.return_temperature() > MINIMUM_TEMPERATURE_START_SUPERCONDUCTION && consider_superconductivity(starting = TRUE))) \ || (cached_atmos_cooldown > (EXCITED_GROUP_DISMANTLE_CYCLES * 2))) SSair.remove_from_active(src) atmos_cooldown = cached_atmos_cooldown -/turf/open/space/process_cell(fire_count) //dumb hack to prevent space pollution - . = ..() - var/datum/gas_mixture/immutable/I = space_gas - I.after_process_cell() - /turf/proc/process_cell_reaction() SSair.remove_from_react_queue(src) @@ -317,7 +311,6 @@ var/datum/gas_mixture/A = new //make local for sanic speed - var/list/A_gases = A.gases var/list/turf_list = src.turf_list var/turflen = turf_list.len var/space_in_group = FALSE @@ -328,12 +321,10 @@ space_in_group = TRUE qdel(A) A = new /datum/gas_mixture/immutable/space() - A_gases = A.gases //update the cache break A.merge(T.air) - for(var/id in A_gases) - A_gases[id] /= turflen + A.multiply(1/turflen) for(var/t in turf_list) var/turf/open/T = t @@ -430,7 +421,7 @@ //Conduct with air on my tile if I have it if(!blocks_air) temperature = air.temperature_share(null, thermal_conductivity, temperature, heat_capacity) - ..((blocks_air ? temperature : air.temperature)) + ..((blocks_air ? temperature : air.return_temperature())) /turf/proc/consider_superconductivity() if(!thermal_conductivity) @@ -440,7 +431,7 @@ return TRUE /turf/open/consider_superconductivity(starting) - if(air.temperature < (starting?MINIMUM_TEMPERATURE_START_SUPERCONDUCTION:MINIMUM_TEMPERATURE_FOR_SUPERCONDUCTION)) + if(air.return_temperature() < (starting?MINIMUM_TEMPERATURE_START_SUPERCONDUCTION:MINIMUM_TEMPERATURE_FOR_SUPERCONDUCTION)) return FALSE if(air.heat_capacity() < M_CELL_WITH_RATIO) // Was: MOLES_CELLSTANDARD*0.1*0.05 Since there are no variables here we can make this a constant. return FALSE diff --git a/code/modules/atmospherics/gasmixtures/gas_mixture.dm b/code/modules/atmospherics/gasmixtures/gas_mixture.dm index 5ff8586c34..7993599a13 100644 --- a/code/modules/atmospherics/gasmixtures/gas_mixture.dm +++ b/code/modules/atmospherics/gasmixtures/gas_mixture.dm @@ -16,65 +16,80 @@ GLOBAL_LIST_INIT(meta_gas_dangers, meta_gas_danger_list()) GLOBAL_LIST_INIT(meta_gas_ids, meta_gas_id_list()) GLOBAL_LIST_INIT(meta_gas_fusions, meta_gas_fusion_list()) /datum/gas_mixture - var/list/gases = list() - var/temperature = 0 //kelvins - var/tmp/temperature_archived = 0 - var/volume = CELL_VOLUME //liters - var/last_share = 0 - var/list/reaction_results = list() + var/initial_volume = CELL_VOLUME //liters + var/list/reaction_results var/list/analyzer_results //used for analyzer feedback - not initialized until its used - var/gc_share = FALSE // Whether to call garbage_collect() on the sharer during shares, used for immutable mixtures + var/_extools_pointer_gasmixture = 0 // Contains the memory address of the shared_ptr object for this gas mixture in c++ land. Don't. Touch. This. Var. /datum/gas_mixture/New(volume) if (!isnull(volume)) - src.volume = volume + initial_volume = volume + ATMOS_EXTOOLS_CHECK + __gasmixture_register() + reaction_results = new - //PV = nRT +/datum/gas_mixture/vv_edit_var(var_name, var_value) + if(var_name == "_extools_pointer_gasmixture") + return FALSE // please no. segfaults bad. + return ..() +/* +/datum/gas_mixture/Del() + __gasmixture_unregister() + . = ..()*/ + +/datum/gas_mixture/proc/__gasmixture_unregister() +/datum/gas_mixture/proc/__gasmixture_register() + +/proc/gas_types() + var/list/L = subtypesof(/datum/gas) + for(var/gt in L) + var/datum/gas/G = gt + L[gt] = initial(G.specific_heat) + return L /datum/gas_mixture/proc/heat_capacity() //joules per kelvin - var/list/cached_gases = gases - var/list/cached_gasheats = GLOB.meta_gas_specific_heats - . = 0 - for(var/id in cached_gases) - . += cached_gases[id] * cached_gasheats[id] - -/datum/gas_mixture/turf/heat_capacity() // Same as above except vacuums return HEAT_CAPACITY_VACUUM - var/list/cached_gases = gases - var/list/cached_gasheats = GLOB.meta_gas_specific_heats - for(var/id in cached_gases) - . += cached_gases[id] * cached_gasheats[id] - if(!.) - . += HEAT_CAPACITY_VACUUM //we want vacuums in turfs to have the same heat capacity as space /datum/gas_mixture/proc/total_moles() - var/cached_gases = gases - TOTAL_MOLES(cached_gases, .) /datum/gas_mixture/proc/return_pressure() //kilopascals - if(volume > 0) // to prevent division by zero - var/cached_gases = gases - TOTAL_MOLES(cached_gases, .) - . *= R_IDEAL_GAS_EQUATION * temperature / volume - return - return 0 /datum/gas_mixture/proc/return_temperature() //kelvins - return temperature + +/datum/gas_mixture/proc/set_min_heat_capacity(n) +/datum/gas_mixture/proc/set_temperature(new_temp) +/datum/gas_mixture/proc/set_volume(new_volume) +/datum/gas_mixture/proc/get_moles(gas_type) +/datum/gas_mixture/proc/set_moles(gas_type, moles) +/datum/gas_mixture/proc/scrub_into(datum/gas_mixture/target, list/gases) +/datum/gas_mixture/proc/mark_immutable() +/datum/gas_mixture/proc/get_gases() +/datum/gas_mixture/proc/multiply(factor) +/datum/gas_mixture/proc/get_last_share() +/datum/gas_mixture/proc/clear() + +/datum/gas_mixture/proc/adjust_moles(gas_type, amt = 0) + set_moles(gas_type, get_moles(gas_type) + amt) /datum/gas_mixture/proc/return_volume() //liters - return max(0, volume) /datum/gas_mixture/proc/thermal_energy() //joules - return THERMAL_ENERGY(src) //see code/__DEFINES/atmospherics.dm; use the define in performance critical areas + +/datum/gas_mixture/proc/archive() + //Update archived versions of variables + //Returns: 1 in all cases /datum/gas_mixture/proc/merge(datum/gas_mixture/giver) - //Merges all air from giver into self. Deletes giver. + //Merges all air from giver into self. giver is untouched. //Returns: 1 if we are mutable, 0 otherwise /datum/gas_mixture/proc/remove(amount) - //Proportionally removes amount of gas from the gas_mixture + //Removes amount of gas from the gas_mixture //Returns: gas_mixture with the gases removed +/datum/gas_mixture/proc/transfer_to(datum/gas_mixture/target, amount) + //Transfers amount of gas to target. Equivalent to target.merge(remove(amount)) but faster. + //Removes amount of gas from the gas_mixture + /datum/gas_mixture/proc/remove_ratio(ratio) //Proportionally removes amount of gas from the gas_mixture //Returns: gas_mixture with the gases removed @@ -112,239 +127,59 @@ GLOBAL_LIST_INIT(meta_gas_fusions, meta_gas_fusion_list()) //Returns: 1 if any reaction took place; 0 otherwise -/datum/gas_mixture/merge(datum/gas_mixture/giver) - if(!giver) - return 0 - - //heat transfer - if(abs(temperature - giver.temperature) > MINIMUM_TEMPERATURE_DELTA_TO_CONSIDER) - var/self_heat_capacity = heat_capacity() - var/giver_heat_capacity = giver.heat_capacity() - var/combined_heat_capacity = giver_heat_capacity + self_heat_capacity - if(combined_heat_capacity) - temperature = (giver.temperature * giver_heat_capacity + temperature * self_heat_capacity) / combined_heat_capacity - - var/list/cached_gases = gases //accessing datum vars is slower than proc vars - var/list/giver_gases = giver.gases - //gas transfer - for(var/giver_id in giver_gases) - cached_gases[giver_id] += giver_gases[giver_id] - - return 1 - +/datum/gas_mixture/proc/__remove() /datum/gas_mixture/remove(amount) - var/sum - var/list/cached_gases = gases - TOTAL_MOLES(cached_gases, sum) - amount = min(amount, sum) //Can not take more air than tile has! - if(amount <= 0) - return null var/datum/gas_mixture/removed = new type - var/list/removed_gases = removed.gases //accessing datum vars is slower than proc vars - - removed.temperature = temperature - for(var/id in cached_gases) - removed_gases[id] = QUANTIZE((cached_gases[id] / sum) * amount) - cached_gases[id] -= removed_gases[id] - GAS_GARBAGE_COLLECT(gases) + __remove(removed, amount) return removed +/datum/gas_mixture/proc/__remove_ratio() /datum/gas_mixture/remove_ratio(ratio) - if(ratio <= 0) - return null - ratio = min(ratio, 1) - - var/list/cached_gases = gases var/datum/gas_mixture/removed = new type - var/list/removed_gases = removed.gases //accessing datum vars is slower than proc vars - - removed.temperature = temperature - for(var/id in cached_gases) - removed_gases[id] = QUANTIZE(cached_gases[id] * ratio) - cached_gases[id] -= removed_gases[id] - - GAS_GARBAGE_COLLECT(gases) + __remove_ratio(removed, ratio) return removed /datum/gas_mixture/copy() - var/list/cached_gases = gases var/datum/gas_mixture/copy = new type - var/list/copy_gases = copy.gases - - copy.temperature = temperature - for(var/id in cached_gases) - copy_gases[id] = cached_gases[id] + copy.copy_from(src) return copy - -/datum/gas_mixture/copy_from(datum/gas_mixture/sample) - var/list/cached_gases = gases //accessing datum vars is slower than proc vars - var/list/sample_gases = sample.gases - - temperature = sample.temperature - for(var/id in sample_gases) - cached_gases[id] = sample_gases[id] - - //remove all gases not in the sample - cached_gases &= sample_gases - - return 1 - /datum/gas_mixture/copy_from_turf(turf/model) parse_gas_string(model.initial_gas_mix) //acounts for changes in temperature var/turf/model_parent = model.parent_type if(model.temperature != initial(model.temperature) || model.temperature != initial(model_parent.temperature)) - temperature = model.temperature + set_temperature(model.temperature) return 1 /datum/gas_mixture/parse_gas_string(gas_string) - var/list/gases = src.gases var/list/gas = params2list(gas_string) if(gas["TEMP"]) - temperature = text2num(gas["TEMP"]) + set_temperature(text2num(gas["TEMP"])) gas -= "TEMP" - gases.Cut() + clear() for(var/id in gas) var/path = id if(!ispath(path)) path = gas_id2path(path) //a lot of these strings can't have embedded expressions (especially for mappers), so support for IDs needs to stick around - gases[path] = text2num(gas[id]) + set_moles(path, text2num(gas[id])) return 1 - -/datum/gas_mixture/share(datum/gas_mixture/sharer, atmos_adjacent_turfs = 4) - - var/list/cached_gases = gases - var/list/sharer_gases = sharer.gases - - var/temperature_delta = temperature_archived - sharer.temperature_archived - var/abs_temperature_delta = abs(temperature_delta) - - var/old_self_heat_capacity = 0 - var/old_sharer_heat_capacity = 0 - if(abs_temperature_delta > MINIMUM_TEMPERATURE_DELTA_TO_CONSIDER) - old_self_heat_capacity = heat_capacity() - old_sharer_heat_capacity = sharer.heat_capacity() - - var/heat_capacity_self_to_sharer = 0 //heat capacity of the moles transferred from us to the sharer - var/heat_capacity_sharer_to_self = 0 //heat capacity of the moles transferred from the sharer to us - - var/moved_moles = 0 - var/abs_moved_moles = 0 - - //we're gonna define these vars outside of this for loop because as it turns out, var declaration is pricy - var/delta - var/gas_heat_capacity - //and also cache this shit rq because that results in sanic speed for reasons byond explanation - var/list/cached_gasheats = GLOB.meta_gas_specific_heats - //GAS TRANSFER - for(var/id in cached_gases | sharer_gases) // transfer gases - - delta = QUANTIZE(cached_gases[id] - sharer_gases[id])/(atmos_adjacent_turfs+1) //the amount of gas that gets moved between the mixtures - - if(delta && abs_temperature_delta > MINIMUM_TEMPERATURE_DELTA_TO_CONSIDER) - gas_heat_capacity = delta * cached_gasheats[id] - if(delta > 0) - heat_capacity_self_to_sharer += gas_heat_capacity - else - heat_capacity_sharer_to_self -= gas_heat_capacity //subtract here instead of adding the absolute value because we know that delta is negative. - - cached_gases[id] -= delta - sharer_gases[id] += delta - moved_moles += delta - abs_moved_moles += abs(delta) - - last_share = abs_moved_moles - - //THERMAL ENERGY TRANSFER - if(abs_temperature_delta > MINIMUM_TEMPERATURE_DELTA_TO_CONSIDER) - var/new_self_heat_capacity = old_self_heat_capacity + heat_capacity_sharer_to_self - heat_capacity_self_to_sharer - var/new_sharer_heat_capacity = old_sharer_heat_capacity + heat_capacity_self_to_sharer - heat_capacity_sharer_to_self - - //transfer of thermal energy (via changed heat capacity) between self and sharer - if(new_self_heat_capacity > MINIMUM_HEAT_CAPACITY) - temperature = (old_self_heat_capacity*temperature - heat_capacity_self_to_sharer*temperature_archived + heat_capacity_sharer_to_self*sharer.temperature_archived)/new_self_heat_capacity - - if(new_sharer_heat_capacity > MINIMUM_HEAT_CAPACITY) - sharer.temperature = (old_sharer_heat_capacity*sharer.temperature-heat_capacity_sharer_to_self*sharer.temperature_archived + heat_capacity_self_to_sharer*temperature_archived)/new_sharer_heat_capacity - //thermal energy of the system (self and sharer) is unchanged - - if(abs(old_sharer_heat_capacity) > MINIMUM_HEAT_CAPACITY) - if(abs(new_sharer_heat_capacity/old_sharer_heat_capacity - 1) < 0.1) // <10% change in sharer heat capacity - temperature_share(sharer, OPEN_HEAT_TRANSFER_COEFFICIENT) - - if (initial(sharer.gc_share)) - GAS_GARBAGE_COLLECT(sharer.gases) - if(temperature_delta > MINIMUM_TEMPERATURE_TO_MOVE || abs(moved_moles) > MINIMUM_MOLES_DELTA_TO_MOVE) - var/our_moles - TOTAL_MOLES(cached_gases,our_moles) - var/their_moles - TOTAL_MOLES(sharer_gases,their_moles) - return (temperature_archived*(our_moles + moved_moles) - sharer.temperature_archived*(their_moles - moved_moles)) * R_IDEAL_GAS_EQUATION / volume - -/datum/gas_mixture/temperature_share(datum/gas_mixture/sharer, conduction_coefficient, sharer_temperature, sharer_heat_capacity) - //transfer of thermal energy (via conduction) between self and sharer - if(sharer) - sharer_temperature = sharer.temperature_archived - var/temperature_delta = temperature_archived - sharer_temperature - if(abs(temperature_delta) > MINIMUM_TEMPERATURE_DELTA_TO_CONSIDER) - var/self_heat_capacity = heat_capacity() - sharer_heat_capacity = sharer_heat_capacity || sharer.heat_capacity() - - if((sharer_heat_capacity > MINIMUM_HEAT_CAPACITY) && (self_heat_capacity > MINIMUM_HEAT_CAPACITY)) - var/heat = conduction_coefficient*temperature_delta* \ - (self_heat_capacity*sharer_heat_capacity/(self_heat_capacity+sharer_heat_capacity)) - - temperature = max(temperature - heat/self_heat_capacity, TCMB) - sharer_temperature = max(sharer_temperature + heat/sharer_heat_capacity, TCMB) - if(sharer) - sharer.temperature = sharer_temperature - return sharer_temperature - //thermal energy of the system (self and sharer) is unchanged - -/datum/gas_mixture/compare(datum/gas_mixture/sample) - var/list/sample_gases = sample.gases //accessing datum vars is slower than proc vars - var/list/cached_gases = gases - - for(var/id in cached_gases | sample_gases) // compare gases from either mixture - var/gas_moles = cached_gases[id] - var/sample_moles = sample_gases[id] - var/delta = abs(gas_moles - sample_moles) - if(delta > MINIMUM_MOLES_DELTA_TO_MOVE && \ - delta > gas_moles * MINIMUM_AIR_RATIO_TO_MOVE) - return id - - var/our_moles - TOTAL_MOLES(cached_gases, our_moles) - if(our_moles > MINIMUM_MOLES_DELTA_TO_MOVE) - var/temp = temperature - var/sample_temp = sample.temperature - - var/temperature_delta = abs(temp - sample_temp) - if(temperature_delta > MINIMUM_TEMPERATURE_DELTA_TO_SUSPEND) - return "temp" - - return "" - + /datum/gas_mixture/react(datum/holder) . = NO_REACTION - var/list/cached_gases = gases - if(!length(cached_gases)) - return var/list/reactions = list() - for(var/datum/gas_reaction/G in SSair.gas_reactions) - if(cached_gases[G.major_gas]) - reactions += G + for(var/I in get_gases()) + reactions += SSair.gas_reactions[I] if(!length(reactions)) return reaction_results = new - var/temp = temperature - var/ener = THERMAL_ENERGY(src) + var/temp = return_temperature() + var/ener = thermal_energy() reaction_loop: for(var/r in reactions) @@ -358,30 +193,14 @@ GLOBAL_LIST_INIT(meta_gas_fusions, meta_gas_fusion_list()) for(var/id in min_reqs) if (id == "TEMP" || id == "ENER") continue - if(cached_gases[id] < min_reqs[id]) + if(get_moles(id) < min_reqs[id]) continue reaction_loop - //at this point, all minimum requirements for the reaction are satisfied. - /* currently no reactions have maximum requirements, so we can leave the checks commented out for a slight performance boost - PLEASE DO NOT REMOVE THIS CODE. the commenting is here only for a performance increase. - enabling these checks should be as easy as possible and the fact that they are disabled should be as clear as possible - - var/list/max_reqs = reaction.max_requirements - if((max_reqs["TEMP"] && temp > max_reqs["TEMP"]) \ - || (max_reqs["ENER"] && ener > max_reqs["ENER"])) - continue - for(var/id in max_reqs) - if(id == "TEMP" || id == "ENER") - continue - if(cached_gases[id] && cached_gases[id][MOLES] > max_reqs[id]) - continue reaction_loop //at this point, all requirements for the reaction are satisfied. we can now react() - */ + . |= reaction.react(src, holder) if (. & STOP_REACTIONS) break - if(.) - GAS_GARBAGE_COLLECT(gases) //Takes the amount of the gas you want to PP as an argument //So I don't have to do some hacky switches/defines/magic strings @@ -390,16 +209,50 @@ GLOBAL_LIST_INIT(meta_gas_fusions, meta_gas_fusion_list()) //O2_PP = get_partial_pressure(gas_mixture.oxygen) /datum/gas_mixture/proc/get_breath_partial_pressure(gas_pressure) - return (gas_pressure * R_IDEAL_GAS_EQUATION * temperature) / BREATH_VOLUME + return (gas_pressure * R_IDEAL_GAS_EQUATION * return_temperature()) / BREATH_VOLUME //inverse /datum/gas_mixture/proc/get_true_breath_pressure(partial_pressure) - return (partial_pressure * BREATH_VOLUME) / (R_IDEAL_GAS_EQUATION * temperature) + return (partial_pressure * BREATH_VOLUME) / (R_IDEAL_GAS_EQUATION * return_temperature()) //Mathematical proofs: /* get_breath_partial_pressure(gas_pp) --> gas_pp/total_moles()*breath_pp = pp get_true_breath_pressure(pp) --> gas_pp = pp/breath_pp*total_moles() - 10/20*5 = 2.5 10 = 2.5/5*20 */ + +/datum/gas_mixture/turf + +/* +/mob/verb/profile_atmos() + /world{loop_checks = 0;} + var/datum/gas_mixture/A = new + var/datum/gas_mixture/B = new + A.parse_gas_string("o2=200;n2=800;TEMP=50") + B.parse_gas_string("co2=500;plasma=500;TEMP=5000") + var/pa + var/pb + pa = world.tick_usage + for(var/I in 1 to 100000) + B.transfer_to(A, 1) + A.transfer_to(B, 1) + pb = world.tick_usage + var/total_time = (pb-pa) * world.tick_lag + to_chat(src, "Total time (gas transfer): [total_time]ms") + to_chat(src, "Operations per second: [100000 / (total_time/1000)]") + pa = world.tick_usage + for(var/I in 1 to 100000) + B.total_moles(); + pb = world.tick_usage + total_time = (pb-pa) * world.tick_lag + to_chat(src, "Total time (total_moles): [total_time]ms") + to_chat(src, "Operations per second: [100000 / (total_time/1000)]") + pa = world.tick_usage + for(var/I in 1 to 100000) + new /datum/gas_mixture + pb = world.tick_usage + total_time = (pb-pa) * world.tick_lag + to_chat(src, "Total time (new gas mixture): [total_time]ms") + to_chat(src, "Operations per second: [100000 / (total_time/1000)]") +*/ diff --git a/code/modules/atmospherics/gasmixtures/immutable_mixtures.dm b/code/modules/atmospherics/gasmixtures/immutable_mixtures.dm index 5527ba3fef..eefad7c970 100644 --- a/code/modules/atmospherics/gasmixtures/immutable_mixtures.dm +++ b/code/modules/atmospherics/gasmixtures/immutable_mixtures.dm @@ -2,73 +2,29 @@ //it can be changed, but any changes will ultimately be undone before they can have any effect /datum/gas_mixture/immutable - var/initial_temperature - gc_share = TRUE + var/initial_temperature = 0 /datum/gas_mixture/immutable/New() ..() - temperature = initial_temperature - temperature_archived = initial_temperature - gases.Cut() + set_temperature(initial_temperature) + populate() + mark_immutable() -/datum/gas_mixture/immutable/merge() - return 0 //we're immutable. +/datum/gas_mixture/immutable/proc/populate() + return -/datum/gas_mixture/immutable/share(datum/gas_mixture/sharer, atmos_adjacent_turfs = 4) - . = ..(sharer, 0) - temperature = initial_temperature - temperature_archived = initial_temperature - gases.Cut() - -/datum/gas_mixture/immutable/react() - return 0 //we're immutable. - -/datum/gas_mixture/immutable/copy() - return new type //we're immutable, so we can just return a new instance. - -/datum/gas_mixture/immutable/copy_from() - return 0 //we're immutable. - -/datum/gas_mixture/immutable/copy_from_turf() - return 0 //we're immutable. - -/datum/gas_mixture/immutable/parse_gas_string() - return 0 //we're immutable. - -/datum/gas_mixture/immutable/temperature_share(datum/gas_mixture/sharer, conduction_coefficient, sharer_temperature, sharer_heat_capacity) - . = ..() - temperature = initial_temperature - -/datum/gas_mixture/immutable/proc/after_process_cell() - temperature = initial_temperature - temperature_archived = initial_temperature - gases.Cut() //used by space tiles /datum/gas_mixture/immutable/space initial_temperature = TCMB -/datum/gas_mixture/immutable/space/heat_capacity() - return HEAT_CAPACITY_VACUUM - -/datum/gas_mixture/immutable/space/remove() - return copy() //we're always empty, so we can just return a copy. - -/datum/gas_mixture/immutable/space/remove_ratio() - return copy() //we're always empty, so we can just return a copy. - +/datum/gas_mixture/immutable/space/populate() + set_min_heat_capacity(HEAT_CAPACITY_VACUUM) //used by cloners /datum/gas_mixture/immutable/cloner initial_temperature = T20C -/datum/gas_mixture/immutable/cloner/New() +/datum/gas_mixture/immutable/cloner/populate() ..() - gases[/datum/gas/nitrogen] = MOLES_O2STANDARD + MOLES_N2STANDARD - -/datum/gas_mixture/immutable/cloner/share(datum/gas_mixture/sharer, atmos_adjacent_turfs = 4) - . = ..(sharer, 0) - gases[/datum/gas/nitrogen] = MOLES_O2STANDARD + MOLES_N2STANDARD - -/datum/gas_mixture/immutable/cloner/heat_capacity() - return (MOLES_O2STANDARD + MOLES_N2STANDARD)*20 //specific heat of nitrogen is 20 + set_moles(/datum/gas/nitrogen, MOLES_O2STANDARD + MOLES_N2STANDARD) diff --git a/code/modules/atmospherics/gasmixtures/reactions.dm b/code/modules/atmospherics/gasmixtures/reactions.dm index 59ef15b4cf..c0f66be7de 100644 --- a/code/modules/atmospherics/gasmixtures/reactions.dm +++ b/code/modules/atmospherics/gasmixtures/reactions.dm @@ -63,11 +63,11 @@ /datum/gas_reaction/water_vapor/react(datum/gas_mixture/air, datum/holder) var/turf/open/location = isturf(holder) ? holder : null . = NO_REACTION - if (air.temperature <= WATER_VAPOR_FREEZE) + if (air.return_temperature() <= WATER_VAPOR_FREEZE) if(location && location.freon_gas_act()) . = REACTING else if(location && location.water_vapor_gas_act()) - air.gases[/datum/gas/water_vapor] -= MOLES_GAS_VISIBLE + air.adjust_moles(/datum/gas/water_vapor,-MOLES_GAS_VISIBLE) . = REACTING //tritium combustion: combustion of oxygen and tritium (treated as hydrocarbons). creates hotspots. exothermic @@ -86,38 +86,37 @@ /datum/gas_reaction/tritfire/react(datum/gas_mixture/air, datum/holder) var/energy_released = 0 var/old_heat_capacity = air.heat_capacity() - var/list/cached_gases = air.gases //this speeds things up because accessing datum vars is slow - var/temperature = air.temperature + var/temperature = air.return_temperature() var/list/cached_results = air.reaction_results cached_results["fire"] = 0 var/turf/open/location = isturf(holder) ? holder : null var/burned_fuel = 0 - if(cached_gases[/datum/gas/oxygen] < cached_gases[/datum/gas/tritium]) - burned_fuel = cached_gases[/datum/gas/oxygen]/TRITIUM_BURN_OXY_FACTOR - cached_gases[/datum/gas/tritium] -= burned_fuel + if(air.get_moles(/datum/gas/oxygen) < air.get_moles(/datum/gas/tritium)) + burned_fuel = air.get_moles(/datum/gas/oxygen)/TRITIUM_BURN_OXY_FACTOR + air.adjust_moles(/datum/gas/tritium, -burned_fuel) else - burned_fuel = cached_gases[/datum/gas/tritium]*TRITIUM_BURN_TRIT_FACTOR - cached_gases[/datum/gas/tritium] -= cached_gases[/datum/gas/tritium]/TRITIUM_BURN_TRIT_FACTOR - cached_gases[/datum/gas/oxygen] -= cached_gases[/datum/gas/tritium] + burned_fuel = air.get_moles(/datum/gas/tritium)*TRITIUM_BURN_TRIT_FACTOR + air.adjust_moles(/datum/gas/tritium, -air.get_moles(/datum/gas/tritium)/TRITIUM_BURN_TRIT_FACTOR) + air.adjust_moles(/datum/gas/oxygen,-air.get_moles(/datum/gas/tritium)) if(burned_fuel) energy_released += (FIRE_HYDROGEN_ENERGY_RELEASED * burned_fuel) if(location && prob(10) && burned_fuel > TRITIUM_MINIMUM_RADIATION_ENERGY) //woah there let's not crash the server radiation_pulse(location, energy_released/TRITIUM_BURN_RADIOACTIVITY_FACTOR) - cached_gases[/datum/gas/water_vapor] += burned_fuel/TRITIUM_BURN_OXY_FACTOR + air.adjust_moles(/datum/gas/water_vapor, burned_fuel/TRITIUM_BURN_OXY_FACTOR) cached_results["fire"] += burned_fuel if(energy_released > 0) var/new_heat_capacity = air.heat_capacity() if(new_heat_capacity > MINIMUM_HEAT_CAPACITY) - air.temperature = (temperature*old_heat_capacity + energy_released)/new_heat_capacity + air.set_temperature((temperature*old_heat_capacity + energy_released)/new_heat_capacity) //let the floor know a fire is happening if(istype(location)) - temperature = air.temperature + temperature = air.return_temperature() if(temperature > FIRE_MINIMUM_TEMPERATURE_TO_EXIST) location.hotspot_expose(temperature, CELL_VOLUME) for(var/I in location) @@ -143,8 +142,7 @@ /datum/gas_reaction/plasmafire/react(datum/gas_mixture/air, datum/holder) var/energy_released = 0 var/old_heat_capacity = air.heat_capacity() - var/list/cached_gases = air.gases //this speeds things up because accessing datum vars is slow - var/temperature = air.temperature + var/temperature = air.return_temperature() var/list/cached_results = air.reaction_results cached_results["fire"] = 0 var/turf/open/location = isturf(holder) ? holder : null @@ -163,21 +161,21 @@ temperature_scale = (temperature-PLASMA_MINIMUM_BURN_TEMPERATURE)/(PLASMA_UPPER_TEMPERATURE-PLASMA_MINIMUM_BURN_TEMPERATURE) if(temperature_scale > 0) oxygen_burn_rate = OXYGEN_BURN_RATE_BASE - temperature_scale - if(cached_gases[/datum/gas/oxygen] / cached_gases[/datum/gas/plasma] > SUPER_SATURATION_THRESHOLD) //supersaturation. Form Tritium. + if(air.get_moles(/datum/gas/oxygen) / air.get_moles(/datum/gas/plasma) > SUPER_SATURATION_THRESHOLD) //supersaturation. Form Tritium. super_saturation = TRUE - if(cached_gases[/datum/gas/oxygen] > cached_gases[/datum/gas/plasma]*PLASMA_OXYGEN_FULLBURN) - plasma_burn_rate = (cached_gases[/datum/gas/plasma]*temperature_scale)/PLASMA_BURN_RATE_DELTA + if(air.get_moles(/datum/gas/oxygen) > air.get_moles(/datum/gas/plasma)*PLASMA_OXYGEN_FULLBURN) + plasma_burn_rate = (air.get_moles(/datum/gas/plasma)*temperature_scale)/PLASMA_BURN_RATE_DELTA else - plasma_burn_rate = (temperature_scale*(cached_gases[/datum/gas/oxygen]/PLASMA_OXYGEN_FULLBURN))/PLASMA_BURN_RATE_DELTA + plasma_burn_rate = (temperature_scale*(air.get_moles(/datum/gas/oxygen)/PLASMA_OXYGEN_FULLBURN))/PLASMA_BURN_RATE_DELTA if(plasma_burn_rate > MINIMUM_HEAT_CAPACITY) - plasma_burn_rate = min(plasma_burn_rate,cached_gases[/datum/gas/plasma],cached_gases[/datum/gas/oxygen]/oxygen_burn_rate) //Ensures matter is conserved properly - cached_gases[/datum/gas/plasma] = QUANTIZE(cached_gases[/datum/gas/plasma] - plasma_burn_rate) - cached_gases[/datum/gas/oxygen] = QUANTIZE(cached_gases[/datum/gas/oxygen] - (plasma_burn_rate * oxygen_burn_rate)) + plasma_burn_rate = min(plasma_burn_rate,air.get_moles(/datum/gas/plasma),air.get_moles(/datum/gas/oxygen)/oxygen_burn_rate) //Ensures matter is conserved properly + air.set_moles(/datum/gas/plasma, QUANTIZE(air.get_moles(/datum/gas/plasma) - plasma_burn_rate)) + air.set_moles(/datum/gas/oxygen, QUANTIZE(air.get_moles(/datum/gas/oxygen) - (plasma_burn_rate * oxygen_burn_rate))) if (super_saturation) - cached_gases[/datum/gas/tritium] += plasma_burn_rate + air.adjust_moles(/datum/gas/tritium, plasma_burn_rate) else - cached_gases[/datum/gas/carbon_dioxide] += plasma_burn_rate + air.adjust_moles(/datum/gas/carbon_dioxide, plasma_burn_rate) energy_released += FIRE_PLASMA_ENERGY_RELEASED * (plasma_burn_rate) @@ -186,11 +184,11 @@ if(energy_released > 0) var/new_heat_capacity = air.heat_capacity() if(new_heat_capacity > MINIMUM_HEAT_CAPACITY) - air.temperature = (temperature*old_heat_capacity + energy_released)/new_heat_capacity + air.set_temperature((temperature*old_heat_capacity + energy_released)/new_heat_capacity) //let the floor know a fire is happening if(istype(location)) - temperature = air.temperature + temperature = air.return_temperature() if(temperature > FIRE_MINIMUM_TEMPERATURE_TO_EXIST) location.hotspot_expose(temperature, CELL_VOLUME) for(var/I in location) @@ -218,7 +216,6 @@ /datum/gas/carbon_dioxide = FUSION_MOLE_THRESHOLD) /datum/gas_reaction/fusion/react(datum/gas_mixture/air, datum/holder) - var/list/cached_gases = air.gases var/turf/open/location if (istype(holder,/datum/pipeline)) //Find the tile the reaction is occuring on, or a random part of the network if it's a pipenet. var/datum/pipeline/fusion_pipenet = holder @@ -230,14 +227,14 @@ var/list/cached_scan_results = air.analyzer_results var/old_heat_capacity = air.heat_capacity() var/reaction_energy = 0 //Reaction energy can be negative or positive, for both exothermic and endothermic reactions. - var/initial_plasma = cached_gases[/datum/gas/plasma] - var/initial_carbon = cached_gases[/datum/gas/carbon_dioxide] - var/scale_factor = (air.volume)/(PI) //We scale it down by volume/Pi because for fusion conditions, moles roughly = 2*volume, but we want it to be based off something constant between reactions. - var/toroidal_size = (2*PI)+TORADIANS(arctan((air.volume-TOROID_VOLUME_BREAKEVEN)/TOROID_VOLUME_BREAKEVEN)) //The size of the phase space hypertorus + var/initial_plasma = air.get_moles(/datum/gas/plasma) + var/initial_carbon = air.get_moles(/datum/gas/carbon_dioxide) + var/scale_factor = (air.return_volume())/(PI) //We scale it down by volume/Pi because for fusion conditions, moles roughly = 2*volume, but we want it to be based off something constant between reactions. + var/toroidal_size = (2*PI)+TORADIANS(arctan((air.return_volume()-TOROID_VOLUME_BREAKEVEN)/TOROID_VOLUME_BREAKEVEN)) //The size of the phase space hypertorus var/gas_power = 0 var/list/gas_fusion_powers = GLOB.meta_gas_fusions - for (var/gas_id in cached_gases) - gas_power += (gas_fusion_powers[gas_id]*cached_gases[gas_id]) + for (var/gas_id in air.get_gases()) + gas_power += (gas_fusion_powers[gas_id]*air.get_moles(gas_id)) var/instability = MODULUS((gas_power*INSTABILITY_GAS_POWER_FACTOR)**2,toroidal_size) //Instability effects how chaotic the behavior of the reaction is cached_scan_results[id] = instability//used for analyzer feedback @@ -249,9 +246,9 @@ carbon = MODULUS(carbon - plasma, toroidal_size) - cached_gases[/datum/gas/plasma] = plasma*scale_factor + FUSION_MOLE_THRESHOLD //Scales the gases back up - cached_gases[/datum/gas/carbon_dioxide] = carbon*scale_factor + FUSION_MOLE_THRESHOLD - var/delta_plasma = initial_plasma - cached_gases[/datum/gas/plasma] + air.set_moles(/datum/gas/plasma, plasma*scale_factor + FUSION_MOLE_THRESHOLD) //Scales the gases back up + air.set_moles(/datum/gas/carbon_dioxide , carbon*scale_factor + FUSION_MOLE_THRESHOLD) + var/delta_plasma = initial_plasma - air.get_moles(/datum/gas/plasma) reaction_energy += delta_plasma*PLASMA_BINDING_ENERGY //Energy is gained or lost corresponding to the creation or destruction of mass. if(instability < FUSION_INSTABILITY_ENDOTHERMALITY) @@ -260,17 +257,17 @@ reaction_energy *= (instability-FUSION_INSTABILITY_ENDOTHERMALITY)**0.5 if(air.thermal_energy() + reaction_energy < 0) //No using energy that doesn't exist. - cached_gases[/datum/gas/plasma] = initial_plasma - cached_gases[/datum/gas/carbon_dioxide] = initial_carbon + air.set_moles(/datum/gas/plasma,initial_plasma) + air.set_moles(/datum/gas/carbon_dioxide, initial_carbon) return NO_REACTION - cached_gases[/datum/gas/tritium] -= FUSION_TRITIUM_MOLES_USED + air.adjust_moles(/datum/gas/tritium, -FUSION_TRITIUM_MOLES_USED) //The decay of the tritium and the reaction's energy produces waste gases, different ones depending on whether the reaction is endo or exothermic if(reaction_energy > 0) - cached_gases[/datum/gas/oxygen] += FUSION_TRITIUM_MOLES_USED*(reaction_energy*FUSION_TRITIUM_CONVERSION_COEFFICIENT) - cached_gases[/datum/gas/nitrous_oxide] += FUSION_TRITIUM_MOLES_USED*(reaction_energy*FUSION_TRITIUM_CONVERSION_COEFFICIENT) + air.adjust_moles(/datum/gas/oxygen, FUSION_TRITIUM_MOLES_USED*(reaction_energy*FUSION_TRITIUM_CONVERSION_COEFFICIENT)) + air.adjust_moles(/datum/gas/nitrous_oxide, FUSION_TRITIUM_MOLES_USED*(reaction_energy*FUSION_TRITIUM_CONVERSION_COEFFICIENT)) else - cached_gases[/datum/gas/bz] += FUSION_TRITIUM_MOLES_USED*(reaction_energy*-FUSION_TRITIUM_CONVERSION_COEFFICIENT) - cached_gases[/datum/gas/nitryl] += FUSION_TRITIUM_MOLES_USED*(reaction_energy*-FUSION_TRITIUM_CONVERSION_COEFFICIENT) + air.adjust_moles(/datum/gas/bz, FUSION_TRITIUM_MOLES_USED*(reaction_energy*-FUSION_TRITIUM_CONVERSION_COEFFICIENT)) + air.adjust_moles(/datum/gas/nitryl, FUSION_TRITIUM_MOLES_USED*(reaction_energy*-FUSION_TRITIUM_CONVERSION_COEFFICIENT)) if(reaction_energy) if(location) @@ -282,7 +279,7 @@ var/new_heat_capacity = air.heat_capacity() if(new_heat_capacity > MINIMUM_HEAT_CAPACITY) - air.temperature = clamp(((air.temperature*old_heat_capacity + reaction_energy)/new_heat_capacity),TCMB,INFINITY) + air.set_temperature(clamp(((air.return_temperature()*old_heat_capacity + reaction_energy)/new_heat_capacity),TCMB,INFINITY)) return REACTING /datum/gas_reaction/nitrylformation //The formation of nitryl. Endothermic. Requires N2O as a catalyst. @@ -299,22 +296,21 @@ ) /datum/gas_reaction/nitrylformation/react(datum/gas_mixture/air) - var/list/cached_gases = air.gases - var/temperature = air.temperature + var/temperature = air.return_temperature() var/old_heat_capacity = air.heat_capacity() - var/heat_efficency = min(temperature/(FIRE_MINIMUM_TEMPERATURE_TO_EXIST*100),cached_gases[/datum/gas/oxygen],cached_gases[/datum/gas/nitrogen]) + var/heat_efficency = min(temperature/(FIRE_MINIMUM_TEMPERATURE_TO_EXIST*100),air.get_moles(/datum/gas/oxygen),air.get_moles(/datum/gas/nitrogen)) var/energy_used = heat_efficency*NITRYL_FORMATION_ENERGY - if ((cached_gases[/datum/gas/oxygen] - heat_efficency < 0 )|| (cached_gases[/datum/gas/nitrogen] - heat_efficency < 0)) //Shouldn't produce gas from nothing. + if ((air.get_moles(/datum/gas/oxygen) - heat_efficency < 0 )|| (air.get_moles(/datum/gas/nitrogen) - heat_efficency < 0)) //Shouldn't produce gas from nothing. return NO_REACTION - cached_gases[/datum/gas/oxygen] -= heat_efficency - cached_gases[/datum/gas/nitrogen] -= heat_efficency - cached_gases[/datum/gas/nitryl] += heat_efficency*2 + air.adjust_moles(/datum/gas/oxygen, heat_efficency) + air.adjust_moles(/datum/gas/nitrogen, heat_efficency) + air.adjust_moles(/datum/gas/nitryl, heat_efficency*2) if(energy_used > 0) var/new_heat_capacity = air.heat_capacity() if(new_heat_capacity > MINIMUM_HEAT_CAPACITY) - air.temperature = max(((temperature*old_heat_capacity - energy_used)/new_heat_capacity),TCMB) + air.set_temperature(max(((temperature*old_heat_capacity - energy_used)/new_heat_capacity),TCMB)) return REACTING /datum/gas_reaction/bzformation //Formation of BZ by combining plasma and tritium at low pressures. Exothermic. @@ -330,27 +326,26 @@ /datum/gas_reaction/bzformation/react(datum/gas_mixture/air) - var/list/cached_gases = air.gases - var/temperature = air.temperature + var/temperature = air.return_temperature() var/pressure = air.return_pressure() var/old_heat_capacity = air.heat_capacity() - var/reaction_efficency = min(1/((pressure/(0.1*ONE_ATMOSPHERE))*(max(cached_gases[/datum/gas/plasma]/cached_gases[/datum/gas/nitrous_oxide],1))),cached_gases[/datum/gas/nitrous_oxide],cached_gases[/datum/gas/plasma]/2) + var/reaction_efficency = min(1/((pressure/(0.1*ONE_ATMOSPHERE))*(max(air.get_moles(/datum/gas/plasma)/air.get_moles(/datum/gas/nitrous_oxide),1))),air.get_moles(/datum/gas/nitrous_oxide),air.get_moles(/datum/gas/plasma)/2) var/energy_released = 2*reaction_efficency*FIRE_CARBON_ENERGY_RELEASED - if ((cached_gases[/datum/gas/nitrous_oxide] - reaction_efficency < 0 )|| (cached_gases[/datum/gas/plasma] - (2*reaction_efficency) < 0) || energy_released <= 0) //Shouldn't produce gas from nothing. + if ((air.get_moles(/datum/gas/nitrous_oxide) - reaction_efficency < 0 )|| (air.get_moles(/datum/gas/plasma) - (2*reaction_efficency) < 0) || energy_released <= 0) //Shouldn't produce gas from nothing. return NO_REACTION - cached_gases[/datum/gas/bz] += reaction_efficency - if(reaction_efficency == cached_gases[/datum/gas/nitrous_oxide]) - cached_gases[/datum/gas/bz] -= min(pressure,1) - cached_gases[/datum/gas/oxygen] += min(pressure,1) - cached_gases[/datum/gas/nitrous_oxide] -= reaction_efficency - cached_gases[/datum/gas/plasma] -= 2*reaction_efficency + air.adjust_moles(/datum/gas/bz, reaction_efficency) + if(reaction_efficency == air.get_moles(/datum/gas/nitrous_oxide)) + air.adjust_moles(/datum/gas/bz, -min(pressure,1)) + air.adjust_moles(/datum/gas/oxygen, min(pressure,1)) + air.adjust_moles(/datum/gas/nitrous_oxide, -reaction_efficency) + air.adjust_moles(/datum/gas/plasma, -2*reaction_efficency) SSresearch.science_tech.add_point_type(TECHWEB_POINT_TYPE_DEFAULT, min((reaction_efficency**2)*BZ_RESEARCH_SCALE),BZ_RESEARCH_MAX_AMOUNT) if(energy_released > 0) var/new_heat_capacity = air.heat_capacity() if(new_heat_capacity > MINIMUM_HEAT_CAPACITY) - air.temperature = max(((temperature*old_heat_capacity + energy_released)/new_heat_capacity),TCMB) + air.set_temperature(max(((temperature*old_heat_capacity + energy_released)/new_heat_capacity),TCMB)) return REACTING /datum/gas_reaction/stimformation //Stimulum formation follows a strange pattern of how effective it will be at a given temperature, having some multiple peaks and some large dropoffs. Exo and endo thermic. @@ -367,24 +362,22 @@ "TEMP" = STIMULUM_HEAT_SCALE/2) /datum/gas_reaction/stimformation/react(datum/gas_mixture/air) - var/list/cached_gases = air.gases - var/old_heat_capacity = air.heat_capacity() - var/heat_scale = min(air.temperature/STIMULUM_HEAT_SCALE,cached_gases[/datum/gas/tritium],cached_gases[/datum/gas/plasma],cached_gases[/datum/gas/nitryl]) + var/heat_scale = min(air.return_temperature()/STIMULUM_HEAT_SCALE,air.get_moles(/datum/gas/tritium),air.get_moles(/datum/gas/plasma),air.get_moles(/datum/gas/nitryl)) var/stim_energy_change = heat_scale + STIMULUM_FIRST_RISE*(heat_scale**2) - STIMULUM_FIRST_DROP*(heat_scale**3) + STIMULUM_SECOND_RISE*(heat_scale**4) - STIMULUM_ABSOLUTE_DROP*(heat_scale**5) - if ((cached_gases[/datum/gas/tritium] - heat_scale < 0 )|| (cached_gases[/datum/gas/plasma] - heat_scale < 0) || (cached_gases[/datum/gas/nitryl] - heat_scale < 0)) //Shouldn't produce gas from nothing. + if ((air.get_moles(/datum/gas/tritium) - heat_scale < 0 )|| (air.get_moles(/datum/gas/plasma) - heat_scale < 0) || (air.get_moles(/datum/gas/nitryl) - heat_scale < 0)) //Shouldn't produce gas from nothing. return NO_REACTION - cached_gases[/datum/gas/stimulum]+= heat_scale/10 - cached_gases[/datum/gas/tritium] -= heat_scale - cached_gases[/datum/gas/plasma] -= heat_scale - cached_gases[/datum/gas/nitryl] -= heat_scale + air.adjust_moles(/datum/gas/stimulum, heat_scale/10) + air.adjust_moles(/datum/gas/tritium, -heat_scale) + air.adjust_moles(/datum/gas/plasma, -heat_scale) + air.adjust_moles(/datum/gas/nitryl, -heat_scale) SSresearch.science_tech.add_point_type(TECHWEB_POINT_TYPE_DEFAULT, STIMULUM_RESEARCH_AMOUNT*max(stim_energy_change,0)) if(stim_energy_change) var/new_heat_capacity = air.heat_capacity() if(new_heat_capacity > MINIMUM_HEAT_CAPACITY) - air.temperature = max(((air.temperature*old_heat_capacity + stim_energy_change)/new_heat_capacity),TCMB) + air.set_temperature(max(((air.return_temperature()*old_heat_capacity + stim_energy_change)/new_heat_capacity),TCMB)) return REACTING /datum/gas_reaction/nobliumformation //Hyper-Noblium formation is extrememly endothermic, but requires high temperatures to start. Due to its high mass, hyper-nobelium uses large amounts of nitrogen and tritium. BZ can be used as a catalyst to make it less endothermic. @@ -399,22 +392,21 @@ "TEMP" = 5000000) /datum/gas_reaction/nobliumformation/react(datum/gas_mixture/air) - var/list/cached_gases = air.gases var/old_heat_capacity = air.heat_capacity() - var/nob_formed = min((cached_gases[/datum/gas/nitrogen]+cached_gases[/datum/gas/tritium])/100,cached_gases[/datum/gas/tritium]/10,cached_gases[/datum/gas/nitrogen]/20) - var/energy_taken = nob_formed*(NOBLIUM_FORMATION_ENERGY/(max(cached_gases[/datum/gas/bz],1))) - if ((cached_gases[/datum/gas/tritium] - 10*nob_formed < 0) || (cached_gases[/datum/gas/nitrogen] - 20*nob_formed < 0)) + var/nob_formed = min((air.get_moles(/datum/gas/nitrogen)+air.get_moles(/datum/gas/tritium))/100,air.get_moles(/datum/gas/tritium)/10,air.get_moles(/datum/gas/nitrogen)/20) + var/energy_taken = nob_formed*(NOBLIUM_FORMATION_ENERGY/(max(air.get_moles(/datum/gas/bz),1))) + if ((air.get_moles(/datum/gas/tritium) - 10*nob_formed < 0) || (air.get_moles(/datum/gas/nitrogen) - 20*nob_formed < 0)) return NO_REACTION - cached_gases[/datum/gas/tritium] -= 10*nob_formed - cached_gases[/datum/gas/nitrogen] -= 20*nob_formed - cached_gases[/datum/gas/hypernoblium]+= nob_formed + air.adjust_moles(/datum/gas/tritium, -10*nob_formed) + air.adjust_moles(/datum/gas/nitrogen, -20*nob_formed) + air.adjust_moles(/datum/gas/hypernoblium,nob_formed) SSresearch.science_tech.add_point_type(TECHWEB_POINT_TYPE_DEFAULT, nob_formed*NOBLIUM_RESEARCH_AMOUNT) if (nob_formed) var/new_heat_capacity = air.heat_capacity() if(new_heat_capacity > MINIMUM_HEAT_CAPACITY) - air.temperature = max(((air.temperature*old_heat_capacity - energy_taken)/new_heat_capacity),TCMB) + air.set_temperature(max(((air.return_temperature()*old_heat_capacity - energy_taken)/new_heat_capacity),TCMB)) /datum/gas_reaction/miaster //dry heat sterilization: clears out pathogens in the air @@ -429,16 +421,15 @@ ) /datum/gas_reaction/miaster/react(datum/gas_mixture/air, datum/holder) - var/list/cached_gases = air.gases // As the name says it, it needs to be dry - if(cached_gases[/datum/gas/water_vapor] && cached_gases[/datum/gas/water_vapor]/air.total_moles() > 0.1) + if(air.get_moles(/datum/gas/water_vapor) && air.get_moles(/datum/gas/water_vapor)/air.total_moles() > 0.1) return //Replace miasma with oxygen - var/cleaned_air = min(cached_gases[/datum/gas/miasma], 20 + (air.temperature - FIRE_MINIMUM_TEMPERATURE_TO_EXIST - 70) / 20) - cached_gases[/datum/gas/miasma] -= cleaned_air - cached_gases[/datum/gas/oxygen] += cleaned_air + var/cleaned_air = min(air.get_moles(/datum/gas/miasma), 20 + (air.return_temperature() - FIRE_MINIMUM_TEMPERATURE_TO_EXIST - 70) / 20) + air.adjust_moles(/datum/gas/miasma, -cleaned_air) + air.adjust_moles(/datum/gas/oxygen, cleaned_air) //Possibly burning a bit of organic matter through maillard reaction, so a *tiny* bit more heat would be understandable - air.temperature += cleaned_air * 0.002 + air.set_temperature(air.return_temperature() + cleaned_air * 0.002) SSresearch.science_tech.add_point_type(TECHWEB_POINT_TYPE_DEFAULT, cleaned_air*MIASMA_RESEARCH_AMOUNT)//Turns out the burning of miasma is kinda interesting to scientists diff --git a/code/modules/atmospherics/machinery/airalarm.dm b/code/modules/atmospherics/machinery/airalarm.dm index 0838c7b091..85a668debc 100644 --- a/code/modules/atmospherics/machinery/airalarm.dm +++ b/code/modules/atmospherics/machinery/airalarm.dm @@ -267,7 +267,7 @@ "unit" = "kPa", "danger_level" = cur_tlv.get_danger_level(pressure) )) - var/temperature = environment.temperature + var/temperature = environment.return_temperature() cur_tlv = TLV["temperature"] data["environment_data"] += list(list( "name" = "Temperature", @@ -276,16 +276,16 @@ "danger_level" = cur_tlv.get_danger_level(temperature) )) var/total_moles = environment.total_moles() - var/partial_pressure = R_IDEAL_GAS_EQUATION * environment.temperature / environment.volume - for(var/gas_id in environment.gases) + var/partial_pressure = R_IDEAL_GAS_EQUATION * environment.return_temperature() / environment.return_volume() + for(var/gas_id in environment.get_gases()) if(!(gas_id in TLV)) // We're not interested in this gas, it seems. continue cur_tlv = TLV[gas_id] data["environment_data"] += list(list( "name" = GLOB.meta_gas_names[gas_id], - "value" = environment.gases[gas_id] / total_moles * 100, + "value" = environment.get_moles(gas_id) / total_moles * 100, "unit" = "%", - "danger_level" = cur_tlv.get_danger_level(environment.gases[gas_id] * partial_pressure) + "danger_level" = cur_tlv.get_danger_level(environment.get_moles(gas_id) * partial_pressure) )) if(!locked || hasSiliconAccessInArea(user, PRIVILEDGES_SILICON|PRIVILEDGES_DRONE)) @@ -682,24 +682,21 @@ var/datum/tlv/cur_tlv var/datum/gas_mixture/environment = location.return_air() - var/list/env_gases = environment.gases - var/partial_pressure = R_IDEAL_GAS_EQUATION * environment.temperature / environment.volume + var/partial_pressure = R_IDEAL_GAS_EQUATION * environment.return_temperature() / environment.return_volume() cur_tlv = TLV["pressure"] var/environment_pressure = environment.return_pressure() var/pressure_dangerlevel = cur_tlv.get_danger_level(environment_pressure) cur_tlv = TLV["temperature"] - var/temperature_dangerlevel = cur_tlv.get_danger_level(environment.temperature) + var/temperature_dangerlevel = cur_tlv.get_danger_level(environment.return_temperature()) var/gas_dangerlevel = 0 - for(var/gas_id in env_gases) + for(var/gas_id in environment.get_gases()) if(!(gas_id in TLV)) // We're not interested in this gas, it seems. continue cur_tlv = TLV[gas_id] - gas_dangerlevel = max(gas_dangerlevel, cur_tlv.get_danger_level(env_gases[gas_id] * partial_pressure)) - - GAS_GARBAGE_COLLECT(environment.gases) + gas_dangerlevel = max(gas_dangerlevel, cur_tlv.get_danger_level(environment.get_moles(gas_id) * partial_pressure)) var/old_danger_level = danger_level danger_level = max(pressure_dangerlevel, temperature_dangerlevel, gas_dangerlevel) diff --git a/code/modules/atmospherics/machinery/components/binary_devices/circulator.dm b/code/modules/atmospherics/machinery/components/binary_devices/circulator.dm index c164dc5ae3..4e0c7c1eff 100644 --- a/code/modules/atmospherics/machinery/components/binary_devices/circulator.dm +++ b/code/modules/atmospherics/machinery/components/binary_devices/circulator.dm @@ -51,10 +51,10 @@ return null //Calculate necessary moles to transfer using PV = nRT - if(air2.temperature>0) + if(air2.return_temperature()>0) var/pressure_delta = (input_starting_pressure - output_starting_pressure)/2 - var/transfer_moles = pressure_delta*air1.volume/(air2.temperature * R_IDEAL_GAS_EQUATION) + var/transfer_moles = pressure_delta*air1.return_volume()/(air2.return_temperature() * R_IDEAL_GAS_EQUATION) last_pressure_delta = pressure_delta diff --git a/code/modules/atmospherics/machinery/components/binary_devices/dp_vent_pump.dm b/code/modules/atmospherics/machinery/components/binary_devices/dp_vent_pump.dm index 2dc0afac26..f5c6048b14 100644 --- a/code/modules/atmospherics/machinery/components/binary_devices/dp_vent_pump.dm +++ b/code/modules/atmospherics/machinery/components/binary_devices/dp_vent_pump.dm @@ -66,8 +66,8 @@ pressure_delta = min(pressure_delta, (air1.return_pressure() - input_pressure_min)) if(pressure_delta > 0) - if(air1.temperature > 0) - var/transfer_moles = pressure_delta*environment.volume/(air1.temperature * R_IDEAL_GAS_EQUATION) + if(air1.return_temperature() > 0) + var/transfer_moles = pressure_delta*environment.return_volume()/(air1.return_temperature() * R_IDEAL_GAS_EQUATION) var/datum/gas_mixture/removed = air1.remove(transfer_moles) //Removed can be null if there is no atmosphere in air1 @@ -89,8 +89,8 @@ pressure_delta = min(pressure_delta, (output_pressure_max - air2.return_pressure())) if(pressure_delta > 0) - if(environment.temperature > 0) - var/transfer_moles = pressure_delta*air2.volume/(environment.temperature * R_IDEAL_GAS_EQUATION) + if(environment.return_temperature() > 0) + var/transfer_moles = pressure_delta*air2.return_volume()/(environment.return_temperature() * R_IDEAL_GAS_EQUATION) var/datum/gas_mixture/removed = loc.remove_air(transfer_moles) //removed can be null if there is no air in the location @@ -182,8 +182,8 @@ ..() var/datum/gas_mixture/air1 = airs[1] var/datum/gas_mixture/air2 = airs[2] - air1.volume = 1000 - air2.volume = 1000 + air1.set_volume(1000) + air2.set_volume(1000) // Mapping 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 051dc965ad..fc967608b3 100644 --- a/code/modules/atmospherics/machinery/components/binary_devices/passive_gate.dm +++ b/code/modules/atmospherics/machinery/components/binary_devices/passive_gate.dm @@ -53,11 +53,11 @@ Passive gate is similar to the regular pump except: return //Calculate necessary moles to transfer using PV = nRT - if((air1.total_moles() > 0) && (air1.temperature>0)) + if((air1.total_moles() > 0) && (air1.return_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.return_volume()/(air1.return_temperature() * R_IDEAL_GAS_EQUATION) //Actually transfer the gas var/datum/gas_mixture/removed = air1.remove(transfer_moles) @@ -172,4 +172,4 @@ Passive gate is similar to the regular pump except: /obj/machinery/atmospherics/components/binary/passive_gate/layer3 piping_layer = 3 - icon_state = "passgate_map-3" \ No newline at end of file + icon_state = "passgate_map-3" diff --git a/code/modules/atmospherics/machinery/components/binary_devices/pump.dm b/code/modules/atmospherics/machinery/components/binary_devices/pump.dm index 0e41f78e20..ab6d02fe61 100644 --- a/code/modules/atmospherics/machinery/components/binary_devices/pump.dm +++ b/code/modules/atmospherics/machinery/components/binary_devices/pump.dm @@ -77,9 +77,9 @@ return //Calculate necessary moles to transfer using PV=nRT - if((air1.total_moles() > 0) && (air1.temperature>0)) + if((air1.total_moles() > 0) && (air1.return_temperature()>0)) var/pressure_delta = target_pressure - output_starting_pressure - var/transfer_moles = pressure_delta*air2.volume/(air1.temperature * R_IDEAL_GAS_EQUATION) + var/transfer_moles = pressure_delta*air2.return_volume()/(air1.return_temperature() * R_IDEAL_GAS_EQUATION) //Actually transfer the gas var/datum/gas_mixture/removed = air1.remove(transfer_moles) @@ -212,4 +212,4 @@ /obj/machinery/atmospherics/components/binary/pump/on/layer3 piping_layer = 3 - icon_state= "pump_on_map-3" \ No newline at end of file + icon_state= "pump_on_map-3" diff --git a/code/modules/atmospherics/machinery/components/binary_devices/volume_pump.dm b/code/modules/atmospherics/machinery/components/binary_devices/volume_pump.dm index 1005f72afe..87cbeb6edf 100644 --- a/code/modules/atmospherics/machinery/components/binary_devices/volume_pump.dm +++ b/code/modules/atmospherics/machinery/components/binary_devices/volume_pump.dm @@ -65,7 +65,7 @@ if((input_starting_pressure < 0.01) || (output_starting_pressure > 9000)) return - var/transfer_ratio = transfer_rate/air1.volume + var/transfer_ratio = transfer_rate/air1.return_volume() var/datum/gas_mixture/removed = air1.remove_ratio(transfer_ratio) @@ -153,7 +153,7 @@ if("set_transfer_rate" in signal.data) var/datum/gas_mixture/air1 = airs[1] - transfer_rate = clamp(text2num(signal.data["set_transfer_rate"]),0,air1.volume) + transfer_rate = clamp(text2num(signal.data["set_transfer_rate"]),0,air1.return_volume()) if(on != old_on) investigate_log("was turned [on ? "on" : "off"] by a remote signal", INVESTIGATE_ATMOS) @@ -200,4 +200,4 @@ /obj/machinery/atmospherics/components/binary/volume_pump/on/layer3 piping_layer = 3 - icon_state = "volpump_map-3" \ No newline at end of file + icon_state = "volpump_map-3" diff --git a/code/modules/atmospherics/machinery/components/components_base.dm b/code/modules/atmospherics/machinery/components/components_base.dm index a45728d51f..6f7d92c719 100644 --- a/code/modules/atmospherics/machinery/components/components_base.dm +++ b/code/modules/atmospherics/machinery/components/components_base.dm @@ -16,7 +16,7 @@ for(var/i in 1 to device_type) var/datum/gas_mixture/A = new - A.volume = 200 + A.set_volume(200) airs[i] = A // Iconnery @@ -117,7 +117,7 @@ var/times_lost = 0 for(var/i in 1 to device_type) var/datum/gas_mixture/air = airs[i] - lost += pressures*environment.volume/(air.temperature * R_IDEAL_GAS_EQUATION) + lost += pressures*environment.return_volume()/(air.return_temperature() * R_IDEAL_GAS_EQUATION) times_lost++ var/shared_loss = lost/times_lost diff --git a/code/modules/atmospherics/machinery/components/trinary_devices/filter.dm b/code/modules/atmospherics/machinery/components/trinary_devices/filter.dm index 78258dd10a..f49dee124e 100644 --- a/code/modules/atmospherics/machinery/components/trinary_devices/filter.dm +++ b/code/modules/atmospherics/machinery/components/trinary_devices/filter.dm @@ -94,7 +94,7 @@ //Calculate necessary moles to transfer using PV=nRT - var/transfer_ratio = transfer_rate/air1.volume + var/transfer_ratio = transfer_rate/air1.return_volume() //Actually transfer the gas @@ -111,14 +111,13 @@ else filtering = FALSE - if(filtering && removed.gases[filter_type]) + if(filtering && removed.get_moles(filter_type)) var/datum/gas_mixture/filtered_out = new - filtered_out.temperature = removed.temperature - filtered_out.gases[filter_type] = removed.gases[filter_type] + filtered_out.set_temperature(removed.return_temperature()) + filtered_out.set_moles(filter_type, removed.get_moles(filter_type)) - removed.gases[filter_type] = 0 - GAS_GARBAGE_COLLECT(removed.gases) + removed.set_moles(filter_type, 0) var/datum/gas_mixture/target = (air2.return_pressure() < 9000 ? air2 : air1) target.merge(filtered_out) @@ -280,4 +279,4 @@ critical_machine = TRUE /obj/machinery/atmospherics/components/trinary/filter/flipped/critical - critical_machine = TRUE \ No newline at end of file + critical_machine = TRUE diff --git a/code/modules/atmospherics/machinery/components/trinary_devices/mixer.dm b/code/modules/atmospherics/machinery/components/trinary_devices/mixer.dm index dcf0d09bee..a96a6efa4b 100644 --- a/code/modules/atmospherics/machinery/components/trinary_devices/mixer.dm +++ b/code/modules/atmospherics/machinery/components/trinary_devices/mixer.dm @@ -57,7 +57,7 @@ /obj/machinery/atmospherics/components/trinary/mixer/New() ..() var/datum/gas_mixture/air3 = airs[3] - air3.volume = 300 + air3.set_volume(300) airs[3] = air3 /obj/machinery/atmospherics/components/trinary/mixer/process_atmos() @@ -81,26 +81,26 @@ return //Calculate necessary moles to transfer using PV=nRT - var/general_transfer = (target_pressure - output_starting_pressure) * air3.volume / R_IDEAL_GAS_EQUATION + var/general_transfer = (target_pressure - output_starting_pressure) * air3.return_volume() / R_IDEAL_GAS_EQUATION - var/transfer_moles1 = air1.temperature ? node1_concentration * general_transfer / air1.temperature : 0 - var/transfer_moles2 = air2.temperature ? node2_concentration * general_transfer / air2.temperature : 0 + var/transfer_moles1 = air1.return_temperature() ? node1_concentration * general_transfer / air1.return_temperature() : 0 + var/transfer_moles2 = air2.return_temperature() ? node2_concentration * general_transfer / air2.return_temperature() : 0 var/air1_moles = air1.total_moles() var/air2_moles = air2.total_moles() if(!node2_concentration) - if(air1.temperature <= 0) + if(air1.return_temperature() <= 0) return transfer_moles1 = min(transfer_moles1, air1_moles) transfer_moles2 = 0 else if(!node1_concentration) - if(air2.temperature <= 0) + if(air2.return_temperature() <= 0) return transfer_moles2 = min(transfer_moles2, air2_moles) transfer_moles1 = 0 else - if(air1.temperature <= 0 || air2.temperature <= 0) + if(air1.return_temperature() <= 0 || air2.return_temperature() <= 0) return if((transfer_moles2 <= 0) || (transfer_moles1 <= 0)) return @@ -248,4 +248,4 @@ /obj/machinery/atmospherics/components/trinary/mixer/airmix/flipped/inverse node1_concentration = O2STANDARD - node2_concentration = N2STANDARD \ No newline at end of file + node2_concentration = N2STANDARD diff --git a/code/modules/atmospherics/machinery/components/unary_devices/cryo.dm b/code/modules/atmospherics/machinery/components/unary_devices/cryo.dm index 38042fe64d..881537cb0e 100644 --- a/code/modules/atmospherics/machinery/components/unary_devices/cryo.dm +++ b/code/modules/atmospherics/machinery/components/unary_devices/cryo.dm @@ -179,7 +179,7 @@ var/datum/gas_mixture/air1 = airs[1] - if(air1.gases.len) + if(air1.total_moles()) if(mob_occupant.bodytemperature < T0C) // Sleepytime. Why? More cryo magic. mob_occupant.Sleeping((mob_occupant.bodytemperature * sleep_factor) * 2000) mob_occupant.Unconscious((mob_occupant.bodytemperature * unconscious_factor) * 2000) @@ -187,8 +187,7 @@ if(reagent_transfer == 0) // Magically transfer reagents. Because cryo magic. beaker.reagents.trans_to(occupant, 1, efficiency * 0.25) // Transfer reagents. beaker.reagents.reaction(occupant, VAPOR) - air1.gases[/datum/gas/oxygen] -= max(0,air1.gases[/datum/gas/oxygen] - 2 / efficiency) //Let's use gas for this - GAS_GARBAGE_COLLECT(air1.gases) + air1.adjust_moles(/datum/gas/oxygen, -max(0,air1.get_moles(/datum/gas/oxygen) - 2 / efficiency)) //Let's use gas for this if(++reagent_transfer >= 10 * efficiency) // Throttle reagent transfer (higher efficiency will transfer the same amount but consume less from the beaker). reagent_transfer = 0 @@ -202,7 +201,7 @@ var/datum/gas_mixture/air1 = airs[1] - if(!nodes[1] || !airs[1] || !air1.gases.len || air1.gases[/datum/gas/oxygen] < 5) // Turn off if the machine won't work. + if(!nodes[1] || !airs[1] || air1.get_moles(/datum/gas/oxygen) < 5) // Turn off if the machine won't work. on = FALSE update_icon() return @@ -210,22 +209,21 @@ if(occupant) var/mob/living/mob_occupant = occupant var/cold_protection = 0 - var/temperature_delta = air1.temperature - mob_occupant.bodytemperature // The only semi-realistic thing here: share temperature between the cell and the occupant. + var/temperature_delta = air1.return_temperature() - mob_occupant.bodytemperature // The only semi-realistic thing here: share temperature between the cell and the occupant. if(ishuman(occupant)) var/mob/living/carbon/human/H = occupant - cold_protection = H.get_thermal_protection(air1.temperature, TRUE) + cold_protection = H.get_thermal_protection(air1.return_temperature(), TRUE) if(abs(temperature_delta) > 1) var/air_heat_capacity = air1.heat_capacity() var/heat = ((1 - cold_protection) * 0.1 + conduction_coefficient) * temperature_delta * (air_heat_capacity * heat_capacity / (air_heat_capacity + heat_capacity)) - air1.temperature = max(air1.temperature - heat / air_heat_capacity, TCMB) + air1.set_temperature(max(air1.return_temperature() - heat / air_heat_capacity, TCMB)) mob_occupant.adjust_bodytemperature(heat / heat_capacity, TCMB) - air1.gases[/datum/gas/oxygen] = max(0,air1.gases[/datum/gas/oxygen] - 0.5 / efficiency) // Magically consume gas? Why not, we run on cryo magic. - GAS_GARBAGE_COLLECT(air1.gases) + air1.set_temperature(max(air1.return_temperature() - 0.5 / efficiency)) // Magically consume gas? Why not, we run on cryo magic. /obj/machinery/atmospherics/components/unary/cryo_cell/power_change() ..() @@ -360,7 +358,7 @@ data["occupant"]["temperaturestatus"] = "bad" var/datum/gas_mixture/air1 = airs[1] - data["cellTemperature"] = round(air1.temperature, 1) + data["cellTemperature"] = round(air1.return_temperature(), 1) data["isBeakerLoaded"] = beaker ? TRUE : FALSE var/beakerContents = list() @@ -430,7 +428,7 @@ var/datum/gas_mixture/G = airs[1] if(G.total_moles() > 10) - return G.temperature + return G.return_temperature() return ..() /obj/machinery/atmospherics/components/unary/cryo_cell/default_change_direction_wrench(mob/user, obj/item/wrench/W) diff --git a/code/modules/atmospherics/machinery/components/unary_devices/heat_exchanger.dm b/code/modules/atmospherics/machinery/components/unary_devices/heat_exchanger.dm index a856ea1f3f..c0dfc5633e 100644 --- a/code/modules/atmospherics/machinery/components/unary_devices/heat_exchanger.dm +++ b/code/modules/atmospherics/machinery/components/unary_devices/heat_exchanger.dm @@ -59,18 +59,18 @@ var/other_air_heat_capacity = partner_air_contents.heat_capacity() var/combined_heat_capacity = other_air_heat_capacity + air_heat_capacity - var/old_temperature = air_contents.temperature - var/other_old_temperature = partner_air_contents.temperature + var/old_temperature = air_contents.return_temperature() + var/other_old_temperature = partner_air_contents.return_temperature() if(combined_heat_capacity > 0) - var/combined_energy = partner_air_contents.temperature*other_air_heat_capacity + air_heat_capacity*air_contents.temperature + var/combined_energy = partner_air_contents.return_temperature()*other_air_heat_capacity + air_heat_capacity*air_contents.return_temperature() var/new_temperature = combined_energy/combined_heat_capacity - air_contents.temperature = new_temperature - partner_air_contents.temperature = new_temperature + air_contents.set_temperature(new_temperature) + partner_air_contents.set_temperature(new_temperature) - if(abs(old_temperature-air_contents.temperature) > 1) + if(abs(old_temperature-air_contents.return_temperature()) > 1) update_parents() - if(abs(other_old_temperature-partner_air_contents.temperature) > 1) + if(abs(other_old_temperature-partner_air_contents.return_temperature()) > 1) partner.update_parents() diff --git a/code/modules/atmospherics/machinery/components/unary_devices/outlet_injector.dm b/code/modules/atmospherics/machinery/components/unary_devices/outlet_injector.dm index 05720583f9..5b87c518b1 100644 --- a/code/modules/atmospherics/machinery/components/unary_devices/outlet_injector.dm +++ b/code/modules/atmospherics/machinery/components/unary_devices/outlet_injector.dm @@ -52,8 +52,8 @@ var/datum/gas_mixture/air_contents = airs[1] - if(air_contents.temperature > 0) - var/transfer_moles = (air_contents.return_pressure())*volume_rate/(air_contents.temperature * R_IDEAL_GAS_EQUATION) + if(air_contents.return_temperature() > 0) + var/transfer_moles = (air_contents.return_pressure())*volume_rate/(air_contents.return_temperature() * R_IDEAL_GAS_EQUATION) var/datum/gas_mixture/removed = air_contents.remove(transfer_moles) @@ -71,8 +71,8 @@ injecting = 1 - if(air_contents.temperature > 0) - var/transfer_moles = (air_contents.return_pressure())*volume_rate/(air_contents.temperature * R_IDEAL_GAS_EQUATION) + if(air_contents.return_temperature() > 0) + var/transfer_moles = (air_contents.return_pressure())*volume_rate/(air_contents.return_temperature() * R_IDEAL_GAS_EQUATION) var/datum/gas_mixture/removed = air_contents.remove(transfer_moles) loc.assume_air(removed) update_parents() @@ -123,7 +123,7 @@ if("set_volume_rate" in signal.data) var/number = text2num(signal.data["set_volume_rate"]) var/datum/gas_mixture/air_contents = airs[1] - volume_rate = clamp(number, 0, air_contents.volume) + volume_rate = clamp(number, 0, air_contents.return_volume()) if("status" in signal.data) spawn(2) @@ -241,4 +241,4 @@ id = ATMOS_GAS_MONITOR_INPUT_INCINERATOR /obj/machinery/atmospherics/components/unary/outlet_injector/atmos/toxins_mixing_input name = "toxins mixing input injector" - id = ATMOS_GAS_MONITOR_INPUT_TOXINS_LAB \ No newline at end of file + id = ATMOS_GAS_MONITOR_INPUT_TOXINS_LAB diff --git a/code/modules/atmospherics/machinery/components/unary_devices/passive_vent.dm b/code/modules/atmospherics/machinery/components/unary_devices/passive_vent.dm index a113484d20..3f5bb818ce 100644 --- a/code/modules/atmospherics/machinery/components/unary_devices/passive_vent.dm +++ b/code/modules/atmospherics/machinery/components/unary_devices/passive_vent.dm @@ -30,14 +30,14 @@ if(pressure_delta > 0.5) if(external_pressure < internal_pressure) - var/air_temperature = (external.temperature > 0) ? external.temperature : internal.temperature - var/transfer_moles = (pressure_delta * external.volume) / (air_temperature * R_IDEAL_GAS_EQUATION) + var/air_temperature = (external.return_temperature() > 0) ? external.return_temperature() : internal.return_temperature() + var/transfer_moles = (pressure_delta * external.return_volume()) / (air_temperature * R_IDEAL_GAS_EQUATION) var/datum/gas_mixture/removed = internal.remove(transfer_moles) external.merge(removed) else - var/air_temperature = (internal.temperature > 0) ? internal.temperature : external.temperature - var/transfer_moles = (pressure_delta * internal.volume) / (air_temperature * R_IDEAL_GAS_EQUATION) - transfer_moles = min(transfer_moles, external.total_moles() * internal.volume / external.volume) + var/air_temperature = (internal.return_temperature() > 0) ? internal.return_temperature() : external.return_temperature() + var/transfer_moles = (pressure_delta * internal.return_volume()) / (air_temperature * R_IDEAL_GAS_EQUATION) + transfer_moles = min(transfer_moles, external.total_moles() * internal.return_volume() / external.return_volume()) var/datum/gas_mixture/removed = external.remove(transfer_moles) if(isnull(removed)) return diff --git a/code/modules/atmospherics/machinery/components/unary_devices/portables_connector.dm b/code/modules/atmospherics/machinery/components/unary_devices/portables_connector.dm index 81ca14a828..6188c919ac 100644 --- a/code/modules/atmospherics/machinery/components/unary_devices/portables_connector.dm +++ b/code/modules/atmospherics/machinery/components/unary_devices/portables_connector.dm @@ -16,7 +16,7 @@ ..() var/datum/gas_mixture/air_contents = airs[1] - air_contents.volume = 0 + air_contents.set_volume(0) /obj/machinery/atmospherics/components/unary/portables_connector/Destroy() if(connected_device) @@ -64,4 +64,4 @@ /obj/machinery/atmospherics/components/unary/portables_connector/visible/layer3 piping_layer = 3 - icon_state = "connector_map-3" \ No newline at end of file + icon_state = "connector_map-3" diff --git a/code/modules/atmospherics/machinery/components/unary_devices/relief_valve.dm b/code/modules/atmospherics/machinery/components/unary_devices/relief_valve.dm index 1d8b875528..0893d2b9e6 100644 --- a/code/modules/atmospherics/machinery/components/unary_devices/relief_valve.dm +++ b/code/modules/atmospherics/machinery/components/unary_devices/relief_valve.dm @@ -49,10 +49,10 @@ else if(!opened && our_pressure >= open_pressure) opened = TRUE update_icon_nopipes() - if(opened && air_contents.temperature > 0) + if(opened && air_contents.return_temperature() > 0) var/datum/gas_mixture/environment = loc.return_air() var/pressure_delta = our_pressure - environment.return_pressure() - var/transfer_moles = pressure_delta*200/(air_contents.temperature * R_IDEAL_GAS_EQUATION) + var/transfer_moles = pressure_delta*200/(air_contents.return_temperature() * R_IDEAL_GAS_EQUATION) if(transfer_moles > 0) var/datum/gas_mixture/removed = air_contents.remove(transfer_moles) diff --git a/code/modules/atmospherics/machinery/components/unary_devices/tank.dm b/code/modules/atmospherics/machinery/components/unary_devices/tank.dm index c1bd59f49b..1ed9c17d82 100644 --- a/code/modules/atmospherics/machinery/components/unary_devices/tank.dm +++ b/code/modules/atmospherics/machinery/components/unary_devices/tank.dm @@ -1,4 +1,4 @@ -#define AIR_CONTENTS ((25*ONE_ATMOSPHERE)*(air_contents.volume)/(R_IDEAL_GAS_EQUATION*air_contents.temperature)) +#define AIR_CONTENTS ((25*ONE_ATMOSPHERE)*(air_contents.return_volume())/(R_IDEAL_GAS_EQUATION*air_contents.return_temperature())) /obj/machinery/atmospherics/components/unary/tank icon = 'icons/obj/atmospherics/pipes/pressure_tank.dmi' icon_state = "generic" @@ -14,10 +14,10 @@ /obj/machinery/atmospherics/components/unary/tank/New() ..() var/datum/gas_mixture/air_contents = airs[1] - air_contents.volume = volume - air_contents.temperature = T20C + air_contents.set_volume(volume) + air_contents.set_temperature(T20C) if(gas_type) - air_contents.gases[gas_type] = AIR_CONTENTS + air_contents.set_moles(AIR_CONTENTS) name = "[name] ([GLOB.meta_gas_names[gas_type]])" /obj/machinery/atmospherics/components/unary/tank/air @@ -27,8 +27,8 @@ /obj/machinery/atmospherics/components/unary/tank/air/New() ..() var/datum/gas_mixture/air_contents = airs[1] - air_contents.gases[/datum/gas/oxygen] = AIR_CONTENTS * 0.2 - air_contents.gases[/datum/gas/nitrogen] = AIR_CONTENTS * 0.8 + air_contents.set_moles(/datum/gas/oxygen, AIR_CONTENTS * 0.2) + air_contents.set_moles(/datum/gas/nitrogen, AIR_CONTENTS * 0.8) /obj/machinery/atmospherics/components/unary/tank/carbon_dioxide gas_type = /datum/gas/carbon_dioxide diff --git a/code/modules/atmospherics/machinery/components/unary_devices/thermomachine.dm b/code/modules/atmospherics/machinery/components/unary_devices/thermomachine.dm index dddfdf08c1..69340648d5 100644 --- a/code/modules/atmospherics/machinery/components/unary_devices/thermomachine.dm +++ b/code/modules/atmospherics/machinery/components/unary_devices/thermomachine.dm @@ -73,13 +73,13 @@ var/air_heat_capacity = air_contents.heat_capacity() var/combined_heat_capacity = heat_capacity + air_heat_capacity - var/old_temperature = air_contents.temperature + var/old_temperature = air_contents.return_temperature() if(combined_heat_capacity > 0) - var/combined_energy = heat_capacity * target_temperature + air_heat_capacity * air_contents.temperature - air_contents.temperature = combined_energy/combined_heat_capacity + var/combined_energy = heat_capacity * target_temperature + air_heat_capacity * air_contents.return_temperature() + air_contents.set_temperature(combined_energy/combined_heat_capacity) - var/temperature_delta= abs(old_temperature - air_contents.temperature) + var/temperature_delta= abs(old_temperature - air_contents.return_temperature()) if(temperature_delta > 1) active_power_usage = (heat_capacity * temperature_delta) / 10 + idle_power_usage update_parents() @@ -141,7 +141,7 @@ data["initial"] = initial(target_temperature) var/datum/gas_mixture/air1 = airs[1] - data["temperature"] = air1.temperature + data["temperature"] = air1.return_temperature() data["pressure"] = air1.return_pressure() return data diff --git a/code/modules/atmospherics/machinery/components/unary_devices/vent_pump.dm b/code/modules/atmospherics/machinery/components/unary_devices/vent_pump.dm index 9788bcb4ee..b6534f5cf7 100644 --- a/code/modules/atmospherics/machinery/components/unary_devices/vent_pump.dm +++ b/code/modules/atmospherics/machinery/components/unary_devices/vent_pump.dm @@ -104,8 +104,8 @@ pressure_delta = min(pressure_delta, (air_contents.return_pressure() - internal_pressure_bound)) if(pressure_delta > 0) - if(air_contents.temperature > 0) - var/transfer_moles = pressure_delta*environment.volume/(air_contents.temperature * R_IDEAL_GAS_EQUATION) + if(air_contents.return_temperature() > 0) + var/transfer_moles = pressure_delta*environment.return_volume()/(air_contents.return_temperature() * R_IDEAL_GAS_EQUATION) var/datum/gas_mixture/removed = air_contents.remove(transfer_moles) @@ -119,8 +119,8 @@ if(pressure_checks&INT_BOUND) pressure_delta = min(pressure_delta, (internal_pressure_bound - air_contents.return_pressure())) - if(pressure_delta > 0 && environment.temperature > 0) - var/transfer_moles = pressure_delta * air_contents.volume / (environment.temperature * R_IDEAL_GAS_EQUATION) + if(pressure_delta > 0 && environment.return_temperature() > 0) + var/transfer_moles = pressure_delta * air_contents.return_volume() / (environment.return_temperature() * R_IDEAL_GAS_EQUATION) var/datum/gas_mixture/removed = loc.remove_air(transfer_moles) if (isnull(removed)) // in space @@ -295,7 +295,7 @@ /obj/machinery/atmospherics/components/unary/vent_pump/high_volume/New() ..() var/datum/gas_mixture/air_contents = airs[1] - air_contents.volume = 1000 + air_contents.set_volume(1000) // mapping diff --git a/code/modules/atmospherics/machinery/components/unary_devices/vent_scrubber.dm b/code/modules/atmospherics/machinery/components/unary_devices/vent_scrubber.dm index 10eac9c717..025c9734ca 100644 --- a/code/modules/atmospherics/machinery/components/unary_devices/vent_scrubber.dm +++ b/code/modules/atmospherics/machinery/components/unary_devices/vent_scrubber.dm @@ -149,43 +149,29 @@ return FALSE var/datum/gas_mixture/environment = tile.return_air() var/datum/gas_mixture/air_contents = airs[1] - var/list/env_gases = environment.gases if(air_contents.return_pressure() >= 50*ONE_ATMOSPHERE) return FALSE if(scrubbing & SCRUBBING) - if(length(env_gases & filter_types)) - var/transfer_moles = min(1, volume_rate/environment.volume)*environment.total_moles() + var/transfer_moles = min(1, volume_rate/environment.return_volume())*environment.total_moles() - //Take a gas sample - var/datum/gas_mixture/removed = tile.remove_air(transfer_moles) + //Take a gas sample + var/datum/gas_mixture/removed = tile.remove_air(transfer_moles) - //Nothing left to remove from the tile - if(isnull(removed)) - return FALSE + //Nothing left to remove from the tile + if(isnull(removed)) + return FALSE - var/list/removed_gases = removed.gases + removed.scrub_into(air_contents, filter_types) - //Filter it - var/datum/gas_mixture/filtered_out = new - var/list/filtered_gases = filtered_out.gases - filtered_out.temperature = removed.temperature - - for(var/gas in filter_types & removed_gases) - filtered_gases[gas] = removed_gases[gas] - removed_gases[gas] = 0 - - GAS_GARBAGE_COLLECT(removed.gases) - - //Remix the resulting gases - air_contents.merge(filtered_out) - tile.assume_air(removed) - tile.air_update_turf() + //Remix the resulting gases + tile.assume_air(removed) + tile.air_update_turf() else //Just siphoning all air - var/transfer_moles = environment.total_moles()*(volume_rate/environment.volume) + var/transfer_moles = environment.total_moles()*(volume_rate/environment.return_volume()) var/datum/gas_mixture/removed = tile.remove_air(transfer_moles) diff --git a/code/modules/atmospherics/machinery/datum_pipeline.dm b/code/modules/atmospherics/machinery/datum_pipeline.dm index 565bbb7b3c..098df67321 100644 --- a/code/modules/atmospherics/machinery/datum_pipeline.dm +++ b/code/modules/atmospherics/machinery/datum_pipeline.dm @@ -15,7 +15,7 @@ /datum/pipeline/Destroy() SSair.networks -= src - if(air && air.volume) + if(air && air.return_volume()) temporarily_store_air() for(var/obj/machinery/atmospherics/pipe/P in members) P.parent = null @@ -76,7 +76,7 @@ possible_expansions -= borderline - air.volume = volume + air.set_volume(volume) /datum/pipeline/proc/addMachineryMember(obj/machinery/atmospherics/components/C) other_atmosmch |= C @@ -99,7 +99,7 @@ merge(E) if(!members.Find(P)) members += P - air.volume += P.volume + air.set_volume(air.return_volume() + P.volume) else A.setPipenet(src, N) addMachineryMember(A) @@ -107,7 +107,7 @@ /datum/pipeline/proc/merge(datum/pipeline/E) if(E == src) return - air.volume += E.air.volume + air.set_volume(air.return_volume() + E.air.return_volume()) members.Add(E.members) for(var/obj/machinery/atmospherics/pipe/S in E.members) S.parent = src @@ -139,18 +139,16 @@ for(var/obj/machinery/atmospherics/pipe/member in members) member.air_temporary = new - member.air_temporary.volume = member.volume + member.air_temporary.set_volume(member.volume) member.air_temporary.copy_from(air) - var/member_gases = member.air_temporary.gases - for(var/id in member_gases) - member_gases[id] *= member.volume/air.volume + member.air_temporary.multiply(member.volume/air.return_volume()) - member.air_temporary.temperature = air.temperature + member.air_temporary.set_temperature(air.return_temperature()) /datum/pipeline/proc/temperature_interact(turf/target, share_volume, thermal_conductivity) var/total_heat_capacity = air.heat_capacity() - var/partial_heat_capacity = total_heat_capacity*(share_volume/air.volume) + var/partial_heat_capacity = total_heat_capacity*(share_volume/air.return_volume()) var/target_temperature var/target_heat_capacity @@ -163,19 +161,19 @@ if(modeled_location.blocks_air) if((modeled_location.heat_capacity>0) && (partial_heat_capacity>0)) - var/delta_temperature = air.temperature - target_temperature + var/delta_temperature = air.return_temperature() - target_temperature var/heat = thermal_conductivity*delta_temperature* \ (partial_heat_capacity*target_heat_capacity/(partial_heat_capacity+target_heat_capacity)) - air.temperature -= heat/total_heat_capacity + air.set_temperature(air.return_temperature() - heat/total_heat_capacity) modeled_location.TakeTemperature(heat/target_heat_capacity) else var/delta_temperature = 0 var/sharer_heat_capacity = 0 - delta_temperature = (air.temperature - target_temperature) + delta_temperature = (air.return_temperature() - target_temperature) sharer_heat_capacity = target_heat_capacity var/self_temperature_delta = 0 @@ -190,18 +188,18 @@ else return 1 - air.temperature += self_temperature_delta + air.set_temperature(air.return_temperature() + self_temperature_delta) modeled_location.TakeTemperature(sharer_temperature_delta) else if((target.heat_capacity>0) && (partial_heat_capacity>0)) - var/delta_temperature = air.temperature - target.temperature + var/delta_temperature = air.return_temperature() - target.return_temperature() var/heat = thermal_conductivity*delta_temperature* \ (partial_heat_capacity*target.heat_capacity/(partial_heat_capacity+target.heat_capacity)) - air.temperature -= heat/total_heat_capacity + air.set_temperature(air.return_temperature() - heat/total_heat_capacity) update = TRUE /datum/pipeline/proc/return_air() @@ -242,20 +240,18 @@ for(var/i in GL) var/datum/gas_mixture/G = i - total_gas_mixture.volume += G.volume + total_gas_mixture.set_volume(total_gas_mixture.return_volume() + G.return_volume()) total_gas_mixture.merge(G) - total_thermal_energy += THERMAL_ENERGY(G) + total_thermal_energy += G.thermal_energy() total_heat_capacity += G.heat_capacity() - total_gas_mixture.temperature = total_heat_capacity ? total_thermal_energy/total_heat_capacity : 0 + total_gas_mixture.set_temperature(total_heat_capacity ? total_thermal_energy/total_heat_capacity : 0) - if(total_gas_mixture.volume > 0) + if(total_gas_mixture.return_volume() > 0) //Update individual gas_mixtures by volume ratio for(var/i in GL) var/datum/gas_mixture/G = i G.copy_from(total_gas_mixture) - var/list/G_gases = G.gases - for(var/id in G_gases) - G_gases[id] *= G.volume/total_gas_mixture.volume + G.multiply(G.return_volume()/total_gas_mixture.return_volume()) diff --git a/code/modules/atmospherics/machinery/other/meter.dm b/code/modules/atmospherics/machinery/other/meter.dm index fab70cc168..c17c93ab95 100644 --- a/code/modules/atmospherics/machinery/other/meter.dm +++ b/code/modules/atmospherics/machinery/other/meter.dm @@ -103,7 +103,7 @@ if (target) var/datum/gas_mixture/environment = target.return_air() if(environment) - . = "The pressure gauge reads [round(environment.return_pressure(), 0.01)] kPa; [round(environment.temperature,0.01)] K ([round(environment.temperature-T0C,0.01)]°C)." + . = "The pressure gauge reads [round(environment.return_pressure(), 0.01)] kPa; [round(environment.return_temperature(),0.01)] K ([round(environment.return_temperature()-T0C,0.01)]°C)." else . = "The sensor error light is blinking." else diff --git a/code/modules/atmospherics/machinery/other/miner.dm b/code/modules/atmospherics/machinery/other/miner.dm index c90d388a1d..1842211fd2 100644 --- a/code/modules/atmospherics/machinery/other/miner.dm +++ b/code/modules/atmospherics/machinery/other/miner.dm @@ -131,8 +131,8 @@ if(!isopenturf(O)) return FALSE var/datum/gas_mixture/merger = new - merger.gases[spawn_id] = (spawn_mol) - merger.temperature = spawn_temp + merger.set_moles(spawn_id, spawn_mol) + merger.set_temperature(spawn_temp) O.assume_air(merger) O.air_update_turf(TRUE) diff --git a/code/modules/atmospherics/machinery/pipes/heat_exchange/he_pipes.dm b/code/modules/atmospherics/machinery/pipes/heat_exchange/he_pipes.dm index 4da053d3c8..7c170f8afc 100644 --- a/code/modules/atmospherics/machinery/pipes/heat_exchange/he_pipes.dm +++ b/code/modules/atmospherics/machinery/pipes/heat_exchange/he_pipes.dm @@ -28,14 +28,14 @@ if(islava(T)) environment_temperature = 5000 else if(T.blocks_air) - environment_temperature = T.temperature + environment_temperature = T.return_temperature() else var/turf/open/OT = T environment_temperature = OT.GetTemperature() else - environment_temperature = T.temperature + environment_temperature = T.return_temperature() - if(abs(environment_temperature-pipe_air.temperature) > minimum_temperature_difference) + if(abs(environment_temperature-pipe_air.return_temperature()) > minimum_temperature_difference) parent.temperature_interact(T, volume, thermal_conductivity) @@ -44,11 +44,11 @@ var/hc = pipe_air.heat_capacity() var/mob/living/heat_source = buckled_mobs[1] //Best guess-estimate of the total bodytemperature of all the mobs, since they share the same environment it's ~ok~ to guess like this - var/avg_temp = (pipe_air.temperature * hc + (heat_source.bodytemperature * buckled_mobs.len) * 3500) / (hc + (buckled_mobs ? buckled_mobs.len * 3500 : 0)) + var/avg_temp = (pipe_air.return_temperature() * hc + (heat_source.bodytemperature * buckled_mobs.len) * 3500) / (hc + (buckled_mobs ? buckled_mobs.len * 3500 : 0)) for(var/m in buckled_mobs) var/mob/living/L = m L.bodytemperature = avg_temp - pipe_air.temperature = avg_temp + pipe_air.set_temperature(avg_temp) /obj/machinery/atmospherics/pipe/heat_exchanging/process() if(!parent) @@ -57,9 +57,9 @@ var/datum/gas_mixture/pipe_air = return_air() //Heat causes pipe to glow - if(pipe_air.temperature && (icon_temperature > 500 || pipe_air.temperature > 500)) //glow starts at 500K - if(abs(pipe_air.temperature - icon_temperature) > 10) - icon_temperature = pipe_air.temperature + if(pipe_air.return_temperature() && (icon_temperature > 500 || pipe_air.return_temperature() > 500)) //glow starts at 500K + if(abs(pipe_air.return_temperature() - icon_temperature) > 10) + icon_temperature = pipe_air.return_temperature() var/h_r = heat2colour_r(icon_temperature) var/h_g = heat2colour_g(icon_temperature) @@ -76,7 +76,7 @@ //burn any mobs buckled based on temperature if(has_buckled_mobs()) var/heat_limit = 1000 - if(pipe_air.temperature > heat_limit + 1) + if(pipe_air.return_temperature() > heat_limit + 1) for(var/m in buckled_mobs) var/mob/living/buckled_mob = m - buckled_mob.apply_damage(4 * log(pipe_air.temperature - heat_limit), BURN, BODY_ZONE_CHEST) + buckled_mob.apply_damage(4 * log(pipe_air.return_temperature() - heat_limit), BURN, BODY_ZONE_CHEST) diff --git a/code/modules/atmospherics/machinery/portable/canister.dm b/code/modules/atmospherics/machinery/portable/canister.dm index 03463ff0f7..2e48aa90d9 100644 --- a/code/modules/atmospherics/machinery/portable/canister.dm +++ b/code/modules/atmospherics/machinery/portable/canister.dm @@ -200,14 +200,14 @@ /obj/machinery/portable_atmospherics/canister/proc/create_gas() if(gas_type) if(starter_temp) - air_contents.temperature = starter_temp - air_contents.gases[gas_type] = (maximum_pressure * filled) * air_contents.volume / (R_IDEAL_GAS_EQUATION * air_contents.temperature) + air_contents.set_temperature(starter_temp) + air_contents.set_moles(gas_type,(maximum_pressure * filled) * air_contents.return_volume() / (R_IDEAL_GAS_EQUATION * air_contents.return_temperature())) if(starter_temp) - air_contents.temperature = starter_temp + air_contents.set_temperature(starter_temp) /obj/machinery/portable_atmospherics/canister/air/create_gas() - air_contents.gases[/datum/gas/oxygen] = (O2STANDARD * maximum_pressure * filled) * air_contents.volume / (R_IDEAL_GAS_EQUATION * air_contents.temperature) - air_contents.gases[/datum/gas/nitrogen] = (N2STANDARD * maximum_pressure * filled) * air_contents.volume / (R_IDEAL_GAS_EQUATION * air_contents.temperature) + air_contents.set_moles(/datum/gas/oxygen, (O2STANDARD * maximum_pressure * filled) * air_contents.return_volume() / (R_IDEAL_GAS_EQUATION * air_contents.return_temperature())) + air_contents.set_moles(/datum/gas/nitrogen, (N2STANDARD * maximum_pressure * filled) * air_contents.return_volume() / (R_IDEAL_GAS_EQUATION * air_contents.return_temperature())) /obj/machinery/portable_atmospherics/canister/update_icon_state() if(stat & BROKEN) @@ -396,8 +396,8 @@ logmsg = "Valve was opened by [key_name(usr)], starting a transfer into \the [holding || "air"].
" if(!holding) var/list/danger = list() - for(var/id in air_contents.gases) - var/gas = air_contents.gases[id] + for(var/id in air_contents.get_gases()) + var/gas = air_contents.get_moles(id) if(!GLOB.meta_gas_dangers[id]) continue if(gas > (GLOB.meta_gas_visibility[id] || MOLES_GAS_VISIBLE)) //if moles_visible is undefined, default to default visibility diff --git a/code/modules/atmospherics/machinery/portable/portable_atmospherics.dm b/code/modules/atmospherics/machinery/portable/portable_atmospherics.dm index 8bf0554070..6ae032fae2 100644 --- a/code/modules/atmospherics/machinery/portable/portable_atmospherics.dm +++ b/code/modules/atmospherics/machinery/portable/portable_atmospherics.dm @@ -19,8 +19,8 @@ SSair.atmos_machinery += src air_contents = new - air_contents.volume = volume - air_contents.temperature = T20C + air_contents.set_volume(volume) + air_contents.set_temperature(T20C) return 1 diff --git a/code/modules/atmospherics/machinery/portable/pump.dm b/code/modules/atmospherics/machinery/portable/pump.dm index 377e9285e3..4ab934a1c8 100644 --- a/code/modules/atmospherics/machinery/portable/pump.dm +++ b/code/modules/atmospherics/machinery/portable/pump.dm @@ -115,8 +115,8 @@ if("power") on = !on if(on && !holding) - var/plasma = air_contents.gases[/datum/gas/plasma] - var/n2o = air_contents.gases[/datum/gas/nitrous_oxide] + var/plasma = air_contents.get_moles(/datum/gas/plasma) + var/n2o = air_contents.get_moles(/datum/gas/nitrous_oxide) if(n2o || plasma) message_admins("[ADMIN_LOOKUPFLW(usr)] turned on a pump that contains [n2o ? "N2O" : ""][n2o && plasma ? " & " : ""][plasma ? "Plasma" : ""] at [ADMIN_VERBOSEJMP(src)]") log_admin("[key_name(usr)] turned on a pump that contains [n2o ? "N2O" : ""][n2o && plasma ? " & " : ""][plasma ? "Plasma" : ""] at [AREACOORD(src)]") diff --git a/code/modules/atmospherics/machinery/portable/scrubber.dm b/code/modules/atmospherics/machinery/portable/scrubber.dm index 3dfce7c1bf..6589e601a2 100644 --- a/code/modules/atmospherics/machinery/portable/scrubber.dm +++ b/code/modules/atmospherics/machinery/portable/scrubber.dm @@ -40,20 +40,13 @@ scrub(T.return_air()) /obj/machinery/portable_atmospherics/scrubber/proc/scrub(var/datum/gas_mixture/mixture) - var/transfer_moles = min(1, volume_rate / mixture.volume) * mixture.total_moles() + var/transfer_moles = min(1, volume_rate / mixture.return_volume()) * mixture.total_moles() var/datum/gas_mixture/filtering = mixture.remove(transfer_moles) // Remove part of the mixture to filter. - var/datum/gas_mixture/filtered = new if(!filtering) return - filtered.temperature = filtering.temperature - for(var/gas in filtering.gases & scrubbing) - filtered.gases[gas] = filtering.gases[gas] // Shuffle the "bad" gasses to the filtered mixture. - filtering.gases[gas] = 0 - GAS_GARBAGE_COLLECT(filtering.gases) - - air_contents.merge(filtered) // Store filtered out gasses. + filtering.scrub_into(air_contents,scrubbing) mixture.merge(filtering) // Returned the cleaned gas. if(!holding) air_update_turf() diff --git a/code/modules/cargo/bounties/engineering.dm b/code/modules/cargo/bounties/engineering.dm index 99e6aa2bdc..b84fd2ca2c 100644 --- a/code/modules/cargo/bounties/engineering.dm +++ b/code/modules/cargo/bounties/engineering.dm @@ -10,9 +10,7 @@ if(!..()) return FALSE var/obj/item/tank/T = O - if(!T.air_contents.gases[gas_type]) - return FALSE - return T.air_contents.gases[gas_type] >= moles_required + return T.air_contents.get_moles(gas_type) >= moles_required //datum/bounty/item/engineering/gas/nitryl_tank // name = "Full Tank of Nitryl" diff --git a/code/modules/cargo/exports/large_objects.dm b/code/modules/cargo/exports/large_objects.dm index b7bdcb1f59..7986a78461 100644 --- a/code/modules/cargo/exports/large_objects.dm +++ b/code/modules/cargo/exports/large_objects.dm @@ -169,15 +169,13 @@ /datum/export/large/gas_canister/get_cost(obj/O) var/obj/machinery/portable_atmospherics/canister/C = O var/worth = 10 - var/gases = C.air_contents.gases - - worth += gases[/datum/gas/bz]*4 - worth += gases[/datum/gas/stimulum]*25 - worth += gases[/datum/gas/hypernoblium]*1000 - worth += gases[/datum/gas/miasma]*4 - worth += gases[/datum/gas/tritium]*7 - worth += gases[/datum/gas/pluoxium]*6 - worth += gases[/datum/gas/nitryl]*30 + worth += C.air_contents.get_moles(/datum/gas/bz)*4 + worth += C.air_contents.get_moles(/datum/gas/stimulum)*25 + worth += C.air_contents.get_moles(/datum/gas/hypernoblium)*1000 + worth += C.air_contents.get_moles(/datum/gas/miasma)*4 + worth += C.air_contents.get_moles(/datum/gas/tritium)*7 + worth += C.air_contents.get_moles(/datum/gas/pluoxium)*6 + worth += C.air_contents.get_moles(/datum/gas/nitryl)*30 return worth diff --git a/code/modules/events/spacevine.dm b/code/modules/events/spacevine.dm index 60f2aef629..f071ab3f9c 100644 --- a/code/modules/events/spacevine.dm +++ b/code/modules/events/spacevine.dm @@ -170,10 +170,7 @@ var/turf/open/floor/T = holder.loc if(istype(T)) var/datum/gas_mixture/GM = T.air - if(!GM.gases[/datum/gas/oxygen]) - return - GM.gases[/datum/gas/oxygen] = max(GM.gases[/datum/gas/oxygen] - severity * holder.energy, 0) - GAS_GARBAGE_COLLECT(GM.gases) + GM.set_moles(/datum/gas/oxygen, max(GM.get_moles(/datum/gas/oxygen) - severity * holder.energy, 0)) /datum/spacevine_mutation/nitro_eater name = "nitrogen consuming" @@ -185,10 +182,7 @@ var/turf/open/floor/T = holder.loc if(istype(T)) var/datum/gas_mixture/GM = T.air - if(!GM.gases[/datum/gas/nitrogen]) - return - GM.gases[/datum/gas/nitrogen] = max(GM.gases[/datum/gas/nitrogen] - severity * holder.energy, 0) - GAS_GARBAGE_COLLECT(GM.gases) + GM.set_moles(/datum/gas/nitrogen, max(GM.get_moles(/datum/gas/nitrogen) - severity * holder.energy, 0)) /datum/spacevine_mutation/carbondioxide_eater name = "CO2 consuming" @@ -200,10 +194,7 @@ var/turf/open/floor/T = holder.loc if(istype(T)) var/datum/gas_mixture/GM = T.air - if(!GM.gases[/datum/gas/carbon_dioxide]) - return - GM.gases[/datum/gas/carbon_dioxide] = max(GM.gases[/datum/gas/carbon_dioxide] - severity * holder.energy, 0) - GAS_GARBAGE_COLLECT(GM.gases) + GM.set_moles(/datum/gas/carbon_dioxide, max(GM.get_moles(/datum/gas/carbon_dioxide) - severity * holder.energy, 0)) /datum/spacevine_mutation/plasma_eater name = "toxins consuming" @@ -215,10 +206,7 @@ var/turf/open/floor/T = holder.loc if(istype(T)) var/datum/gas_mixture/GM = T.air - if(!GM.gases[/datum/gas/plasma]) - return - GM.gases[/datum/gas/plasma] = max(GM.gases[/datum/gas/plasma] - severity * holder.energy, 0) - GAS_GARBAGE_COLLECT(GM.gases) + GM.set_moles(/datum/gas/plasma, max(GM.get_moles(/datum/gas/plasma) - severity * holder.energy, 0)) /datum/spacevine_mutation/thorns name = "thorny" @@ -541,4 +529,4 @@ var/mob/living/M = A if(("vines" in M.faction) || ("plants" in M.faction)) return TRUE - return FALSE \ No newline at end of file + return FALSE diff --git a/code/modules/hydroponics/grown/misc.dm b/code/modules/hydroponics/grown/misc.dm index f356ed7b68..097d784592 100644 --- a/code/modules/hydroponics/grown/misc.dm +++ b/code/modules/hydroponics/grown/misc.dm @@ -57,8 +57,8 @@ return var/datum/gas_mixture/stank = new - stank.gases[/datum/gas/miasma] = (yield + 6)*7*0.02 // this process is only being called about 2/7 as much as corpses so this is 12-32 times a corpses - stank.temperature = T20C // without this the room would eventually freeze and miasma mining would be easier + stank.adjust_moles(/datum/gas/miasma,(yield + 6)*7*0.02) // this process is only being called about 2/7 as much as corpses so this is 12-32 times a corpses + stank.set_temperature(T20C) // without this the room would eventually freeze and miasma mining would be easier T.assume_air(stank) T.air_update_turf() diff --git a/code/modules/hydroponics/grown/towercap.dm b/code/modules/hydroponics/grown/towercap.dm index a18dbe165d..28ae5f4b69 100644 --- a/code/modules/hydroponics/grown/towercap.dm +++ b/code/modules/hydroponics/grown/towercap.dm @@ -226,8 +226,8 @@ if(isopenturf(loc)) var/turf/open/O = loc if(O.air) - var/loc_gases = O.air.gases - if(loc_gases[/datum/gas/oxygen] > 13) + var/datum/gas_mixture/loc_air = O.air + if(loc_air.get_moles(/datum/gas/oxygen) > 13) return TRUE return FALSE diff --git a/code/modules/integrated_electronics/subtypes/atmospherics.dm b/code/modules/integrated_electronics/subtypes/atmospherics.dm index 219e30c57f..d9a18bc509 100644 --- a/code/modules/integrated_electronics/subtypes/atmospherics.dm +++ b/code/modules/integrated_electronics/subtypes/atmospherics.dm @@ -125,12 +125,12 @@ return // Negative Kelvin temperatures should never happen and if they do, normalize them - if(source_air.temperature < TCMB) - source_air.temperature = TCMB + if(source_air.return_temperature() < TCMB) + source_air.set_temperature(TCMB) var/pressure_delta = target_pressure - target_air.return_pressure() if(pressure_delta > 0.1) - var/transfer_moles = (pressure_delta*target_air.volume/(source_air.temperature * R_IDEAL_GAS_EQUATION))*PUMP_EFFICIENCY + var/transfer_moles = (pressure_delta*target_air.return_volume()/(source_air.return_temperature() * R_IDEAL_GAS_EQUATION))*PUMP_EFFICIENCY var/datum/gas_mixture/removed = source_air.remove(transfer_moles) target_air.merge(removed) @@ -171,14 +171,14 @@ return // Negative Kelvin temperatures should never happen and if they do, normalize them - if(source_air.temperature < TCMB) - source_air.temperature = TCMB + if(source_air.return_temperature() < TCMB) + source_air.set_temperature(TCMB) if((source_air.return_pressure() < 0.01) || (target_air.return_pressure() >= PUMP_MAX_PRESSURE)) return //The second part of the min caps the pressure built by the volume pumps to the max pump pressure - var/transfer_ratio = min(transfer_rate,target_air.volume*PUMP_MAX_PRESSURE/source_air.return_pressure())/source_air.volume + var/transfer_ratio = min(transfer_rate,target_air.return_volume()*PUMP_MAX_PRESSURE/source_air.return_pressure())/source_air.return_volume() var/datum/gas_mixture/removed = source_air.remove_ratio(transfer_ratio * PUMP_EFFICIENCY) @@ -351,10 +351,10 @@ obj/item/integrated_circuit/atmospherics/connector/portableConnectorReturnAir() var/transfer_moles //Negative Kelvins are an anomaly and should be normalized if encountered - if(source_air.temperature < TCMB) - source_air.temperature = TCMB + if(source_air.return_temperature(TCMB)) + source_air.set_temperature(TCMB) - transfer_moles = (pressure_delta*contaminated_air.volume/(source_air.temperature * R_IDEAL_GAS_EQUATION))*PUMP_EFFICIENCY + transfer_moles = (pressure_delta*contaminated_air.return_volume()/(source_air.return_temperature() * R_IDEAL_GAS_EQUATION))*PUMP_EFFICIENCY //If there is nothing to transfer, just return if(transfer_moles <= 0) @@ -368,16 +368,15 @@ obj/item/integrated_circuit/atmospherics/connector/portableConnectorReturnAir() //This is the gas that will be moved from source to filtered var/datum/gas_mixture/filtered_out = new - for(var/filtered_gas in removed.gases) + for(var/filtered_gas in removed.get_gases()) //Get the name of the gas and see if it is in the list if(GLOB.meta_gas_names[filtered_gas] in wanted) //The gas that is put in all the filtered out gases - filtered_out.temperature = removed.temperature - filtered_out.gases[filtered_gas] = removed.gases[filtered_gas] + filtered_out.set_temperature(removed.return_temperature()) + filtered_out.set_moles(filtered_gas, removed.get_moles(filtered_gas)) //The filtered out gas is entirely removed from the currently filtered gases - removed.gases[filtered_gas] = 0 - GAS_GARBAGE_COLLECT(removed.gases) + removed.set_moles(filtered_gas, 0) //Check if the pressure is high enough to put stuff in filtered, or else just put it back in the source var/datum/gas_mixture/target = (filtered_air.return_pressure() < target_pressure ? filtered_air : source_air) @@ -444,7 +443,7 @@ obj/item/integrated_circuit/atmospherics/connector/portableConnectorReturnAir() var/gas_percentage = round(max(min(get_pin_data(IC_INPUT, 4),100),0) / 100) //Basically: number of moles = percentage of pressure filled up * efficiency coefficient * (pressure from both gases * volume of output) / (R * Temperature) - var/transfer_moles = (get_pin_data(IC_INPUT, 5) / max(1,output_gases.return_pressure())) * PUMP_EFFICIENCY * (source_1_gases.return_pressure() * gas_percentage + source_2_gases.return_pressure() * (1 - gas_percentage)) * output_gases.volume/ (R_IDEAL_GAS_EQUATION * max(output_gases.temperature,TCMB)) + var/transfer_moles = (get_pin_data(IC_INPUT, 5) / max(1,output_gases.return_pressure())) * PUMP_EFFICIENCY * (source_1_gases.return_pressure() * gas_percentage + source_2_gases.return_pressure() * (1 - gas_percentage)) * output_gases.return_volume()/ (R_IDEAL_GAS_EQUATION * max(output_gases.return_temperature(),TCMB)) if(transfer_moles <= 0) @@ -544,10 +543,10 @@ obj/item/integrated_circuit/atmospherics/connector/portableConnectorReturnAir() push_data() //Cool the tank if the power is on and the temp is above - if(!power_draw_idle || air_contents.temperature < temperature) + if(!power_draw_idle || air_contents.return_temperature() < temperature) return - air_contents.temperature = max(73.15,air_contents.temperature - (air_contents.temperature - temperature) * heater_coefficient) + air_contents.set_temperature(max(73.15,air_contents.return_temperature() - (air_contents.return_temperature() - temperature) * heater_coefficient)) // - heater tank - // **works** @@ -574,10 +573,10 @@ obj/item/integrated_circuit/atmospherics/connector/portableConnectorReturnAir() push_data() //Heat the tank if the power is on or its temperature is below what is set - if(!power_draw_idle || air_contents.temperature > temperature) + if(!power_draw_idle || air_contents.return_temperature() > temperature) return - air_contents.temperature = min(573.15,air_contents.temperature + (temperature - air_contents.temperature) * heater_coefficient) + air_contents.set_temperature(min(573.15,air_contents.return_temperature() + (temperature - air_contents.return_temperature()) * heater_coefficient)) // - atmospheric cooler - // **works** @@ -621,11 +620,11 @@ obj/item/integrated_circuit/atmospherics/connector/portableConnectorReturnAir() return var/datum/gas_mixture/turf_air = current_turf.return_air() - if(!power_draw_idle || turf_air.temperature < temperature) + if(!power_draw_idle || turf_air.return_temperature() < temperature) return //Cool the gas - turf_air.temperature = max(243.15,turf_air.temperature - (turf_air.temperature - temperature) * heater_coefficient) + turf_air.set_temperature(max(243.15,turf_air.return_temperature() - (turf_air.return_temperature() - temperature) * heater_coefficient)) // - atmospheric heater - // **works** @@ -650,11 +649,11 @@ obj/item/integrated_circuit/atmospherics/connector/portableConnectorReturnAir() return var/datum/gas_mixture/turf_air = current_turf.return_air() - if(!power_draw_idle || turf_air.temperature > temperature) + if(!power_draw_idle || turf_air.return_temperature() > temperature) return //Heat the gas - turf_air.temperature = min(323.15,turf_air.temperature + (temperature - turf_air.temperature) * heater_coefficient) + turf_air.set_temperature(min(323.15,turf_air.return_temperature() + (temperature - turf_air.return_temperature()) * heater_coefficient)) // - tank slot - // **works** diff --git a/code/modules/integrated_electronics/subtypes/input.dm b/code/modules/integrated_electronics/subtypes/input.dm index 49e6855b38..1ecfe29009 100644 --- a/code/modules/integrated_electronics/subtypes/input.dm +++ b/code/modules/integrated_electronics/subtypes/input.dm @@ -1162,12 +1162,11 @@ activate_pin(3) return - var/list/gases = air_contents.gases var/list/gas_names = list() var/list/gas_amounts = list() - for(var/id in gases) + for(var/id in air_contents.get_gases()) var/name = GLOB.meta_gas_names[id] - var/amt = round(gases[id], 0.001) + var/amt = round(air_contents.get_moles(id), 0.001) gas_names.Add(name) gas_amounts.Add(amt) @@ -1175,7 +1174,7 @@ set_pin_data(IC_OUTPUT, 2, gas_amounts) set_pin_data(IC_OUTPUT, 3, round(air_contents.total_moles(), 0.001)) set_pin_data(IC_OUTPUT, 4, round(air_contents.return_pressure(), 0.001)) - set_pin_data(IC_OUTPUT, 5, round(air_contents.temperature, 0.001)) + set_pin_data(IC_OUTPUT, 5, round(air_contents.return_temperature(), 0.001)) set_pin_data(IC_OUTPUT, 6, round(air_contents.return_volume(), 0.001)) push_data() activate_pin(2) diff --git a/code/modules/mob/living/carbon/alien/life.dm b/code/modules/mob/living/carbon/alien/life.dm index 75aadd69c9..0a2aee4238 100644 --- a/code/modules/mob/living/carbon/alien/life.dm +++ b/code/modules/mob/living/carbon/alien/life.dm @@ -12,26 +12,23 @@ var/toxins_used = 0 var/tox_detect_threshold = 0.02 - var/breath_pressure = (breath.total_moles()*R_IDEAL_GAS_EQUATION*breath.temperature)/BREATH_VOLUME - var/list/breath_gases = breath.gases + var/breath_pressure = (breath.total_moles()*R_IDEAL_GAS_EQUATION*breath.return_temperature())/BREATH_VOLUME //Partial pressure of the toxins in our breath - var/Toxins_pp = (breath_gases[/datum/gas/plasma]/breath.total_moles())*breath_pressure + var/Toxins_pp = (breath.get_moles(/datum/gas/plasma)/breath.total_moles())*breath_pressure if(Toxins_pp > tox_detect_threshold) // Detect toxins in air - adjustPlasma(breath_gases[/datum/gas/plasma]*250) + adjustPlasma(breath.get_moles(/datum/gas/plasma)*250) throw_alert("alien_tox", /obj/screen/alert/alien_tox) - toxins_used = breath_gases[/datum/gas/plasma] + toxins_used = breath.get_moles(/datum/gas/plasma) else clear_alert("alien_tox") //Breathe in toxins and out oxygen - breath_gases[/datum/gas/plasma] -= toxins_used - breath_gases[/datum/gas/oxygen] += toxins_used - - GAS_GARBAGE_COLLECT(breath.gases) + breath.adjust_moles(/datum/gas/plasma, -toxins_used) + breath.adjust_moles(/datum/gas/oxygen, toxins_used) //BREATH TEMPERATURE handle_breath_temperature(breath) diff --git a/code/modules/mob/living/carbon/human/species_types/plasmamen.dm b/code/modules/mob/living/carbon/human/species_types/plasmamen.dm index 0383a19764..91d3135ae1 100644 --- a/code/modules/mob/living/carbon/human/species_types/plasmamen.dm +++ b/code/modules/mob/living/carbon/human/species_types/plasmamen.dm @@ -33,7 +33,7 @@ if((!istype(H.w_uniform, /obj/item/clothing/under/plasmaman) || !istype(H.head, /obj/item/clothing/head/helmet/space/plasmaman)) && !atmos_sealed) if(environment) if(environment.total_moles()) - if(environment.gases[/datum/gas/oxygen] && (environment.gases[/datum/gas/oxygen]) >= 1) //Same threshhold that extinguishes fire + if(environment.get_moles(/datum/gas/oxygen) >= 1) //Same threshhold that extinguishes fire H.adjust_fire_stacks(0.5) if(!H.on_fire && H.fire_stacks > 0) H.visible_message("[H]'s body reacts with the atmosphere and bursts into flames!","Your body reacts with the atmosphere and bursts into flame!") diff --git a/code/modules/mob/living/carbon/life.dm b/code/modules/mob/living/carbon/life.dm index 00a0991e19..8b8fe52346 100644 --- a/code/modules/mob/living/carbon/life.dm +++ b/code/modules/mob/living/carbon/life.dm @@ -169,12 +169,11 @@ var/SA_para_min = 1 var/SA_sleep_min = 5 var/oxygen_used = 0 - var/breath_pressure = (breath.total_moles()*R_IDEAL_GAS_EQUATION*breath.temperature)/BREATH_VOLUME + var/breath_pressure = (breath.total_moles()*R_IDEAL_GAS_EQUATION*breath.return_temperature())/BREATH_VOLUME - var/list/breath_gases = breath.gases - var/O2_partialpressure = (breath_gases[/datum/gas/oxygen]/breath.total_moles())*breath_pressure - var/Toxins_partialpressure = (breath_gases[/datum/gas/plasma]/breath.total_moles())*breath_pressure - var/CO2_partialpressure = (breath_gases[/datum/gas/carbon_dioxide]/breath.total_moles())*breath_pressure + var/O2_partialpressure = (breath.get_moles(/datum/gas/oxygen)/breath.total_moles())*breath_pressure + var/Toxins_partialpressure = (breath.get_moles(/datum/gas/plasma)/breath.total_moles())*breath_pressure + var/CO2_partialpressure = (breath.get_moles(/datum/gas/carbon_dioxide)/breath.total_moles())*breath_pressure //OXYGEN @@ -198,7 +197,7 @@ var/ratio = 1 - O2_partialpressure/safe_oxy_min adjustOxyLoss(min(5*ratio, 3)) failed_last_breath = 1 - oxygen_used = breath_gases[/datum/gas/oxygen]*ratio + oxygen_used = breath.get_moles(/datum/gas/oxygen)*ratio else adjustOxyLoss(3) failed_last_breath = 1 @@ -210,12 +209,12 @@ o2overloadtime = 0 //reset our counter for this too if(health >= crit_threshold) adjustOxyLoss(-5) - oxygen_used = breath_gases[/datum/gas/oxygen] + oxygen_used = breath.get_moles(/datum/gas/oxygen) clear_alert("not_enough_oxy") SEND_SIGNAL(src, COMSIG_CLEAR_MOOD_EVENT, "suffocation") - breath_gases[/datum/gas/oxygen] -= oxygen_used - breath_gases[/datum/gas/carbon_dioxide] += oxygen_used + breath.adjust_moles(/datum/gas/oxygen, -oxygen_used) + breath.adjust_moles(/datum/gas/carbon_dioxide, oxygen_used) //CARBON DIOXIDE if(CO2_partialpressure > safe_co2_max) @@ -234,15 +233,15 @@ //TOXINS/PLASMA if(Toxins_partialpressure > safe_tox_max) - var/ratio = (breath_gases[/datum/gas/plasma]/safe_tox_max) * 10 + var/ratio = (breath.get_moles(/datum/gas/plasma)/safe_tox_max) * 10 adjustToxLoss(clamp(ratio, MIN_TOXIC_GAS_DAMAGE, MAX_TOXIC_GAS_DAMAGE)) throw_alert("too_much_tox", /obj/screen/alert/too_much_tox) else clear_alert("too_much_tox") //NITROUS OXIDE - if(breath_gases[/datum/gas/nitrous_oxide]) - var/SA_partialpressure = (breath_gases[/datum/gas/nitrous_oxide]/breath.total_moles())*breath_pressure + if(breath.get_moles(/datum/gas/nitrous_oxide)) + var/SA_partialpressure = (breath.get_moles(/datum/gas/nitrous_oxide)/breath.total_moles())*breath_pressure if(SA_partialpressure > SA_para_min) Unconscious(60) if(SA_partialpressure > SA_sleep_min) @@ -255,26 +254,26 @@ SEND_SIGNAL(src, COMSIG_CLEAR_MOOD_EVENT, "chemical_euphoria") //BZ (Facepunch port of their Agent B) - if(breath_gases[/datum/gas/bz]) - var/bz_partialpressure = (breath_gases[/datum/gas/bz]/breath.total_moles())*breath_pressure + if(breath.get_moles(/datum/gas/bz)) + var/bz_partialpressure = (breath.get_moles(/datum/gas/bz)/breath.total_moles())*breath_pressure if(bz_partialpressure > 1) hallucination += 10 else if(bz_partialpressure > 0.01) hallucination += 5 //TRITIUM - if(breath_gases[/datum/gas/tritium]) - var/tritium_partialpressure = (breath_gases[/datum/gas/tritium]/breath.total_moles())*breath_pressure + if(breath.get_moles(/datum/gas/tritium)) + var/tritium_partialpressure = (breath.get_moles(/datum/gas/tritium)/breath.total_moles())*breath_pressure radiation += tritium_partialpressure/10 //NITRYL - if(breath_gases[/datum/gas/nitryl]) - var/nitryl_partialpressure = (breath_gases[/datum/gas/nitryl]/breath.total_moles())*breath_pressure + if(breath.get_moles(/datum/gas/nitryl)) + var/nitryl_partialpressure = (breath.get_moles(/datum/gas/nitryl)/breath.total_moles())*breath_pressure adjustFireLoss(nitryl_partialpressure/4) //MIASMA - if(breath_gases[/datum/gas/miasma]) - var/miasma_partialpressure = (breath_gases[/datum/gas/miasma]/breath.total_moles())*breath_pressure + if(breath.get_moles(/datum/gas/miasma)) + var/miasma_partialpressure = (breath.get_moles(/datum/gas/miasma)/breath.total_moles())*breath_pressure if(miasma_partialpressure > MINIMUM_MOLES_DELTA_TO_MOVE) if(prob(0.05 * miasma_partialpressure)) @@ -314,11 +313,6 @@ else SEND_SIGNAL(src, COMSIG_CLEAR_MOOD_EVENT, "smell") - - - - GAS_GARBAGE_COLLECT(breath.gases) - //BREATH TEMPERATURE handle_breath_temperature(breath) @@ -377,9 +371,9 @@ var/datum/gas_mixture/stank = new - stank.gases[/datum/gas/miasma] = 0.1 + stank.set_moles(/datum/gas/miasma,0.1) - stank.temperature = BODYTEMP_NORMAL + stank.set_temperature(BODYTEMP_NORMAL) miasma_turf.assume_air(stank) diff --git a/code/modules/mob/living/carbon/monkey/life.dm b/code/modules/mob/living/carbon/monkey/life.dm index edbd1562b3..c770be9629 100644 --- a/code/modules/mob/living/carbon/monkey/life.dm +++ b/code/modules/mob/living/carbon/monkey/life.dm @@ -50,8 +50,8 @@ return ..() /mob/living/carbon/monkey/handle_breath_temperature(datum/gas_mixture/breath) - if(abs(BODYTEMP_NORMAL - breath.temperature) > 50) - switch(breath.temperature) + if(abs(BODYTEMP_NORMAL - breath.return_temperature()) > 50) + switch(breath.return_temperature()) if(-INFINITY to 120) adjustFireLoss(3) if(120 to 200) diff --git a/code/modules/mob/living/life.dm b/code/modules/mob/living/life.dm index d3199d6f8b..76c6bd508f 100644 --- a/code/modules/mob/living/life.dm +++ b/code/modules/mob/living/life.dm @@ -110,7 +110,7 @@ ExtinguishMob() return var/datum/gas_mixture/G = loc.return_air() // Check if we're standing in an oxygenless environment - if(G.gases[/datum/gas/oxygen] < 1) + if(G.get_moles(/datum/gas/oxygen, 1)) ExtinguishMob() //If there's no oxygen in the tile we're on, put out the fire return var/turf/location = get_turf(src) @@ -166,4 +166,4 @@ /mob/living/proc/handle_high_gravity(gravity) if(gravity >= GRAVITY_DAMAGE_TRESHOLD) //Aka gravity values of 3 or more var/grav_stregth = gravity - GRAVITY_DAMAGE_TRESHOLD - adjustBruteLoss(min(grav_stregth,3)) \ No newline at end of file + adjustBruteLoss(min(grav_stregth,3)) diff --git a/code/modules/mob/living/living.dm b/code/modules/mob/living/living.dm index db5771f75e..804e8f4899 100644 --- a/code/modules/mob/living/living.dm +++ b/code/modules/mob/living/living.dm @@ -902,7 +902,7 @@ setMovetype(movement_type & ~FLOATING) // If we were without gravity, the bouncing animation got stopped, so we make sure to restart it in next life(). /mob/living/proc/get_temperature(datum/gas_mixture/environment) - var/loc_temp = environment ? environment.temperature : T0C + var/loc_temp = environment ? environment.return_temperature() : T0C if(isobj(loc)) var/obj/oloc = loc var/obj_temp = oloc.return_temperature() diff --git a/code/modules/mob/living/silicon/pai/software.dm b/code/modules/mob/living/silicon/pai/software.dm index 892cc3f13b..d3fab4752c 100644 --- a/code/modules/mob/living/silicon/pai/software.dm +++ b/code/modules/mob/living/silicon/pai/software.dm @@ -566,7 +566,6 @@ dat += "Unable to obtain a reading.
" else var/datum/gas_mixture/environment = T.return_air() - var/list/env_gases = environment.gases var/pressure = environment.return_pressure() var/total_moles = environment.total_moles() @@ -574,11 +573,11 @@ dat += "Air Pressure: [round(pressure,0.1)] kPa
" if (total_moles) - for(var/id in env_gases) - var/gas_level = env_gases[id]/total_moles + for(var/id in environment.get_gases()) + var/gas_level = environment.get_moles(id)/total_moles if(gas_level > 0.01) dat += "[GLOB.meta_gas_names[id]]: [round(gas_level*100)]%
" - dat += "Temperature: [round(environment.temperature-T0C)]°C
" + dat += "Temperature: [round(environment.return_temperature()-T0C)]°C
" dat += "Refresh Reading
" dat += "
" return dat diff --git a/code/modules/mob/living/simple_animal/hostile/tree.dm b/code/modules/mob/living/simple_animal/hostile/tree.dm index bc932666f6..3c8d028d53 100644 --- a/code/modules/mob/living/simple_animal/hostile/tree.dm +++ b/code/modules/mob/living/simple_animal/hostile/tree.dm @@ -44,12 +44,12 @@ ..() if(isopenturf(loc)) var/turf/open/T = src.loc - if(T.air && T.air.gases[/datum/gas/carbon_dioxide]) - var/co2 = T.air.gases[/datum/gas/carbon_dioxide] + if(T.air) + var/co2 = T.air.get_moles(/datum/gas/carbon_dioxide) if(co2 > 0) if(prob(25)) var/amt = min(co2, 9) - T.air.gases[/datum/gas/carbon_dioxide] -= amt + T.air.adjust_moles(/datum/gas/carbon_dioxide, -amt) T.atmos_spawn_air("o2=[amt]") /mob/living/simple_animal/hostile/tree/AttackingTarget() diff --git a/code/modules/mob/living/simple_animal/simple_animal.dm b/code/modules/mob/living/simple_animal/simple_animal.dm index def6327461..ba524d156e 100644 --- a/code/modules/mob/living/simple_animal/simple_animal.dm +++ b/code/modules/mob/living/simple_animal/simple_animal.dm @@ -208,14 +208,11 @@ if(isturf(src.loc) && isopenturf(src.loc)) var/turf/open/ST = src.loc if(ST.air) - var/ST_gases = ST.air.gases - var/tox = ST_gases[/datum/gas/plasma] - var/oxy = ST_gases[/datum/gas/oxygen] - var/n2 = ST_gases[/datum/gas/nitrogen] - var/co2 = ST_gases[/datum/gas/carbon_dioxide] - - GAS_GARBAGE_COLLECT(ST.air.gases) + var/tox = ST.air.get_moles(/datum/gas/plasma) + var/oxy = ST.air.get_moles(/datum/gas/oxygen) + var/n2 = ST.air.get_moles(/datum/gas/nitrogen) + var/co2 = ST.air.get_moles(/datum/gas/carbon_dioxide) if(atmos_requirements["min_oxy"] && oxy < atmos_requirements["min_oxy"]) . = FALSE diff --git a/code/modules/mob/living/simple_animal/slime/life.dm b/code/modules/mob/living/simple_animal/slime/life.dm index 4b89d96e64..a4cd5a0164 100644 --- a/code/modules/mob/living/simple_animal/slime/life.dm +++ b/code/modules/mob/living/simple_animal/slime/life.dm @@ -130,9 +130,7 @@ Tempstun = 0 if(stat != DEAD) - var/bz_percentage =0 - if(environment.gases[/datum/gas/bz]) - bz_percentage = environment.gases[/datum/gas/bz] / environment.total_moles() + var/bz_percentage = environment.total_moles() ? (environment.get_moles(/datum/gas/bz) / environment.total_moles()) : 0 var/stasis = (bz_percentage >= 0.05 && bodytemperature < (T0C + 100)) || force_stasis if(stat == CONSCIOUS && stasis) diff --git a/code/modules/mob/mob.dm b/code/modules/mob/mob.dm index ce3b8bf3d2..ae05454421 100644 --- a/code/modules/mob/mob.dm +++ b/code/modules/mob/mob.dm @@ -66,11 +66,10 @@ var/datum/gas_mixture/environment = loc.return_air() var/t = "Coordinates: [x],[y] \n" - t += "Temperature: [environment.temperature] \n" - for(var/id in environment.gases) - var/gas = environment.gases[id] - if(gas) - t+="[GLOB.meta_gas_names[id]]: [gas] \n" + t += "Temperature: [environment.return_temperature()] \n" + for(var/id in environment.get_gases()) + if(environment.get_moles(id)) + t+="[GLOB.meta_gas_names[id]]: [environment.get_moles(id)] \n" to_chat(usr, t) diff --git a/code/modules/modular_computers/file_system/programs/sm_monitor.dm b/code/modules/modular_computers/file_system/programs/sm_monitor.dm index dbee59bb3e..101f533e8f 100644 --- a/code/modules/modular_computers/file_system/programs/sm_monitor.dm +++ b/code/modules/modular_computers/file_system/programs/sm_monitor.dm @@ -73,20 +73,22 @@ data["active"] = TRUE data["SM_integrity"] = active.get_integrity() data["SM_power"] = active.power - data["SM_ambienttemp"] = air.temperature + data["SM_ambienttemp"] = air.return_temperature() data["SM_ambientpressure"] = air.return_pressure() //data["SM_EPR"] = round((air.total_moles / air.group_multiplier) / 23.1, 0.01) var/list/gasdata = list() if(air.total_moles()) - for(var/gasid in air.gases) - gasdata.Add(list(list( - "name"= GLOB.meta_gas_names[gasid], - "amount" = round(100*air.gases[gasid]/air.total_moles(),0.01)))) + for(var/gasid in air.get_gases()) + var/amount = air.get_moles(gasid) + if(amount) + gasdata.Add(list(list( + "name"= GLOB.meta_gas_names[gasid], + "amount" = round(100*amount/air.total_moles(),0.01)))) else - for(var/gasid in air.gases) + for(var/gasid in air.get_gases()) gasdata.Add(list(list( "name"= GLOB.meta_gas_names[gasid], "amount" = 0))) @@ -124,4 +126,4 @@ for(var/obj/machinery/power/supermatter_crystal/S in supermatters) if(S.uid == newuid) active = S - return TRUE \ No newline at end of file + return TRUE diff --git a/code/modules/power/generator.dm b/code/modules/power/generator.dm index 6d63a57c88..78a20e5b62 100644 --- a/code/modules/power/generator.dm +++ b/code/modules/power/generator.dm @@ -57,7 +57,7 @@ var/cold_air_heat_capacity = cold_air.heat_capacity() var/hot_air_heat_capacity = hot_air.heat_capacity() - var/delta_temperature = hot_air.temperature - cold_air.temperature + var/delta_temperature = hot_air.return_temperature() - cold_air.return_temperature() if(delta_temperature > 0 && cold_air_heat_capacity > 0 && hot_air_heat_capacity > 0) @@ -68,8 +68,8 @@ var/heat = energy_transfer*(1-efficiency) lastgen += energy_transfer*efficiency - hot_air.temperature = hot_air.temperature - energy_transfer/hot_air_heat_capacity - cold_air.temperature = cold_air.temperature + heat/cold_air_heat_capacity + hot_air.set_temperature(hot_air.return_temperature() - energy_transfer/hot_air_heat_capacity) + cold_air.set_temperature(cold_air.return_temperature() + heat/cold_air_heat_capacity) //add_avail(lastgen) This is done in process now // update icon overlays only if displayed level has changed @@ -116,11 +116,11 @@ t += "
" t += "Cold loop
" - t += "Temperature Inlet: [round(cold_circ_air2.temperature, 0.1)] K / Outlet: [round(cold_circ_air1.temperature, 0.1)] K
" + t += "Temperature Inlet: [round(cold_circ_air2.return_temperature(), 0.1)] K / Outlet: [round(cold_circ_air1.return_temperature(), 0.1)] K
" t += "Pressure Inlet: [round(cold_circ_air2.return_pressure(), 0.1)] kPa / Outlet: [round(cold_circ_air1.return_pressure(), 0.1)] kPa
" t += "Hot loop
" - t += "Temperature Inlet: [round(hot_circ_air2.temperature, 0.1)] K / Outlet: [round(hot_circ_air1.temperature, 0.1)] K
" + t += "Temperature Inlet: [round(hot_circ_air2.return_temperature(), 0.1)] K / Outlet: [round(hot_circ_air1.return_temperature(), 0.1)] K
" t += "Pressure Inlet: [round(hot_circ_air2.return_pressure(), 0.1)] kPa / Outlet: [round(hot_circ_air1.return_pressure(), 0.1)] kPa
" t += "" diff --git a/code/modules/power/singularity/collector.dm b/code/modules/power/singularity/collector.dm index 68a6b34216..fa7628b8ad 100644 --- a/code/modules/power/singularity/collector.dm +++ b/code/modules/power/singularity/collector.dm @@ -47,31 +47,29 @@ if(!loaded_tank) return if(!bitcoinmining) - if(!loaded_tank.air_contents.gases[/datum/gas/plasma]) + if(loaded_tank.air_contents.get_moles(/datum/gas/plasma) < 0.0001) investigate_log("out of fuel.", INVESTIGATE_SINGULO) playsound(src, 'sound/machines/ding.ogg', 50, 1) Radio.talk_into(src, "Insufficient plasma in [get_area(src)] [src], ejecting \the [loaded_tank].", FREQ_ENGINEERING) eject() else - var/gasdrained = min(powerproduction_drain*drainratio,loaded_tank.air_contents.gases[/datum/gas/plasma]) - loaded_tank.air_contents.gases[/datum/gas/plasma] -= 2.7 * gasdrained - loaded_tank.air_contents.gases[/datum/gas/tritium] += 2.7 * gasdrained - GAS_GARBAGE_COLLECT(loaded_tank.air_contents.gases) + var/gasdrained = min(powerproduction_drain*drainratio,loaded_tank.air_contents.get_moles(/datum/gas/plasma)) + loaded_tank.air_contents.adjust_moles(/datum/gas/plasma, -gasdrained) + loaded_tank.air_contents.adjust_moles(/datum/gas/tritium, gasdrained) var/power_produced = RAD_COLLECTOR_OUTPUT add_avail(power_produced) stored_power-=power_produced else if(is_station_level(z) && SSresearch.science_tech) - if(!loaded_tank.air_contents.gases[/datum/gas/tritium] || !loaded_tank.air_contents.gases[/datum/gas/oxygen]) + if(!loaded_tank.air_contents.get_moles(/datum/gas/tritium) || !loaded_tank.air_contents.get_moles(/datum/gas/oxygen)) playsound(src, 'sound/machines/ding.ogg', 50, 1) Radio.talk_into(src, "Insufficient oxygen and tritium in [get_area(src)] [src] to produce research points, ejecting \the [loaded_tank].", FREQ_ENGINEERING) eject() else var/gasdrained = bitcoinproduction_drain*drainratio - loaded_tank.air_contents.gases[/datum/gas/tritium] -= gasdrained - loaded_tank.air_contents.gases[/datum/gas/oxygen] -= gasdrained - loaded_tank.air_contents.gases[/datum/gas/carbon_dioxide] += gasdrained*2 - GAS_GARBAGE_COLLECT(loaded_tank.air_contents.gases) + loaded_tank.air_contents.adjust_moles(/datum/gas/tritium, -gasdrained) + loaded_tank.air_contents.adjust_moles(/datum/gas/oxygen, -gasdrained) + loaded_tank.air_contents.adjust_moles(/datum/gas/carbon_dioxide, gasdrained*2) SSresearch.science_tech.add_point_type(TECHWEB_POINT_TYPE_DEFAULT, stored_power*RAD_COLLECTOR_MINING_CONVERSION_RATE) last_push = stored_power stored_power = 0 @@ -82,9 +80,7 @@ toggle_power() user.visible_message("[user.name] turns the [src.name] [active? "on":"off"].", \ "You turn the [src.name] [active? "on":"off"].") - var/fuel - if(loaded_tank) - fuel = loaded_tank.air_contents.gases[/datum/gas/plasma] + var/fuel = loaded_tank.air_contents.get_moles(/datum/gas/plasma) investigate_log("turned [active?"on":"off"] by [key_name(user)]. [loaded_tank?"Fuel: [round(fuel/0.29)]%":"It is empty"].", INVESTIGATE_SINGULO) return else diff --git a/code/modules/power/supermatter/supermatter.dm b/code/modules/power/supermatter/supermatter.dm index 650961e2f4..f441fda3f9 100644 --- a/code/modules/power/supermatter/supermatter.dm +++ b/code/modules/power/supermatter/supermatter.dm @@ -211,10 +211,10 @@ GLOBAL_DATUM(main_supermatter_engine, /obj/machinery/power/supermatter_crystal) if(get_integrity() < SUPERMATTER_DANGER_PERCENT) return SUPERMATTER_DANGER - if((get_integrity() < SUPERMATTER_WARNING_PERCENT) || (air.temperature > CRITICAL_TEMPERATURE)) + if((get_integrity() < SUPERMATTER_WARNING_PERCENT) || (air.return_temperature() > CRITICAL_TEMPERATURE)) return SUPERMATTER_WARNING - if(air.temperature > (CRITICAL_TEMPERATURE * 0.8)) + if(air.return_temperature() > (CRITICAL_TEMPERATURE * 0.8)) return SUPERMATTER_NOTIFY if(power > 5) @@ -342,13 +342,13 @@ GLOBAL_DATUM(main_supermatter_engine, /obj/machinery/power/supermatter_crystal) else if(takes_damage) //causing damage - damage = max(damage + (max(clamp(removed.total_moles() / 200, 0.5, 1) * removed.temperature - ((T0C + HEAT_PENALTY_THRESHOLD)*dynamic_heat_resistance), 0) * mole_heat_penalty / 150 ) * DAMAGE_INCREASE_MULTIPLIER, 0) + damage = max(damage + (max(clamp(removed.total_moles() / 200, 0.5, 1) * removed.return_temperature() - ((T0C + HEAT_PENALTY_THRESHOLD)*dynamic_heat_resistance), 0) * mole_heat_penalty / 150 ) * DAMAGE_INCREASE_MULTIPLIER, 0) damage = max(damage + (max(power - POWER_PENALTY_THRESHOLD, 0)/500) * DAMAGE_INCREASE_MULTIPLIER, 0) damage = max(damage + (max(combined_gas - MOLE_PENALTY_THRESHOLD, 0)/80) * DAMAGE_INCREASE_MULTIPLIER, 0) //healing damage if(combined_gas < MOLE_PENALTY_THRESHOLD) - damage = max(damage + (min(removed.temperature - (T0C + HEAT_PENALTY_THRESHOLD), 0) / 150 ), 0) + damage = max(damage + (min(removed.return_temperature() - (T0C + HEAT_PENALTY_THRESHOLD), 0) / 150 ), 0) //capping damage damage = min(damage_archived + (DAMAGE_HARDCAP * explosion_point),damage) @@ -358,15 +358,15 @@ GLOBAL_DATUM(main_supermatter_engine, /obj/machinery/power/supermatter_crystal) //calculating gas related values combined_gas = max(removed.total_moles(), 0) - plasmacomp = max(removed.gases[/datum/gas/plasma]/combined_gas, 0) - o2comp = max(removed.gases[/datum/gas/oxygen]/combined_gas, 0) - co2comp = max(removed.gases[/datum/gas/carbon_dioxide]/combined_gas, 0) - pluoxiumcomp = max(removed.gases[/datum/gas/pluoxium]/combined_gas, 0) - tritiumcomp = max(removed.gases[/datum/gas/tritium]/combined_gas, 0) - bzcomp = max(removed.gases[/datum/gas/bz]/combined_gas, 0) + plasmacomp = max(removed.get_moles(/datum/gas/plasma)/combined_gas, 0) + o2comp = max(removed.get_moles(/datum/gas/oxygen)/combined_gas, 0) + co2comp = max(removed.get_moles(/datum/gas/carbon_dioxide)/combined_gas, 0) + tritiumcomp = max(removed.get_moles(/datum/gas/tritium)/combined_gas, 0) + bzcomp = max(removed.get_moles(/datum/gas/bz)/combined_gas, 0) - n2ocomp = max(removed.gases[/datum/gas/nitrous_oxide]/combined_gas, 0) - n2comp = max(removed.gases[/datum/gas/nitrogen]/combined_gas, 0) + pluoxiumcomp = max(removed.get_moles(/datum/gas/pluoxium)/combined_gas, 0) + n2ocomp = max(removed.get_moles(/datum/gas/nitrous_oxide)/combined_gas, 0) + n2comp = max(removed.get_moles(/datum/gas/nitrogen)/combined_gas, 0) if(pluoxiumcomp >= 0.15) pluoxiumbonus = 1 //makes pluoxium only work at 15%+ @@ -404,7 +404,7 @@ GLOBAL_DATUM(main_supermatter_engine, /obj/machinery/power/supermatter_crystal) temp_factor = 30 icon_state = base_icon_state - power = max( (removed.temperature * temp_factor / T0C) * gasmix_power_ratio + power, 0) //Total laser power plus an overload + power = max( (removed.return_temperature() * temp_factor / T0C) * gasmix_power_ratio + power, 0) //Total laser power plus an overload if(prob(50)) radiation_pulse(src, power * (1 + (tritiumcomp * TRITIUM_RADIOACTIVITY_MODIFIER) + ((pluoxiumcomp * PLUOXIUM_RADIOACTIVITY_MODIFIER) * pluoxiumbonus) * (power_transmission_bonus/(10-(bzcomp * BZ_RADIOACTIVITY_MODIFIER))))) // Rad Modifiers BZ(500%), Tritium(300%), and Pluoxium(-200%) @@ -420,14 +420,14 @@ GLOBAL_DATUM(main_supermatter_engine, /obj/machinery/power/supermatter_crystal) //Also keep in mind we are only adding this temperature to (efficiency)% of the one tile the rock //is on. An increase of 4*C @ 25% efficiency here results in an increase of 1*C / (#tilesincore) overall. - removed.temperature += ((device_energy * dynamic_heat_modifier) / THERMAL_RELEASE_MODIFIER) + removed.set_temperature(removed.return_temperature() + ((device_energy * dynamic_heat_modifier) / THERMAL_RELEASE_MODIFIER)) - removed.temperature = max(0, min(removed.temperature, 2500 * dynamic_heat_modifier)) + removed.set_temperature(max(0, min(removed.return_temperature(), 2500 * dynamic_heat_modifier))) //Calculate how much gas to release - removed.gases[/datum/gas/plasma] += max((device_energy * dynamic_heat_modifier) / PLASMA_RELEASE_MODIFIER, 0) + removed.adjust_moles(/datum/gas/plasma, max((device_energy * dynamic_heat_modifier) / PLASMA_RELEASE_MODIFIER, 0)) - removed.gases[/datum/gas/oxygen] += max(((device_energy + removed.temperature * dynamic_heat_modifier) - T0C) / OXYGEN_RELEASE_MODIFIER, 0) + removed.adjust_moles(/datum/gas/oxygen, max(((device_energy + removed.return_temperature() * dynamic_heat_modifier) - T0C) / OXYGEN_RELEASE_MODIFIER, 0)) if(produces_gas) env.merge(removed) diff --git a/code/modules/power/turbine.dm b/code/modules/power/turbine.dm index b40e5c6c41..6fd1b27a47 100644 --- a/code/modules/power/turbine.dm +++ b/code/modules/power/turbine.dm @@ -205,7 +205,7 @@ // Weird function but it works. Should be something else... - var/newrpm = ((compressor.gas_contained.temperature) * compressor.gas_contained.total_moles())/4 + var/newrpm = ((compressor.gas_contained.return_temperature()) * compressor.gas_contained.total_moles())/4 newrpm = max(0, newrpm) @@ -333,7 +333,7 @@ data["power"] = DisplayPower(compressor?.turbine?.lastgen) data["rpm"] = compressor?.rpm - data["temp"] = compressor?.gas_contained.temperature + data["temp"] = compressor?.gas_contained.return_temperature() return data diff --git a/code/modules/procedural_mapping/mapGeneratorModules/helpers.dm b/code/modules/procedural_mapping/mapGeneratorModules/helpers.dm index 3083e7a096..4bd9177373 100644 --- a/code/modules/procedural_mapping/mapGeneratorModules/helpers.dm +++ b/code/modules/procedural_mapping/mapGeneratorModules/helpers.dm @@ -16,7 +16,7 @@ if(T.air) if(T.initial_gas_mix) T.air.parse_gas_string(T.initial_gas_mix) - T.temperature = T.air.temperature + T.temperature = T.air.return_temperature() else T.air.copy_from_turf(T) SSair.add_to_active(T) diff --git a/code/modules/reagents/chemistry/reagents/food_reagents.dm b/code/modules/reagents/chemistry/reagents/food_reagents.dm index c7ff3f01c9..e97563b33f 100644 --- a/code/modules/reagents/chemistry/reagents/food_reagents.dm +++ b/code/modules/reagents/chemistry/reagents/food_reagents.dm @@ -270,7 +270,7 @@ if(isopenturf(T)) var/turf/open/OT = T OT.MakeSlippery(wet_setting=TURF_WET_ICE, min_wet_time=100, wet_time_to_add=reac_volume SECONDS) // Is less effective in high pressure/high heat capacity environments. More effective in low pressure. - OT.air.temperature -= MOLES_CELLSTANDARD*100*reac_volume/OT.air.heat_capacity() // reduces environment temperature by 5K per unit. + OT.air.set_temperature(OT.air.return_temperature() - MOLES_CELLSTANDARD*100*reac_volume/OT.air.heat_capacity()) // reduces environment temperature by 5K per unit. /datum/reagent/consumable/condensedcapsaicin name = "Condensed Capsaicin" @@ -505,7 +505,7 @@ var/obj/effect/hotspot/hotspot = (locate(/obj/effect/hotspot) in T) if(hotspot) var/datum/gas_mixture/lowertemp = T.remove_air(T.air.total_moles()) - lowertemp.temperature = max( min(lowertemp.temperature-2000,lowertemp.temperature / 2) ,0) + lowertemp.set_temperature(max( min(lowertemp.return_temperature()-2000,lowertemp.return_temperature() / 2) ,0)) lowertemp.react(src) T.assume_air(lowertemp) qdel(hotspot) diff --git a/code/modules/reagents/chemistry/reagents/other_reagents.dm b/code/modules/reagents/chemistry/reagents/other_reagents.dm index 5fb27bd074..ed94a28c7a 100644 --- a/code/modules/reagents/chemistry/reagents/other_reagents.dm +++ b/code/modules/reagents/chemistry/reagents/other_reagents.dm @@ -259,7 +259,7 @@ if(hotspot && !isspaceturf(T)) if(T.air) var/datum/gas_mixture/G = T.air - G.temperature = max(min(G.temperature-(CT*1000),G.temperature/CT),TCMB) + G.set_temperature(max(min(G.return_temperature()-(CT*1000),G.return_temperature()/CT),TCMB)) G.react(src) qdel(hotspot) var/obj/effect/acid/A = (locate(/obj/effect/acid) in T) diff --git a/code/modules/reagents/chemistry/reagents/pyrotechnic_reagents.dm b/code/modules/reagents/chemistry/reagents/pyrotechnic_reagents.dm index 67ff61610d..f7684cd908 100644 --- a/code/modules/reagents/chemistry/reagents/pyrotechnic_reagents.dm +++ b/code/modules/reagents/chemistry/reagents/pyrotechnic_reagents.dm @@ -269,8 +269,8 @@ if(hotspot && !isspaceturf(T)) if(T.air) var/datum/gas_mixture/G = T.air - if(G.temperature > T20C) - G.temperature = max(G.temperature/2,T20C) + if(G.return_temperature() > T20C) + G.set_temperature(max(G.return_temperature()/2,T20C)) G.react(src) qdel(hotspot) diff --git a/code/modules/recycling/disposal/bin.dm b/code/modules/recycling/disposal/bin.dm index 65bfa1d98f..fb615563df 100644 --- a/code/modules/recycling/disposal/bin.dm +++ b/code/modules/recycling/disposal/bin.dm @@ -40,7 +40,7 @@ trunk_check() air_contents = new /datum/gas_mixture() - //gas.volume = 1.05 * CELLSTANDARD + //air_contents.set_volume(1.05 * CELLSTANDARD) update_icon() return INITIALIZE_HINT_LATELOAD //we need turfs to have air @@ -443,8 +443,8 @@ var/datum/gas_mixture/env = L.return_air() var/pressure_delta = (SEND_PRESSURE*1.01) - air_contents.return_pressure() - if(env.temperature > 0) - var/transfer_moles = 0.1 * pressure_delta*air_contents.volume/(env.temperature * R_IDEAL_GAS_EQUATION) + if(env.return_temperature() > 0) + var/transfer_moles = 0.1 * pressure_delta*air_contents.return_volume()/(env.return_temperature() * R_IDEAL_GAS_EQUATION) //Actually transfer the gas var/datum/gas_mixture/removed = env.remove(transfer_moles) diff --git a/code/modules/research/experimentor.dm b/code/modules/research/experimentor.dm index 3d4bf2b4c9..9667830dbc 100644 --- a/code/modules/research/experimentor.dm +++ b/code/modules/research/experimentor.dm @@ -368,7 +368,7 @@ var/heat_capacity = removed.heat_capacity() if(heat_capacity == 0 || heat_capacity == null) heat_capacity = 1 - removed.temperature = min((removed.temperature*heat_capacity + 100000)/heat_capacity, 1000) + removed.set_temperature(min((removed.return_temperature()*heat_capacity + 100000)/heat_capacity, 1000)) env.merge(removed) air_update_turf() investigate_log("Experimentor has released hot air.", INVESTIGATE_EXPERIMENTOR) @@ -414,7 +414,7 @@ var/heat_capacity = removed.heat_capacity() if(heat_capacity == 0 || heat_capacity == null) heat_capacity = 1 - removed.temperature = (removed.temperature*heat_capacity - 75000)/heat_capacity + removed.set_temperature((removed.return_temperature()*heat_capacity - 75000)/heat_capacity) env.merge(removed) air_update_turf() investigate_log("Experimentor has released cold air.", INVESTIGATE_EXPERIMENTOR) diff --git a/code/modules/research/server.dm b/code/modules/research/server.dm index b3e114d2ad..d3b4bb6bac 100644 --- a/code/modules/research/server.dm +++ b/code/modules/research/server.dm @@ -59,14 +59,14 @@ /obj/machinery/rnd/server/proc/get_env_temp() var/datum/gas_mixture/environment = loc.return_air() - return environment.temperature + return environment.return_temperature() /obj/machinery/rnd/server/proc/produce_heat(heat_amt) if(!(stat & (NOPOWER|BROKEN))) //Blatently stolen from space heater. var/turf/L = loc if(istype(L)) var/datum/gas_mixture/env = L.return_air() - if(env.temperature < (heat_amt+T0C)) + if(env.return_temperature() < (heat_amt+T0C)) var/transfer_moles = 0.25 * env.total_moles() @@ -77,7 +77,7 @@ var/heat_capacity = removed.heat_capacity() if(heat_capacity == 0 || heat_capacity == null) heat_capacity = 1 - removed.temperature = min((removed.temperature*heat_capacity + heating_power)/heat_capacity, 1000) + removed.set_temperature(min((removed.return_temperature()*heat_capacity + heating_power)/heat_capacity, 1000)) env.merge(removed) air_update_turf() diff --git a/code/modules/research/xenobiology/crossbreeding/chilling.dm b/code/modules/research/xenobiology/crossbreeding/chilling.dm index 1405bbad51..5325680588 100644 --- a/code/modules/research/xenobiology/crossbreeding/chilling.dm +++ b/code/modules/research/xenobiology/crossbreeding/chilling.dm @@ -100,9 +100,8 @@ Chilling extracts: for(var/turf/open/T in A) var/datum/gas_mixture/G = T.air if(istype(G)) - G.gases[/datum/gas/plasma] = 0 + G.set_moles(/datum/gas/plasma, 0) filtered = TRUE - GAS_GARBAGE_COLLECT(G.gases) T.air_update_turf() if(filtered) user.visible_message("Cracks spread throughout [src], and some air is sucked in!") @@ -308,4 +307,4 @@ Chilling extracts: user.visible_message("[src] reflects an array of dazzling colors and light, energy rushing to nearby doors!") for(var/obj/machinery/door/airlock/door in area) new /obj/effect/forcefield/slimewall/rainbow(door.loc) - return ..() \ No newline at end of file + return ..() diff --git a/code/modules/surgery/organs/lungs.dm b/code/modules/surgery/organs/lungs.dm index b3020ae13f..be8b8d6b3f 100644 --- a/code/modules/surgery/organs/lungs.dm +++ b/code/modules/surgery/organs/lungs.dm @@ -131,13 +131,11 @@ var/gas_breathed = 0 - var/list/breath_gases = breath.gases - //Partial pressures in our breath - var/O2_pp = breath.get_breath_partial_pressure(breath_gases[/datum/gas/oxygen])+(8*breath.get_breath_partial_pressure(breath_gases[/datum/gas/pluoxium])) - var/N2_pp = breath.get_breath_partial_pressure(breath_gases[/datum/gas/nitrogen]) - var/Toxins_pp = breath.get_breath_partial_pressure(breath_gases[/datum/gas/plasma]) - var/CO2_pp = breath.get_breath_partial_pressure(breath_gases[/datum/gas/carbon_dioxide]) + var/O2_pp = breath.get_breath_partial_pressure(breath.get_moles(/datum/gas/oxygen))+(8*breath.get_breath_partial_pressure(breath.get_moles(/datum/gas/pluoxium))) + var/N2_pp = breath.get_breath_partial_pressure(breath.get_moles(/datum/gas/nitrogen)) + var/Toxins_pp = breath.get_breath_partial_pressure(breath.get_moles(/datum/gas/plasma)) + var/CO2_pp = breath.get_breath_partial_pressure(breath.get_moles(/datum/gas/carbon_dioxide)) //-- OXY --// @@ -145,7 +143,7 @@ //Too much oxygen! //Yes, some species may not like it. if(safe_oxygen_max) if((O2_pp > safe_oxygen_max) && safe_oxygen_max == 0) //I guess plasma men technically need to have a check. - var/ratio = (breath_gases[/datum/gas/oxygen]/safe_oxygen_max) * 10 + var/ratio = (breath.get_moles(/datum/gas/oxygen)/safe_oxygen_max) * 10 H.apply_damage_type(clamp(ratio, oxy_breath_dam_min, oxy_breath_dam_max), oxy_damage_type) H.throw_alert("too_much_oxy", /obj/screen/alert/too_much_oxy) @@ -168,18 +166,18 @@ //Too little oxygen! if(safe_oxygen_min) if(O2_pp < safe_oxygen_min) - gas_breathed = handle_too_little_breath(H, O2_pp, safe_oxygen_min, breath_gases[/datum/gas/oxygen]) + gas_breathed = handle_too_little_breath(H, O2_pp, safe_oxygen_min, breath.get_moles(/datum/gas/oxygen)) H.throw_alert("not_enough_oxy", /obj/screen/alert/not_enough_oxy) else H.failed_last_breath = FALSE if(H.health >= H.crit_threshold) H.adjustOxyLoss(-breathModifier) //More damaged lungs = slower oxy rate up to a factor of half - gas_breathed = breath_gases[/datum/gas/oxygen] + gas_breathed = breath.get_moles(/datum/gas/oxygen) H.clear_alert("not_enough_oxy") //Exhale - breath_gases[/datum/gas/oxygen] -= gas_breathed - breath_gases[/datum/gas/carbon_dioxide] += gas_breathed + breath.adjust_moles(/datum/gas/oxygen, -gas_breathed) + breath.adjust_moles(/datum/gas/carbon_dioxide, gas_breathed) gas_breathed = 0 //-- Nitrogen --// @@ -187,7 +185,7 @@ //Too much nitrogen! if(safe_nitro_max) if(N2_pp > safe_nitro_max) - var/ratio = (breath_gases[/datum/gas/nitrogen]/safe_nitro_max) * 10 + var/ratio = (breath.get_moles(/datum/gas/nitrogen)/safe_nitro_max) * 10 H.apply_damage_type(clamp(ratio, nitro_breath_dam_min, nitro_breath_dam_max), nitro_damage_type) H.throw_alert("too_much_nitro", /obj/screen/alert/too_much_nitro) H.losebreath += 2 @@ -197,18 +195,18 @@ //Too little nitrogen! if(safe_nitro_min) if(N2_pp < safe_nitro_min) - gas_breathed = handle_too_little_breath(H, N2_pp, safe_nitro_min, breath_gases[/datum/gas/nitrogen]) + gas_breathed = handle_too_little_breath(H, N2_pp, safe_nitro_min, breath.get_moles(/datum/gas/nitrogen)) H.throw_alert("nitro", /obj/screen/alert/not_enough_nitro) else H.failed_last_breath = FALSE if(H.health >= H.crit_threshold) H.adjustOxyLoss(-breathModifier) - gas_breathed = breath_gases[/datum/gas/nitrogen] + gas_breathed = breath.get_moles(/datum/gas/nitrogen) H.clear_alert("nitro") //Exhale - breath_gases[/datum/gas/nitrogen] -= gas_breathed - breath_gases[/datum/gas/carbon_dioxide] += gas_breathed + breath.adjust_moles(/datum/gas/nitrogen, -gas_breathed) + breath.adjust_moles(/datum/gas/carbon_dioxide, gas_breathed) gas_breathed = 0 //-- CO2 --// @@ -234,18 +232,18 @@ //Too little CO2! if(safe_co2_min) if(CO2_pp < safe_co2_min) - gas_breathed = handle_too_little_breath(H, CO2_pp, safe_co2_min, breath_gases[/datum/gas/carbon_dioxide]) + gas_breathed = handle_too_little_breath(H, CO2_pp, safe_co2_min, breath.get_moles(/datum/gas/carbon_dioxide)) H.throw_alert("not_enough_co2", /obj/screen/alert/not_enough_co2) else H.failed_last_breath = FALSE if(H.health >= H.crit_threshold) H.adjustOxyLoss(-breathModifier) - gas_breathed = breath_gases[/datum/gas/carbon_dioxide] + gas_breathed = breath.get_moles(/datum/gas/carbon_dioxide) H.clear_alert("not_enough_co2") //Exhale - breath_gases[/datum/gas/carbon_dioxide] -= gas_breathed - breath_gases[/datum/gas/oxygen] += gas_breathed + breath.adjust_moles(/datum/gas/carbon_dioxide, -gas_breathed) + breath.adjust_moles(/datum/gas/oxygen, gas_breathed) gas_breathed = 0 @@ -254,7 +252,7 @@ //Too much toxins! if(safe_toxins_max) if(Toxins_pp > safe_toxins_max) - var/ratio = (breath_gases[/datum/gas/plasma]/safe_toxins_max) * 10 + var/ratio = (breath.get_moles(/datum/gas/plasma)/safe_toxins_max) * 10 H.apply_damage_type(clamp(ratio, tox_breath_dam_min, tox_breath_dam_max), tox_damage_type) H.throw_alert("too_much_tox", /obj/screen/alert/too_much_tox) else @@ -264,18 +262,18 @@ //Too little toxins! if(safe_toxins_min) if(Toxins_pp < safe_toxins_min) - gas_breathed = handle_too_little_breath(H, Toxins_pp, safe_toxins_min, breath_gases[/datum/gas/plasma]) + gas_breathed = handle_too_little_breath(H, Toxins_pp, safe_toxins_min, breath.get_moles(/datum/gas/plasma)) H.throw_alert("not_enough_tox", /obj/screen/alert/not_enough_tox) else H.failed_last_breath = FALSE if(H.health >= H.crit_threshold) H.adjustOxyLoss(-breathModifier) - gas_breathed = breath_gases[/datum/gas/plasma] + gas_breathed = breath.get_moles(/datum/gas/plasma) H.clear_alert("not_enough_tox") //Exhale - breath_gases[/datum/gas/plasma] -= gas_breathed - breath_gases[/datum/gas/carbon_dioxide] += gas_breathed + breath.adjust_moles(/datum/gas/plasma, -gas_breathed) + breath.adjust_moles(/datum/gas/carbon_dioxide, gas_breathed) gas_breathed = 0 @@ -285,7 +283,7 @@ // N2O - var/SA_pp = breath.get_breath_partial_pressure(breath_gases[/datum/gas/nitrous_oxide]) + var/SA_pp = breath.get_breath_partial_pressure(breath.get_moles(/datum/gas/nitrous_oxide)) if(SA_pp > SA_para_min) // Enough to make us stunned for a bit H.Unconscious(60) // 60 gives them one second to wake up and run away a bit! if(SA_pp > SA_sleep_min) // Enough to make us sleep as well @@ -299,7 +297,7 @@ // BZ - var/bz_pp = breath.get_breath_partial_pressure(breath_gases[/datum/gas/bz]) + var/bz_pp = breath.get_breath_partial_pressure(breath.get_moles(/datum/gas/bz)) if(bz_pp > BZ_trip_balls_min) H.hallucination += 10 H.reagents.add_reagent(/datum/reagent/bz_metabolites,5) @@ -312,14 +310,14 @@ // Tritium - var/trit_pp = breath.get_breath_partial_pressure(breath_gases[/datum/gas/tritium]) + var/trit_pp = breath.get_breath_partial_pressure(breath.get_moles(/datum/gas/tritium)) if (trit_pp > 50) H.radiation += trit_pp/2 //If you're breathing in half an atmosphere of radioactive gas, you fucked up. else H.radiation += trit_pp/10 // Nitryl - var/nitryl_pp = breath.get_breath_partial_pressure(breath_gases[/datum/gas/nitryl]) + var/nitryl_pp = breath.get_breath_partial_pressure(breath.get_moles(/datum/gas/nitryl)) if (prob(nitryl_pp)) to_chat(H, "Your mouth feels like it's burning!") if (nitryl_pp >40) @@ -330,22 +328,22 @@ H.silent = max(H.silent, 3) else H.adjustFireLoss(nitryl_pp/4) - gas_breathed = breath_gases[/datum/gas/nitryl] + gas_breathed = breath.get_moles(/datum/gas/nitryl) if (gas_breathed > gas_stimulation_min) H.reagents.add_reagent(/datum/reagent/nitryl,1) - breath_gases[/datum/gas/nitryl]-=gas_breathed + breath.adjust_moles(/datum/gas/nitryl, -gas_breathed) // Stimulum - gas_breathed = breath_gases[/datum/gas/stimulum] + gas_breathed = breath.get_moles(/datum/gas/stimulum) if (gas_breathed > gas_stimulation_min) var/existing = H.reagents.get_reagent_amount(/datum/reagent/stimulum) H.reagents.add_reagent(/datum/reagent/stimulum, max(0, 5 - existing)) - breath_gases[/datum/gas/stimulum]-=gas_breathed + breath.adjust_moles(/datum/gas/stimulum, -gas_breathed) // Miasma - if (breath_gases[/datum/gas/miasma]) - var/miasma_pp = breath.get_breath_partial_pressure(breath_gases[/datum/gas/miasma]) + if (breath.get_moles(/datum/gas/miasma)) + var/miasma_pp = breath.get_breath_partial_pressure(breath.get_moles(/datum/gas/miasma)) if(miasma_pp > MINIMUM_MOLES_DELTA_TO_MOVE) //Miasma sickness @@ -385,14 +383,13 @@ // Then again, this is a purely hypothetical scenario and hardly reachable owner.adjust_disgust(0.1 * miasma_pp) - breath_gases[/datum/gas/miasma]-=gas_breathed + breath.adjust_moles(/datum/gas/miasma, -gas_breathed) // Clear out moods when no miasma at all else SEND_SIGNAL(owner, COMSIG_CLEAR_MOOD_EVENT, "smell") handle_breath_temperature(breath, H) - GAS_GARBAGE_COLLECT(breath.gases) return TRUE @@ -414,7 +411,7 @@ /obj/item/organ/lungs/proc/handle_breath_temperature(datum/gas_mixture/breath, mob/living/carbon/human/H) // called by human/life, handles temperatures - var/breath_temperature = breath.temperature + var/breath_temperature = breath.return_temperature() if(!HAS_TRAIT(H, TRAIT_RESISTCOLD)) // COLD DAMAGE var/cold_modifier = H.dna.species.coldmod @@ -536,8 +533,8 @@ /obj/item/organ/lungs/slime/check_breath(datum/gas_mixture/breath, mob/living/carbon/human/H) . = ..() - if (breath && breath.gases[/datum/gas/plasma]) - var/plasma_pp = breath.get_breath_partial_pressure(breath.gases[/datum/gas/plasma]) + if (breath) + var/plasma_pp = breath.get_breath_partial_pressure(breath.get_moles(/datum/gas/plasma)) owner.blood_volume += (0.2 * plasma_pp) // 10/s when breathing literally nothing but plasma, which will suffocate you. /obj/item/organ/lungs/yamerol diff --git a/code/modules/surgery/organs/organ_internal.dm b/code/modules/surgery/organs/organ_internal.dm index 761ebc17a2..ace2edab5b 100644 --- a/code/modules/surgery/organs/organ_internal.dm +++ b/code/modules/surgery/organs/organ_internal.dm @@ -106,7 +106,7 @@ if(istype(loc, /turf/))//Only concern is adding an organ to a freezer when the area around it is cold. var/turf/T = loc var/datum/gas_mixture/enviro = T.return_air() - local_temp = enviro.temperature + local_temp = enviro.return_temperature() else if(!owner && ismob(loc)) var/mob/M = loc @@ -116,7 +116,7 @@ return TRUE var/turf/T = M.loc var/datum/gas_mixture/enviro = T.return_air() - local_temp = enviro.temperature + local_temp = enviro.return_temperature() if(owner) //Don't interfere with bodies frozen by structures. diff --git a/modular_citadel/code/modules/mob/living/silicon/robot/dogborg_equipment.dm b/modular_citadel/code/modules/mob/living/silicon/robot/dogborg_equipment.dm index d5d1e56485..62f28262a2 100644 --- a/modular_citadel/code/modules/mob/living/silicon/robot/dogborg_equipment.dm +++ b/modular_citadel/code/modules/mob/living/silicon/robot/dogborg_equipment.dm @@ -110,57 +110,7 @@ SLEEPER CODE IS IN game/objects/items/devices/dogborg_sleeper.dm ! /obj/item/analyzer/nose/attack_self(mob/user) user.visible_message("[user] sniffs around the air.", "You sniff the air for gas traces.") - - var/turf/location = user.loc - if(!istype(location)) - return - - var/datum/gas_mixture/environment = location.return_air() - - var/pressure = environment.return_pressure() - var/total_moles = environment.total_moles() - - to_chat(user, "Results:") - if(abs(pressure - ONE_ATMOSPHERE) < 10) - to_chat(user, "Pressure: [round(pressure,0.1)] kPa") - else - to_chat(user, "Pressure: [round(pressure,0.1)] kPa") - if(total_moles) - var/list/env_gases = environment.gases - - var/o2_concentration = env_gases[/datum/gas/oxygen]/total_moles - var/n2_concentration = env_gases[/datum/gas/nitrogen]/total_moles - var/co2_concentration = env_gases[/datum/gas/carbon_dioxide]/total_moles - var/plasma_concentration = env_gases[/datum/gas/plasma]/total_moles - GAS_GARBAGE_COLLECT(environment.gases) - - if(abs(n2_concentration - N2STANDARD) < 20) - to_chat(user, "Nitrogen: [round(n2_concentration*100, 0.01)] %") - else - to_chat(user, "Nitrogen: [round(n2_concentration*100, 0.01)] %") - - if(abs(o2_concentration - O2STANDARD) < 2) - to_chat(user, "Oxygen: [round(o2_concentration*100, 0.01)] %") - else - to_chat(user, "Oxygen: [round(o2_concentration*100, 0.01)] %") - - if(co2_concentration > 0.01) - to_chat(user, "CO2: [round(co2_concentration*100, 0.01)] %") - else - to_chat(user, "CO2: [round(co2_concentration*100, 0.01)] %") - - if(plasma_concentration > 0.005) - to_chat(user, "Plasma: [round(plasma_concentration*100, 0.01)] %") - else - to_chat(user, "Plasma: [round(plasma_concentration*100, 0.01)] %") - - - for(var/id in env_gases) - if(id in GLOB.hardcoded_gases) - continue - var/gas_concentration = env_gases[id]/total_moles - to_chat(user, "[GLOB.meta_gas_names[id]]: [round(gas_concentration*100, 0.01)] %") - to_chat(user, "Temperature: [round(environment.temperature-T0C)] °C") + ..() /obj/item/analyzer/nose/afterattack(atom/target, mob/user, proximity) . = ..()