associative list

This commit is contained in:
duncathan
2015-12-29 13:33:12 -06:00
parent cc9c5768ca
commit 17f167bcb7
44 changed files with 473 additions and 371 deletions
@@ -1,10 +1,10 @@
#define FILTER_NOTHING -1
//very cleverly using the gas index defines so as to simplify a bunch of logic
#define FILTER_PLASMA GAS_PL
#define FILTER_OXYGEN GAS_O2
#define FILTER_NITROGEN GAS_N2
#define FILTER_CARBONDIOXIDE GAS_CO2
#define FILTER_NITROUSOXIDE GAS_N2O
#define FILTER_NOTHING ""
//very cleverly using the gas IDs so as to simplify a bunch of logic
#define FILTER_PLASMA "plasma"
#define FILTER_OXYGEN "o2"
#define FILTER_NITROGEN "n2"
#define FILTER_CARBONDIOXIDE "co2"
#define FILTER_NITROUSOXIDE "n2o"
/obj/machinery/atmospherics/components/trinary/filter
icon_state = "filter_off"
@@ -109,12 +109,15 @@ Filter types:
var/datum/gas_mixture/filtered_out = new
filtered_out.temperature = removed.temperature
if(filter_type > 0)
if(filter_type && removed.gases[filter_type])
filtered_out.assert_gas(filter_type)
filtered_out.gases[filter_type][MOLES] = removed.gases[filter_type][MOLES]
removed.gases[filter_type][MOLES] = 0
if(filter_type == FILTER_PLASMA)
filtered_out.gases[GAS_AGENT_B][MOLES] = removed.gases[GAS_AGENT_B][MOLES]
removed.gases[GAS_AGENT_B][MOLES] = 0
if(filter_type == FILTER_PLASMA && removed.gases["agent_b"])
filtered_out.assert_gas("agent_b")
filtered_out.gases["agent_b"][MOLES] = removed.gases["agent_b"][MOLES]
removed.gases["agent_b"][MOLES] = 0
removed.garbage_collect()
else
filtered_out = null
@@ -269,7 +269,7 @@
if(occupant.bodytemperature < T0C)
occupant.sleeping = max(5 / efficiency, (1 / occupant.bodytemperature) * 2000 / efficiency)
occupant.Paralyse(max(5 / efficiency, (1 / occupant.bodytemperature) * 3000 / efficiency))
if(air_contents.gases[GAS_O2][MOLES] > 2)
if(air_contents.gases["o2"] && air_contents.gases["o2"][MOLES] > 2)
if(occupant.getOxyLoss()) occupant.adjustOxyLoss(-1)
else
occupant.adjustOxyLoss(-1)
@@ -46,7 +46,8 @@
var/added_oxygen = oxygen_content - total_moles
air_contents.temperature = (current_heat_capacity*air_contents.temperature + 20*added_oxygen*T0C)/(current_heat_capacity+20*added_oxygen)
air_contents.gases[GAS_O2][MOLES] += added_oxygen
air_contents.assert_gas("o2")
air_contents.gases["o2"][MOLES] += added_oxygen
update_parents()
@@ -14,27 +14,28 @@
air_contents.volume = volume
air_contents.temperature = T20C
if(gas_type)
air_contents.assert_gas(gas_type)
air_contents.gases[gas_type][MOLES] = AIR_CONTENTS
name = "[name] ([air_contents.gases[gas_type][GAS_NAME]])"
/obj/machinery/atmospherics/components/unary/tank/carbon_dioxide
gas_type = GAS_CO2
gas_type = "co2"
/obj/machinery/atmospherics/components/unary/tank/toxins
icon_state = "orange"
gas_type = GAS_PL
gas_type = "plasma"
/obj/machinery/atmospherics/components/unary/tank/oxygen_agent_b
icon_state = "orange_2"
gas_type = GAS_AGENT_B
gas_type = "agent_b"
/obj/machinery/atmospherics/components/unary/tank/oxygen
icon_state = "blue"
gas_type = GAS_O2
gas_type = "o2"
/obj/machinery/atmospherics/components/unary/tank/nitrogen
icon_state = "red"
gas_type = GAS_N2
gas_type = "n2"
/obj/machinery/atmospherics/components/unary/tank/air
icon_state = "grey"
@@ -43,5 +44,6 @@
/obj/machinery/atmospherics/components/unary/tank/air/New()
..()
var/datum/gas_mixture/air_contents = AIR1
air_contents.gases[GAS_O2][MOLES] = AIR_CONTENTS * 0.2
air_contents.gases[GAS_N2][MOLES] = AIR_CONTENTS * 0.8
air_contents.assert_gases("o2", "n2")
air_contents.gases["o2"][MOLES] = AIR_CONTENTS * 0.2
air_contents.gases["n2"][MOLES] = AIR_CONTENTS * 0.8
@@ -171,7 +171,7 @@
if(scrubbing & SCRUBBING)
var/should_we_scrub = FALSE
for(var/gas in environment.gases)
if(gas[GAS_INDEX] <= 2)
if(gas[GAS_ID] == "nitrogen" || gas[GAS_ID] == "oxygen")
continue
if(gas[MOLES])
should_we_scrub = TRUE
@@ -181,24 +181,36 @@
//Take a gas sample
var/datum/gas_mixture/removed = tile.remove_air(transfer_moles)
var/list/removed_gases = removed.gases
if (isnull(removed)) //in space
return
//Filter it
var/datum/gas_mixture/filtered_out = new
var/list/filtered_gases = filtered_out.gases
filtered_out.temperature = removed.temperature
if(scrub_Toxins)
filtered_out.gases[GAS_PL][MOLES] = removed.gases[GAS_PL][MOLES]
removed.gases[GAS_PL][MOLES] = 0
if(scrub_CO2)
filtered_out.gases[GAS_CO2][MOLES] = removed.gases[GAS_CO2][MOLES]
removed.gases[GAS_CO2][MOLES] = 0
if(TRUE) //no var for scrubbing agent b but I wanted the indentation to line up
filtered_out.gases[GAS_AGENT_B][MOLES] = removed.gases[GAS_AGENT_B][MOLES]
removed.gases[GAS_AGENT_B][MOLES] = 0
if(scrub_N2O)
filtered_out.gases[GAS_N2O][MOLES] = removed.gases[GAS_N2O][MOLES]
removed.gases[GAS_AGENT_B][MOLES] = 0
if(scrub_Toxins && removed_gases["plasma"])
filtered_out.assert_gas("plasma")
filtered_gases["plasma"][MOLES] = removed_gases["plasma"][MOLES]
removed.gases["plasma"][MOLES] = 0
if(scrub_CO2 && removed_gases["co2"])
filtered_out.assert_gas("co2")
filtered_out.gases["co2"][MOLES] = removed_gases["co2"][MOLES]
removed.gases["co2"][MOLES] = 0
if(removed_gases["agent_b"])
filtered_out.assert_gas("agent_b")
filtered_out.gases["agent_b"][MOLES] = removed_gases["agent_b"][MOLES]
removed.gases["agent_b"][MOLES] = 0
if(scrub_N2O && removed_gases["n2o"])
filtered_out.assert_gas("n2o")
filtered_out.gases["n2o"][MOLES] = removed_gases["n2o"][MOLES]
removed.gases["n2o"][MOLES] = 0
removed.garbage_collect()
//Remix the resulting gases
air_contents.merge(filtered_out)