diff --git a/code/__DEFINES/atmospherics_defines.dm b/code/__DEFINES/atmospherics_defines.dm index ae6031aea77..8c421a9b610 100644 --- a/code/__DEFINES/atmospherics_defines.dm +++ b/code/__DEFINES/atmospherics_defines.dm @@ -157,6 +157,11 @@ /// The coefficient c for a function of the form: 1 - (a / (x + c)^2) which gives a decomposition rate of 0.5 at 50000 Kelvin /// And a decomposition rate close to 0 at 1400 Kelvin #define N2O_DECOMPOSITION_COEFFICIENT_C 115930.77913 +/// Agent B starts working at this temperature +#define AGENT_B_CONVERSION_MIN_TEMP 900 +/// Agent B released this much energy per mole of CO2 converted to O2 +#define AGENT_B_CONVERSION_ENERGY_RELEASED 20000 + // From milla/src/model.rs, line 126 #define ATMOS_MODE_SPACE 0 //! Tile is exposed to space and loses air every second #define ATMOS_MODE_SEALED 1 //! Tile has no special behaviour diff --git a/code/modules/atmospherics/gasmixtures/gas_mixture.dm b/code/modules/atmospherics/gasmixtures/gas_mixture.dm index 510b981fcee..29b3464c028 100644 --- a/code/modules/atmospherics/gasmixtures/gas_mixture.dm +++ b/code/modules/atmospherics/gasmixtures/gas_mixture.dm @@ -560,16 +560,20 @@ What are the archived variables for? /datum/gas_mixture/proc/react(atom/dump_location) var/reacting = FALSE //set to TRUE if a notable reaction occured (used by pipe_network) - if((private_agent_b > MINIMUM_MOLE_COUNT) && private_temperature > 900) + if((private_agent_b > MINIMUM_MOLE_COUNT) && private_temperature > AGENT_B_CONVERSION_MIN_TEMP) if(private_toxins > MINIMUM_HEAT_CAPACITY && private_carbon_dioxide > MINIMUM_HEAT_CAPACITY) var/reaction_rate = min(private_carbon_dioxide * 0.75, private_toxins * 0.25, private_agent_b * 0.05) + var/old_heat_capacity = heat_capacity() + var/energy_released = reaction_rate * AGENT_B_CONVERSION_ENERGY_RELEASED private_carbon_dioxide -= reaction_rate private_oxygen += reaction_rate private_agent_b -= reaction_rate * 0.05 - private_temperature += (reaction_rate * 20000) / heat_capacity() + var/new_heat_capacity = heat_capacity() + if(new_heat_capacity > MINIMUM_HEAT_CAPACITY) + private_temperature = (private_temperature * old_heat_capacity + energy_released) / new_heat_capacity reacting = TRUE diff --git a/rust/src/milla/simulate.rs b/rust/src/milla/simulate.rs index 2cdc5ab964d..05cd43bd537 100644 --- a/rust/src/milla/simulate.rs +++ b/rust/src/milla/simulate.rs @@ -560,10 +560,9 @@ pub(crate) fn react(my_next_tile: &mut Tile, hotspot_step: bool) { my_next_tile .gases .set_agent_b(my_next_tile.gases.agent_b() - co2_converted * 0.05); - // Recalculate existing thermal energy to account for the change in heat capacity. + // Recalculate heat capacity. cached_heat_capacity = fraction * my_next_tile.heat_capacity(); - thermal_energy = cached_temperature * cached_heat_capacity; - // THEN we can add in the new thermal energy. + // Add in the new thermal energy. thermal_energy += AGENT_B_CONVERSION_ENERGY * co2_converted; // Recalculate temperature for any subsequent reactions. cached_temperature = thermal_energy / cached_heat_capacity; @@ -588,10 +587,9 @@ pub(crate) fn react(my_next_tile: &mut Tile, hotspot_step: bool) { .gases .set_oxygen(my_next_tile.gases.oxygen() + nitrous_decomposed / 2.0); - // Recalculate existing thermal energy to account for the change in heat capacity. + // Recalculate heat capacity. cached_heat_capacity = fraction * my_next_tile.heat_capacity(); - thermal_energy = cached_temperature * cached_heat_capacity; - // THEN we can add in the new thermal energy. + // Add in the new thermal energy. thermal_energy += NITROUS_BREAKDOWN_ENERGY * nitrous_decomposed; // Recalculate temperature for any subsequent reactions. cached_temperature = thermal_energy / cached_heat_capacity; @@ -634,9 +632,8 @@ pub(crate) fn react(my_next_tile: &mut Tile, hotspot_step: bool) { .gases .set_oxygen(my_next_tile.gases.oxygen() - plasma_burnt * PLASMA_BURN_OXYGEN_PER_PLASMA); - // Recalculate existing thermal energy to account for the change in heat capacity. + // Recalculate heat capacity. cached_heat_capacity = fraction * my_next_tile.heat_capacity(); - thermal_energy = cached_temperature * cached_heat_capacity; // THEN we can add in the new thermal energy. thermal_energy += PLASMA_BURN_ENERGY * plasma_burnt; // Recalculate temperature for any subsequent reactions. @@ -681,8 +678,9 @@ pub(crate) fn apply_tile_mode( if my_next_tile.temperature() > SPACE_COOLING_THRESHOLD { let excess_thermal_energy = my_next_tile.thermal_energy - SPACE_COOLING_THRESHOLD * my_next_tile.heat_capacity(); - let cooling = (SPACE_COOLING_FLAT + SPACE_COOLING_TEMPERATURE_RATIO * my_next_tile.temperature()) - .min(excess_thermal_energy); + let cooling = (SPACE_COOLING_FLAT + + SPACE_COOLING_TEMPERATURE_RATIO * my_next_tile.temperature()) + .min(excess_thermal_energy); my_next_tile.thermal_energy -= cooling; } } diff --git a/rustlibs_515.dll b/rustlibs_515.dll index dfa6d3fab19..a4fbe8dc5b4 100644 Binary files a/rustlibs_515.dll and b/rustlibs_515.dll differ diff --git a/rustlibs_515_prod.dll b/rustlibs_515_prod.dll index 42d98d6532c..865dba9cb08 100644 Binary files a/rustlibs_515_prod.dll and b/rustlibs_515_prod.dll differ diff --git a/rustlibs_516.dll b/rustlibs_516.dll index 448abf2f6d4..68cba82245e 100644 Binary files a/rustlibs_516.dll and b/rustlibs_516.dll differ diff --git a/rustlibs_516_prod.dll b/rustlibs_516_prod.dll index 1e662b32d24..2b6955c58ba 100644 Binary files a/rustlibs_516_prod.dll and b/rustlibs_516_prod.dll differ diff --git a/tools/ci/librustlibs_ci_515.so b/tools/ci/librustlibs_ci_515.so index e47d1287109..cfce5816183 100644 Binary files a/tools/ci/librustlibs_ci_515.so and b/tools/ci/librustlibs_ci_515.so differ diff --git a/tools/ci/librustlibs_ci_516.so b/tools/ci/librustlibs_ci_516.so index 6a1a55ef0a2..5d6752530e2 100644 Binary files a/tools/ci/librustlibs_ci_516.so and b/tools/ci/librustlibs_ci_516.so differ