mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-08-30 16:47:13 +01:00
[MIRROR] [NO GBP] Fix superconduction overflow [MDB IGNORE] (#14266)
* [NO GBP] Fix superconduction overflow (#67684) * Documentation, parentheses, and more * Better comment for the inside multiplication * Even more parentheses Co-authored-by: LemonInTheDark <58055496+LemonInTheDark@ users.noreply.github.com> * Nicer commenting methinks Co-authored-by: LemonInTheDark <58055496+LemonInTheDark@ users.noreply.github.com> * [NO GBP] Fix superconduction overflow * [NO GBP] Fix superconduction overflow Co-authored-by: vincentiusvin <54709710+vincentiusvin@users.noreply.github.com> Co-authored-by: LemonInTheDark <58055496+LemonInTheDark@ users.noreply.github.com> Co-authored-by: Tom <8881105+tf-4@users.noreply.github.com>
This commit is contained in:
co-authored by
LemonInTheDark
vincentiusvin
Tom
parent
30df4f7dea
commit
3ca13816f5
@@ -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)))))
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -202,7 +202,7 @@
|
||||
if(turf_heat_capacity <= 0 || partial_heat_capacity <= 0)
|
||||
return TRUE
|
||||
|
||||
var/heat = thermal_conductivity * CALCULATE_CONDUCTION_ENERGY(delta_temperature, turf_heat_capacity, partial_heat_capacity)
|
||||
var/heat = CALCULATE_CONDUCTION_ENERGY(thermal_conductivity * delta_temperature, turf_heat_capacity, partial_heat_capacity)
|
||||
|
||||
air.temperature -= heat / total_heat_capacity
|
||||
if(!target.liquids.immutable)
|
||||
|
||||
Reference in New Issue
Block a user