debug improvements

This commit is contained in:
duncathan
2017-04-03 19:59:25 -06:00
parent 55c1dffee1
commit d63eddd2ea
3 changed files with 43 additions and 19 deletions
@@ -417,7 +417,7 @@ var/list/gaslist_cache = init_gaslist_cache()
return ""
/datum/gas_mixture/react(turf/open/dump_location)
/datum/gas_mixture/react(turf/open/dump_location, debug)
. = 0
if(temperature < TCMB) //just for safety
temperature = TCMB
@@ -426,23 +426,27 @@ var/list/gaslist_cache = init_gaslist_cache()
var/list/cached_gases = gases
reaction_loop:
for(var/r in gas_reactions)
for(var/r in SSair.gas_reactions)
var/datum/gas_reaction/reaction = r
var/list/min_reqs = params2list(reaction.min_requirements)
var/list/min_reqs = reaction.min_requirements.Copy()
if((min_reqs["TEMP"] && temperature < text2num(min_reqs["TEMP"])) \
|| (min_reqs["ENER"] && thermal_energy() < text2num(min_reqs["ENER"])))
if(debug)
to_chat(world, "Reaction: [reaction.name] did not occur because temperature or energy requirements were not met.")
continue
min_reqs -= "TEMP"
min_reqs -= "ENER"
for(var/id in min_reqs)
if(cached_gases[id][MOLES] < text2num(min_reqs[id]))
if(debug)
to_chat(world, "Reaction: [reaction.name] did not occur because [id] requirements were not met. Requirement: [text2num(min_reqs[id])] moles. Current level: [cached_gases[id][MOLES]] moles.")
continue reaction_loop
//at this point, all minimum requirements for the reaction are satisfied.
/* currently no reactions have maximum requirements, so we can leave the checks commented out for a slight performance boost
var/list/max_reqs = params2list(reaction.max_requirements)
var/list/max_reqs = reaction.max_requirements.Copy()
if((max_reqs["TEMP"] && temperature > text2num(max_reqs["TEMP"])) \
|| (max_reqs["ENER"] && thermal_energy() > text2num(max_reqs["ENER"])))
continue
@@ -455,7 +459,10 @@ var/list/gaslist_cache = init_gaslist_cache()
//at this point, all requirements for the reaction are satisfied. we can now react()
*/
. |= reaction.react(src, dump_location)
var/result = reaction.react(src, dump_location)
. |= result
if(result && debug)
to_chat(world, "Reaction: [reaction.name] succesfully reacted.")
if(.)
garbage_collect()
@@ -1,7 +1,7 @@
#define NO_REACTION 0
#define REACTING 1
var/list/gas_reactions = init_gas_reactions() //this is our singleton of all reactions
/datum/controller/subsystem/air/var/list/gas_reactions //this is our singleton of all reactions
/proc/init_gas_reactions()
var/list/reaction_types = list()
@@ -15,10 +15,11 @@ var/list/gas_reactions = init_gas_reactions() //this is our singleton of all rea
return initial(b.priority) - initial(a.priority)
/datum/gas_reaction
var/min_requirements
var/max_requirements
var/list/min_requirements
var/list/max_requirements
var/exclude = FALSE //do it this way to allow for addition/removal of reactions midmatch in the future
var/priority //lower numbers are checked/react later than higher numbers. if two reactions have the same priority they may happen in either order
var/name = "reaction"
/datum/gas_reaction/New()
init_reqs()
@@ -30,9 +31,16 @@ var/list/gas_reactions = init_gas_reactions() //this is our singleton of all rea
//agent b: converts hot co2 and agent b to oxygen. requires plasma as a catalyst. endothermic
/datum/gas_reaction/agent_b
priority = 2
name = "Agent B"
/datum/gas_reaction/agent_b/init_reqs()
min_requirements = "TEMP=900;agent_b=0;plasma=[MINIMUM_HEAT_CAPACITY];co2=[MINIMUM_HEAT_CAPACITY]"
min_requirements = list(
"TEMP" = 900,
"agent_b" = 0,
"plasma" = MINIMUM_HEAT_CAPACITY,
"co2" = MINIMUM_HEAT_CAPACITY
)
/datum/gas_reaction/agent_b/react(datum/gas_mixture/air)
var/list/cached_gases = air.gases
@@ -51,9 +59,10 @@ var/list/gas_reactions = init_gas_reactions() //this is our singleton of all rea
//freon: does a freezy thing?
/datum/gas_reaction/freon
priority = 1
name = "Freon"
/datum/gas_reaction/freon/init_reqs()
min_requirements = "freon=[MOLES_PLASMA_VISIBLE]"
min_requirements = list("freon" = MOLES_PLASMA_VISIBLE)
/datum/gas_reaction/freon/react(datum/gas_mixture/air, turf/open/location)
. = NO_REACTION
@@ -64,9 +73,10 @@ var/list/gas_reactions = init_gas_reactions() //this is our singleton of all rea
//water vapor: puts out fires?
/datum/gas_reaction/water_vapor
priority = 1
name = "Water Vapor"
/datum/gas_reaction/water_vapor/init_reqs()
min_requirements = "water_vapor=[MOLES_PLASMA_VISIBLE]"
min_requirements = list("water_vapor" = MOLES_PLASMA_VISIBLE)
/datum/gas_reaction/water_vapor/react(datum/gas_mixture/air, turf/open/location)
. = NO_REACTION
@@ -77,9 +87,10 @@ var/list/gas_reactions = init_gas_reactions() //this is our singleton of all rea
//fire: combustion of plasma and volatile fuel (treated as hydrocarbons). creates hotspots. exothermic
/datum/gas_reaction/fire
priority = -1 //fire should ALWAYS be last
name = "Hydrocarbon Combustion"
/datum/gas_reaction/fire/init_reqs()
min_requirements = "TEMP=[FIRE_MINIMUM_TEMPERATURE_TO_EXIST]" //doesn't include plasma reqs b/c of volatile fuel stuff - consider finally axing volatile fuel
min_requirements = list("TEMP" = FIRE_MINIMUM_TEMPERATURE_TO_EXIST) //doesn't include plasma reqs b/c of volatile fuel stuff - consider finally axing volatile fuel
/datum/gas_reaction/fire/react(datum/gas_mixture/air, turf/open/location)
var/energy_released = 0
@@ -146,23 +157,28 @@ var/list/gas_reactions = init_gas_reactions() //this is our singleton of all rea
//to_chat(world, "post [temperature], [cached_gases["o2"][MOLES]], [cached_gases["plasma"][MOLES]]")
//let the floor know a fire is happening
var/loc_temperature = location.air.temperature
var/loc_air = location.air
if(loc_temperature > FIRE_MINIMUM_TEMPERATURE_TO_EXIST)
location.hotspot_expose(loc_temperature, CELL_VOLUME)
temperature = air.temperature
if(temperature > FIRE_MINIMUM_TEMPERATURE_TO_EXIST)
location.hotspot_expose(temperature, CELL_VOLUME)
for(var/I in location)
var/atom/movable/item = I
item.temperature_expose(loc_air, loc_temperature, CELL_VOLUME)
location.temperature_expose(loc_air, loc_temperature, CELL_VOLUME)
item.temperature_expose(air, temperature, CELL_VOLUME)
location.temperature_expose(air, temperature, CELL_VOLUME)
return air.fuel_burnt ? REACTING : NO_REACTION
//fusion: a terrible idea that was fun to try. turns co2 and plasma into REALLY HOT oxygen and nitrogen. super exothermic lol
/datum/gas_reaction/fusion
exclude = TRUE
priority = 2
name = "Plasmic Fusion"
/datum/gas_reaction/fusion/init_reqs()
min_requirements = "ENER=[PLASMA_BINDING_ENERGY*10];plasma=[MINIMUM_HEAT_CAPACITY];co2=[MINIMUM_HEAT_CAPACITY]"
min_requirements = list(
"ENER" = PLASMA_BINDING_ENERGY * 10,
"plasma" = MINIMUM_HEAT_CAPACITY,
"co2" = MINIMUM_HEAT_CAPACITY
)
/datum/gas_reaction/fusion/react(datum/gas_mixture/air)
var/list/cached_gases = air.gases