Fixes issues with group_multiplier, filtering lists

This commit is contained in:
mwerezak
2014-08-04 20:56:22 -04:00
parent 949cdd275b
commit d662c5e804
2 changed files with 20 additions and 10 deletions

View File

@@ -61,7 +61,7 @@
if (source.total_moles < MINUMUM_MOLES_TO_FILTER) //if we cant transfer enough gas just stop to avoid further processing if (source.total_moles < MINUMUM_MOLES_TO_FILTER) //if we cant transfer enough gas just stop to avoid further processing
return -1 return -1
filtering &= source.gas //only filter gasses that are actually there. filtering = filtering & source.gas //only filter gasses that are actually there. DO NOT USE &=
//Determine the specific power of each filterable gas type, and the total amount of filterable gas (gasses selected to be scrubbed) //Determine the specific power of each filterable gas type, and the total amount of filterable gas (gasses selected to be scrubbed)
var/total_filterable_moles = 0 //the total amount of filterable gas var/total_filterable_moles = 0 //the total amount of filterable gas
@@ -135,7 +135,7 @@
if (source.total_moles < MINUMUM_MOLES_TO_FILTER) //if we cant transfer enough gas just stop to avoid further processing if (source.total_moles < MINUMUM_MOLES_TO_FILTER) //if we cant transfer enough gas just stop to avoid further processing
return -1 return -1
filtering &= source.gas //only filter gasses that are actually there. filtering = filtering & source.gas //only filter gasses that are actually there. DO NOT USE &=
var/total_specific_power = 0 //the power required to remove one mole of input gas var/total_specific_power = 0 //the power required to remove one mole of input gas
var/total_filterable_moles = 0 //the total amount of filterable gas var/total_filterable_moles = 0 //the total amount of filterable gas
@@ -212,7 +212,7 @@
if (source.total_moles < MINUMUM_MOLES_TO_FILTER) //if we cant transfer enough gas just stop to avoid further processing if (source.total_moles < MINUMUM_MOLES_TO_FILTER) //if we cant transfer enough gas just stop to avoid further processing
return -1 return -1
filtering &= source.gas //only filter gasses that are actually there. filtering = filtering & source.gas //only filter gasses that are actually there. DO NOT USE &=
var/total_specific_power = 0 //the power required to remove one mole of input gas var/total_specific_power = 0 //the power required to remove one mole of input gas
var/total_filterable_moles = 0 //the total amount of filterable gas var/total_filterable_moles = 0 //the total amount of filterable gas
@@ -390,12 +390,15 @@
//Calling update_use_power() or use_power() too often will result in lag since updating area power can be costly. //Calling update_use_power() or use_power() too often will result in lag since updating area power can be costly.
//This proc implements an approximation scheme that will cause area power updates to be triggered less often. //This proc implements an approximation scheme that will cause area power updates to be triggered less often.
//By having atmos machinery use this proc it is easy to change the power usage approximation for all atmos machines //By having atmos machinery use this proc it is easy to change the power usage approximation for all atmos machines
/obj/machinery/atmospherics/proc/handle_power_draw(var/usage_amount) /obj/machinery/proc/handle_power_draw(var/usage_amount)
//***This scheme errs on the side of using more power. Using this will mean that sometimes atmos machines use more power than they need, but won't get power for free. //***This scheme errs on the side of using more power. Using this will mean that sometimes atmos machines use more power than they need, but won't get power for free.
if (usage_amount > idle_power_usage) if (usage_amount > idle_power_usage)
update_use_power(1) update_use_power(2)
else else
use_power = 1 //Don't update here. We will use more power than we are supposed to, but trigger less area power updates. if (use_power >= 2)
use_power = 1 //Don't update here. We will use more power than we are supposed to, but trigger less area power updates.
else
update_use_power(1)
switch (use_power) switch (use_power)
if (0) return 0 if (0) return 0

View File

@@ -22,7 +22,10 @@
if(moles == 0) if(moles == 0)
return return
gas[gasid] += moles if (group_multiplier != 1)
gas[gasid] += moles/group_multiplier
else
gas[gasid] += moles
if(update) if(update)
update_values() update_values()
@@ -39,7 +42,10 @@
if(combined_heat_capacity != 0) if(combined_heat_capacity != 0)
temperature = (temp * giver_heat_capacity + temperature * self_heat_capacity) / combined_heat_capacity temperature = (temp * giver_heat_capacity + temperature * self_heat_capacity) / combined_heat_capacity
gas[gasid] += moles if (group_multiplier != 1)
gas[gasid] += moles/group_multiplier
else
gas[gasid] += moles
if(update) if(update)
update_values() update_values()
@@ -94,7 +100,7 @@
if (temperature < TCMB || total_moles == 0) if (temperature < TCMB || total_moles == 0)
return 0 return 0
var/heat_capacity = heat_capacity() var/heat_capacity = heat_capacity()*group_multiplier
if (thermal_energy < 0) if (thermal_energy < 0)
var/thermal_energy_limit = -(temperature - TCMB)*heat_capacity //ensure temperature does not go below TCMB var/thermal_energy_limit = -(temperature - TCMB)*heat_capacity //ensure temperature does not go below TCMB
thermal_energy = max( thermal_energy, thermal_energy_limit ) thermal_energy = max( thermal_energy, thermal_energy_limit )
@@ -103,7 +109,7 @@
//Returns the thermal energy change required to get to a new temperature //Returns the thermal energy change required to get to a new temperature
/datum/gas_mixture/proc/get_thermal_energy_change(var/new_temperature) /datum/gas_mixture/proc/get_thermal_energy_change(var/new_temperature)
return heat_capacity()*(new_temperature - temperature) return heat_capacity()*group_multiplier*(new_temperature - temperature)
//Technically vacuum doesn't have a specific entropy. Just use a really big number (infinity would be ideal) here so that it's easy to add gas to vacuum and hard to take gas out. //Technically vacuum doesn't have a specific entropy. Just use a really big number (infinity would be ideal) here so that it's easy to add gas to vacuum and hard to take gas out.
#define SPECIFIC_ENTROPY_VACUUM 150000 #define SPECIFIC_ENTROPY_VACUUM 150000
@@ -126,6 +132,7 @@
var/molar_mass = gas_data.molar_mass[gasid] var/molar_mass = gas_data.molar_mass[gasid]
var/specific_heat = gas_data.specific_heat[gasid] var/specific_heat = gas_data.specific_heat[gasid]
//group_multiplier gets divided out in volume/gas[gasid]
return R_IDEAL_GAS_EQUATION * ( log( (IDEAL_GAS_ENTROPY_CONSTANT*volume/gas[gasid]) * sqrt((molar_mass*specific_heat*temperature)**3) + 1 ) + 5/2 ) return R_IDEAL_GAS_EQUATION * ( log( (IDEAL_GAS_ENTROPY_CONSTANT*volume/gas[gasid]) * sqrt((molar_mass*specific_heat*temperature)**3) + 1 ) + 5/2 )
//Updates the total_moles count and trims any empty gases. //Updates the total_moles count and trims any empty gases.