From 648040de9c1866f582847569c9f92d27c067da05 Mon Sep 17 00:00:00 2001 From: vuonojenmustaturska Date: Fri, 6 Oct 2017 01:58:25 +0300 Subject: [PATCH 1/2] Makes a couple of atmos procs a tiny bit faster, removes /datum/gas_mixture/thermal_energy() (#31321) * Atmos stuff * moved the define --- code/__DEFINES/atmospherics.dm | 2 ++ code/modules/atmospherics/gasmixtures/gas_mixture.dm | 5 +---- code/modules/atmospherics/gasmixtures/reactions.dm | 4 ++-- code/modules/atmospherics/machinery/datum_pipeline.dm | 2 +- 4 files changed, 6 insertions(+), 7 deletions(-) diff --git a/code/__DEFINES/atmospherics.dm b/code/__DEFINES/atmospherics.dm index a79850b04f..c6ca2cf0ec 100644 --- a/code/__DEFINES/atmospherics.dm +++ b/code/__DEFINES/atmospherics.dm @@ -174,3 +174,5 @@ #define LAVALAND_EQUIPMENT_EFFECT_PRESSURE 50 //what pressure you have to be under to increase the effect of equipment meant for lavaland #define LAVALAND_DEFAULT_ATMOS "o2=14;n2=23;TEMP=300" + +#define THERMAL_ENERGY(gas) (gas.temperature * gas.heat_capacity()) \ No newline at end of file diff --git a/code/modules/atmospherics/gasmixtures/gas_mixture.dm b/code/modules/atmospherics/gasmixtures/gas_mixture.dm index ad1ba46d86..ac8349f5f7 100644 --- a/code/modules/atmospherics/gasmixtures/gas_mixture.dm +++ b/code/modules/atmospherics/gasmixtures/gas_mixture.dm @@ -119,9 +119,6 @@ GLOBAL_LIST_INIT(gaslist_cache, init_gaslist_cache()) /datum/gas_mixture/proc/return_volume() //liters return max(0, volume) -/datum/gas_mixture/proc/thermal_energy() //joules - return temperature * heat_capacity() - /datum/gas_mixture/proc/archive() //Update archived versions of variables //Returns: 1 in all cases @@ -424,7 +421,7 @@ GLOBAL_LIST_INIT(gaslist_cache, init_gaslist_cache()) var/list/cached_gases = gases var/temp = temperature - var/ener = thermal_energy() + var/ener = THERMAL_ENERGY(src) reaction_loop: for(var/r in SSair.gas_reactions) diff --git a/code/modules/atmospherics/gasmixtures/reactions.dm b/code/modules/atmospherics/gasmixtures/reactions.dm index a37e4d61c4..abbfcf8924 100644 --- a/code/modules/atmospherics/gasmixtures/reactions.dm +++ b/code/modules/atmospherics/gasmixtures/reactions.dm @@ -199,13 +199,13 @@ var/old_heat_capacity = air.heat_capacity() var/carbon_efficency = min(cached_gases["plasma"][MOLES]/cached_gases["co2"][MOLES],MAX_CARBON_EFFICENCY) - var/reaction_energy = air.thermal_energy() + var/reaction_energy = THERMAL_ENERGY(air) var/moles_impurities = air.total_moles()-(cached_gases["plasma"][MOLES]+cached_gases["co2"][MOLES]) var/plasma_fused = (PLASMA_FUSED_COEFFICENT*carbon_efficency)*(temperature/PLASMA_BINDING_ENERGY) var/carbon_catalyzed = (CARBON_CATALYST_COEFFICENT*carbon_efficency)*(temperature/PLASMA_BINDING_ENERGY) var/oxygen_added = carbon_catalyzed - var/nitrogen_added = (plasma_fused-oxygen_added)-(air.thermal_energy()/PLASMA_BINDING_ENERGY) + var/nitrogen_added = (plasma_fused-oxygen_added)-(THERMAL_ENERGY(air)/PLASMA_BINDING_ENERGY) reaction_energy = max(reaction_energy+((carbon_efficency*cached_gases["plasma"][MOLES])/((moles_impurities/carbon_efficency)+2)*10)+((plasma_fused/(moles_impurities/carbon_efficency))*PLASMA_BINDING_ENERGY),0) diff --git a/code/modules/atmospherics/machinery/datum_pipeline.dm b/code/modules/atmospherics/machinery/datum_pipeline.dm index 11a7881a98..ad7fdb921a 100644 --- a/code/modules/atmospherics/machinery/datum_pipeline.dm +++ b/code/modules/atmospherics/machinery/datum_pipeline.dm @@ -232,7 +232,7 @@ total_gas_mixture.merge(G) - total_thermal_energy += G.thermal_energy() + total_thermal_energy += THERMAL_ENERGY(G) total_heat_capacity += G.heat_capacity() total_gas_mixture.temperature = total_heat_capacity ? total_thermal_energy/total_heat_capacity : 0