Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
silicons committed Oct 20, 2024
1 parent 28d2914 commit 26e6e68
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions code/modules/atmospherics/gasmixtures/gas_mixture-share.dm
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@
#ifdef CF_ATMOS_XGM_UPDATE_VALUES_ASSERTIONS
ASSERT(gas ~= debug_gas_archive)
#endif
// if both of us are empty, bail or division by zero's happen later
// this proc can handle up to one empty mixture after this check, as this check
// throws out cases of two empty mixtures
if(!total_moles && !other.total_moles)
return

// tally total group multiplier & volume for further processing
var/total_effective_volume = src.group_multiplier * src.volume + other.group_multiplier * other.volume
Expand All @@ -46,8 +51,12 @@
var/mol_existing_B = other.gas[gas]
// tally specific heat while we're at it to save a proccall and more iteration
var/specific_heat = global.gas_data.specific_heats[gas]
our_specific_heat += (specific_heat * mol_existing_A) / src.total_moles
their_specific_heat += (specific_heat * mol_existing_B) / other.total_moles
// if we're empty, we have no specific heat
if(src.total_moles)
our_specific_heat += (specific_heat * mol_existing_A) / src.total_moles
// if they're empty, they have no specific heat
if(other.total_moles)
their_specific_heat += (specific_heat * mol_existing_B) / other.total_moles
// combine both, calculate the amount actualyl being shared, then split to to each by volume
// need to divide out group multiplier too, as volume takes that into account
var/combined = (mol_existing_A * src.group_multiplier + mol_existing_B * other.group_multiplier) * ratio
Expand Down

0 comments on commit 26e6e68

Please sign in to comment.