diff --git a/code/__DEFINES/atmospherics/atmos_helpers.dm b/code/__DEFINES/atmospherics/atmos_helpers.dm index f53e5a67b36..e321404ad15 100644 --- a/code/__DEFINES/atmospherics/atmos_helpers.dm +++ b/code/__DEFINES/atmospherics/atmos_helpers.dm @@ -99,12 +99,17 @@ GLOBAL_LIST_INIT(atmos_adjacent_savings, list(0,0)) * * Not immediately obvious, but saves us operation time. * + * We put a lot of parentheses here because the numbers get really really big. + * By prioritizing the division we try to tone the number down so we dont get overflows. + * * Arguments: * * temperature_delta: T2 - T1. [/datum/gas_mixture/var/temperature] + * If you have any moderating (less than 1) coefficients and are dealing with very big numbers + * multiply the temperature_delta by it first before passing so we get even more breathing room. * * heat_capacity_one: gasmix one's [/datum/gas_mixture/proc/heat_capacity] * * heat_capacity_two: gasmix two's [/datum/gas_mixture/proc/heat_capacity] * Returns: The energy gained by gas mixture one. Negative if gas mixture one loses energy. * Honestly the heat capacity is interchangeable, just make sure the delta is right. */ #define CALCULATE_CONDUCTION_ENERGY(temperature_delta, heat_capacity_one, heat_capacity_two)\ - (temperature_delta * heat_capacity_one * heat_capacity_two / (heat_capacity_one+heat_capacity_two)) + ((temperature_delta) * ((heat_capacity_one) * ((heat_capacity_two) / ((heat_capacity_one) + (heat_capacity_two))))) diff --git a/code/modules/atmospherics/environmental/LINDA_turf_tile.dm b/code/modules/atmospherics/environmental/LINDA_turf_tile.dm index 002d46cff09..4cc7d10f7bb 100644 --- a/code/modules/atmospherics/environmental/LINDA_turf_tile.dm +++ b/code/modules/atmospherics/environmental/LINDA_turf_tile.dm @@ -650,7 +650,8 @@ Then we space some of our heat, and think about if we should stop conducting. if(heat_capacity <= 0 || abs(delta_temperature) <= MINIMUM_TEMPERATURE_DELTA_TO_CONSIDER) return // Heat should be positive in most cases - var/heat = thermal_conductivity * CALCULATE_CONDUCTION_ENERGY(delta_temperature, HEAT_CAPACITY_VACUUM, heat_capacity) + // coefficient applied first because some turfs have very big heat caps. + var/heat = CALCULATE_CONDUCTION_ENERGY(thermal_conductivity * delta_temperature, HEAT_CAPACITY_VACUUM, heat_capacity) temperature -= heat / heat_capacity /turf/open/proc/temperature_share_open_to_solid(turf/sharer) diff --git a/code/modules/atmospherics/gasmixtures/gas_mixture.dm b/code/modules/atmospherics/gasmixtures/gas_mixture.dm index 944b22c02bb..7e227dad419 100644 --- a/code/modules/atmospherics/gasmixtures/gas_mixture.dm +++ b/code/modules/atmospherics/gasmixtures/gas_mixture.dm @@ -443,7 +443,8 @@ GLOBAL_LIST_INIT(gaslist_cache, init_gaslist_cache()) sharer_heat_capacity = sharer_heat_capacity || sharer.heat_capacity(ARCHIVE) if((sharer_heat_capacity > MINIMUM_HEAT_CAPACITY) && (self_heat_capacity > MINIMUM_HEAT_CAPACITY)) - var/heat = conduction_coefficient * CALCULATE_CONDUCTION_ENERGY(temperature_delta, sharer_heat_capacity, self_heat_capacity) + // coefficient applied first because some turfs have very big heat caps. + var/heat = CALCULATE_CONDUCTION_ENERGY(conduction_coefficient * temperature_delta, sharer_heat_capacity, self_heat_capacity) temperature = max(temperature - heat/self_heat_capacity, TCMB) sharer_temperature = max(sharer_temperature + heat/sharer_heat_capacity, TCMB)