|
|
|
@@ -15,15 +15,16 @@ GLOBAL_LIST_INIT(meta_gas_overlays, meta_gas_overlay_list())
|
|
|
|
|
GLOBAL_LIST_INIT(meta_gas_dangers, meta_gas_danger_list())
|
|
|
|
|
GLOBAL_LIST_INIT(meta_gas_ids, meta_gas_id_list())
|
|
|
|
|
GLOBAL_LIST_INIT(meta_gas_fusions, meta_gas_fusion_list())
|
|
|
|
|
|
|
|
|
|
/datum/gas_mixture
|
|
|
|
|
var/list/gases = list()
|
|
|
|
|
var/tmp/list/gases_archived = list()
|
|
|
|
|
var/temperature = 0 //kelvins
|
|
|
|
|
var/tmp/temperature_archived = 0
|
|
|
|
|
var/volume = CELL_VOLUME //liters
|
|
|
|
|
var/last_share = 0
|
|
|
|
|
var/list/reaction_results = list()
|
|
|
|
|
var/list/analyzer_results //used for analyzer feedback - not initialized until its used
|
|
|
|
|
var/gc_share = FALSE // Whether to call garbage_collect() on the sharer during shares, used for immutable mixtures
|
|
|
|
|
|
|
|
|
|
/datum/gas_mixture/New(volume)
|
|
|
|
|
if (!isnull(volume))
|
|
|
|
@@ -219,7 +220,7 @@ GLOBAL_LIST_INIT(meta_gas_fusions, meta_gas_fusion_list())
|
|
|
|
|
|
|
|
|
|
/datum/gas_mixture/share(datum/gas_mixture/sharer, atmos_adjacent_turfs = 4)
|
|
|
|
|
|
|
|
|
|
var/list/cached_gases = gases
|
|
|
|
|
var/list/cached_gases = gases_archived
|
|
|
|
|
var/list/sharer_gases = sharer.gases
|
|
|
|
|
|
|
|
|
|
var/temperature_delta = temperature_archived - sharer.temperature_archived
|
|
|
|
@@ -242,10 +243,28 @@ GLOBAL_LIST_INIT(meta_gas_fusions, meta_gas_fusion_list())
|
|
|
|
|
var/gas_heat_capacity
|
|
|
|
|
//and also cache this shit rq because that results in sanic speed for reasons byond explanation
|
|
|
|
|
var/list/cached_gasheats = GLOB.meta_gas_specific_heats
|
|
|
|
|
|
|
|
|
|
//Do this early and save doing TWO MORE (probable) LIST ACCESSES!!
|
|
|
|
|
var/our_moles
|
|
|
|
|
var/their_moles
|
|
|
|
|
|
|
|
|
|
//decs are expensive
|
|
|
|
|
var/us
|
|
|
|
|
var/them
|
|
|
|
|
|
|
|
|
|
//GAS TRANSFER
|
|
|
|
|
for(var/id in cached_gases | sharer_gases) // transfer gases
|
|
|
|
|
us = cached_gases[id]
|
|
|
|
|
them = sharer_gases[id]
|
|
|
|
|
|
|
|
|
|
delta = QUANTIZE(cached_gases[id] - sharer_gases[id])/(atmos_adjacent_turfs+1) //the amount of gas that gets moved between the mixtures
|
|
|
|
|
//buitl in garbage collect
|
|
|
|
|
if(max(us, them) <= ATMOS_QUANTIZATION_ACCURACY)
|
|
|
|
|
cached_gases -= id
|
|
|
|
|
sharer_gases -= id
|
|
|
|
|
continue
|
|
|
|
|
|
|
|
|
|
delta = QUANTIZE(us - them)/(atmos_adjacent_turfs+1) //the amount of gas that gets moved between the mixtures
|
|
|
|
|
our_moles += cached
|
|
|
|
|
|
|
|
|
|
if(delta && abs_temperature_delta > MINIMUM_TEMPERATURE_DELTA_TO_CONSIDER)
|
|
|
|
|
gas_heat_capacity = delta * cached_gasheats[id]
|
|
|
|
@@ -259,6 +278,9 @@ GLOBAL_LIST_INIT(meta_gas_fusions, meta_gas_fusion_list())
|
|
|
|
|
moved_moles += delta
|
|
|
|
|
abs_moved_moles += abs(delta)
|
|
|
|
|
|
|
|
|
|
our_moles += cached_gases[id]
|
|
|
|
|
their_moles += sharer_gases[id]
|
|
|
|
|
|
|
|
|
|
last_share = abs_moved_moles
|
|
|
|
|
|
|
|
|
|
//THERMAL ENERGY TRANSFER
|
|
|
|
@@ -278,13 +300,7 @@ GLOBAL_LIST_INIT(meta_gas_fusions, meta_gas_fusion_list())
|
|
|
|
|
if(abs(new_sharer_heat_capacity/old_sharer_heat_capacity - 1) < 0.1) // <10% change in sharer heat capacity
|
|
|
|
|
temperature_share(sharer, OPEN_HEAT_TRANSFER_COEFFICIENT)
|
|
|
|
|
|
|
|
|
|
if (initial(sharer.gc_share))
|
|
|
|
|
GAS_GARBAGE_COLLECT(sharer.gases)
|
|
|
|
|
if(temperature_delta > MINIMUM_TEMPERATURE_TO_MOVE || abs(moved_moles) > MINIMUM_MOLES_DELTA_TO_MOVE)
|
|
|
|
|
var/our_moles
|
|
|
|
|
TOTAL_MOLES(cached_gases,our_moles)
|
|
|
|
|
var/their_moles
|
|
|
|
|
TOTAL_MOLES(sharer_gases,their_moles)
|
|
|
|
|
return (temperature_archived*(our_moles + moved_moles) - sharer.temperature_archived*(their_moles - moved_moles)) * R_IDEAL_GAS_EQUATION / volume
|
|
|
|
|
|
|
|
|
|
/datum/gas_mixture/temperature_share(datum/gas_mixture/sharer, conduction_coefficient, sharer_temperature, sharer_heat_capacity)
|
|
|
|
|