Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions code/__defines/_byond_version_compat.dm
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#define REQUIRED_DM_VERSION 515
#define REQUIRED_DM_VERSION 516

#if DM_VERSION < REQUIRED_DM_VERSION
#warn Nebula is not tested on BYOND versions older than 515. The code may not compile, and if it does compile it may have severe problems.
#warn Nebula is not tested on BYOND versions older than 516. The code may not compile, and if it does compile it may have severe problems.
#endif
2 changes: 1 addition & 1 deletion code/__defines/math_physics.dm
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
#define ATM *ONE_ATMOSPHERE

#define ATMOS_PRECISION 0.0001
#define QUANTIZE(variable) (round(variable, ATMOS_PRECISION))
#define QUANTIZE(variable) (NONUNIT_FLOOR(variable, ATMOS_PRECISION))

#define INFINITY 1.#INF

Expand Down
7 changes: 7 additions & 0 deletions code/_helpers/lists.dm
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,13 @@ Checks if a list has the same entries and values as an element of big.
else
.[key] = call(merge_method)(.[key], b_value)

// Picks a key in an alist. This is awful but hey, what can you do?
/proc/apick(alist/target_alist)
var/index = rand(1, length(target_alist))
for(var/key in target_alist)
if(--index == 0)
return key

//Pretends to pick an element based on its weight but really just seems to pick a random element.
/proc/pickweight(list/target_list)
var/total = 0
Expand Down
6 changes: 3 additions & 3 deletions code/game/machinery/air_sensor.dm
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@
if(total_moles <= 0)
return
. = list()
for(var/gas in air_sample.gas)
var/decl/material/mat = GET_DECL(gas)
var/gaspercent = round(air_sample.gas[gas]*100/total_moles,0.01)
for(var/gas_type, gas_amount in air_sample.gas)
var/decl/material/mat = GET_DECL(gas_type)
var/gaspercent = round(gas_amount*100/total_moles,0.01)
var/gas_list = list("symbol" = mat.gas_symbol_html, "percent" = gaspercent)
. += list(gas_list)

Expand Down
6 changes: 3 additions & 3 deletions code/game/machinery/atmoalter/portable_atmospherics.dm
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@

/obj/machinery/portable_atmospherics/get_single_monetary_worth()
. = ..()
for(var/gas in air_contents?.gas)
var/decl/material/gas_data = GET_DECL(gas)
. += gas_data.get_value() * air_contents.gas[gas] * GAS_WORTH_MULTIPLIER
for(var/gas_type, gas_amount in air_contents?.gas)
var/decl/material/gas_data = GET_DECL(gas_type)
. += gas_data.get_value() * gas_amount * GAS_WORTH_MULTIPLIER
. = max(1, round(.))

/obj/machinery/portable_atmospherics/Initialize()
Expand Down
4 changes: 2 additions & 2 deletions code/game/objects/effects/spawners/bombspawner.dm
Original file line number Diff line number Diff line change
Expand Up @@ -75,15 +75,15 @@
OT.master = V

PT.valve_welded = TRUE
PT.air_contents.gas = list()
PT.air_contents.gas = alist()
PT.air_contents.gas[accelerant_type] = accelerant_amount
PT.air_contents.gas[filler_type] = filler_amount
PT.air_contents.total_moles = accelerant_amount + filler_amount
PT.air_contents.temperature = FLAMMABLE_GAS_MINIMUM_BURN_TEMPERATURE+1
PT.air_contents.update_values()

OT.valve_welded = TRUE
OT.air_contents.gas = list()
OT.air_contents.gas = alist()
OT.air_contents.gas[oxidizer_type] = oxidizer_amount
OT.air_contents.total_moles = oxidizer_amount
OT.air_contents.temperature = FLAMMABLE_GAS_MINIMUM_BURN_TEMPERATURE+1
Expand Down
6 changes: 3 additions & 3 deletions code/game/objects/items/weapons/tanks/tanks.dm
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,9 @@ var/global/list/global/tank_gauge_cache = list()

/obj/item/tank/get_single_monetary_worth()
. = ..()
for(var/gas in air_contents?.gas)
var/decl/material/gas_data = GET_DECL(gas)
. += gas_data.get_value() * air_contents.gas[gas] * GAS_WORTH_MULTIPLIER
for(var/gas_type, gas_amount in air_contents?.gas)
var/decl/material/gas_data = GET_DECL(gas_type)
. += gas_data.get_value() * gas_amount * GAS_WORTH_MULTIPLIER
. = max(1, round(.))

/obj/item/tank/get_examine_strings(mob/user, distance, infix, suffix)
Expand Down
4 changes: 2 additions & 2 deletions code/game/objects/structures/fires.dm
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,8 @@

/obj/structure/fire_source/proc/check_atmos()
var/datum/gas_mixture/GM = loc?.return_air()
for(var/g in GM?.gas)
var/decl/material/oxidizer = GET_DECL(g)
for(var/gas_type in GM?.gas)
var/decl/material/oxidizer = GET_DECL(gas_type)
if(oxidizer.gas_flags & XGM_GAS_OXIDIZER)
return TRUE

Expand Down
2 changes: 1 addition & 1 deletion code/game/turfs/floors/subtypes/floor_circuit.dm
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
temperature = TCMB

/turf/floor/greengrid/nitrogen
initial_gas = list(/decl/material/gas/nitrogen = MOLES_N2STANDARD)
initial_gas = alist(/decl/material/gas/nitrogen = MOLES_N2STANDARD)

/turf/floor/blackgrid
name = "mainframe floor"
Expand Down
16 changes: 8 additions & 8 deletions code/game/turfs/floors/subtypes/floor_reinforced.dm
Original file line number Diff line number Diff line change
Expand Up @@ -8,32 +8,32 @@
initial_gas = null

/turf/floor/reinforced/airmix
initial_gas = list(
initial_gas = alist(
/decl/material/gas/oxygen = MOLES_O2ATMOS,
/decl/material/gas/nitrogen = MOLES_N2ATMOS
)

/turf/floor/reinforced/nitrogen
initial_gas = list(/decl/material/gas/nitrogen = ATMOSTANK_NITROGEN)
initial_gas = alist(/decl/material/gas/nitrogen = ATMOSTANK_NITROGEN)

/turf/floor/reinforced/hydrogen
initial_gas = list(/decl/material/gas/hydrogen = ATMOSTANK_HYDROGEN)
initial_gas = alist(/decl/material/gas/hydrogen = ATMOSTANK_HYDROGEN)

/turf/floor/reinforced/oxygen
initial_gas = list(/decl/material/gas/oxygen = ATMOSTANK_OXYGEN)
initial_gas = alist(/decl/material/gas/oxygen = ATMOSTANK_OXYGEN)

/turf/floor/reinforced/nitrogen/engine
name = "engine floor"
initial_gas = list(/decl/material/gas/nitrogen = MOLES_N2STANDARD)
initial_gas = alist(/decl/material/gas/nitrogen = MOLES_N2STANDARD)

/turf/floor/reinforced/hydrogen/fuel
initial_gas = list(/decl/material/gas/hydrogen = ATMOSTANK_HYDROGEN_FUEL)
initial_gas = alist(/decl/material/gas/hydrogen = ATMOSTANK_HYDROGEN_FUEL)

/turf/floor/reinforced/carbon_dioxide
initial_gas = list(/decl/material/gas/carbon_dioxide = ATMOSTANK_CO2)
initial_gas = alist(/decl/material/gas/carbon_dioxide = ATMOSTANK_CO2)

/turf/floor/reinforced/n20
initial_gas = list(/decl/material/gas/nitrous_oxide = ATMOSTANK_NITROUSOXIDE)
initial_gas = alist(/decl/material/gas/nitrous_oxide = ATMOSTANK_NITROUSOXIDE)

/turf/floor/reinforced/airless
name = "vacuum floor"
Expand Down
2 changes: 1 addition & 1 deletion code/game/turfs/turf.dm
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
var/turf_flags

/// Either a mapping of material decls to mol amounts, or a reserved initial gas define like GAS_STANDARD_AIRMIX.
var/list/initial_gas
var/alist/initial_gas

//Properties for airtight tiles (/wall)
var/thermal_conductivity = 0.05
Expand Down
6 changes: 3 additions & 3 deletions code/game/turfs/turf_enter.dm
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,9 @@
var/datum/gas_mixture/env = return_air(1)
if(!env)
return
for(var/g in env.gas)
var/decl/material/mat = GET_DECL(g)
if((mat.gas_flags & XGM_GAS_CONTAMINANT) && env.gas[g] > mat.gas_overlay_limit + 1)
for(var/gas_type, gas_amount in env.gas)
var/decl/material/mat = GET_DECL(gas_type)
if((mat.gas_flags & XGM_GAS_CONTAMINANT) && gas_amount > mat.gas_overlay_limit + 1)
I.contaminate()
break

Expand Down
4 changes: 2 additions & 2 deletions code/modules/ZAS/Diagnostic.dm
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
to_chat(mob, "ZONE: No zone here.")
var/datum/gas_mixture/mix = T.return_air()
to_chat(mob, "ZONE: [mix.return_pressure()] kPa [mix.temperature] k")
for(var/g in mix.gas)
to_chat(mob, "ZONE GASES: [g]: [mix.gas[g]]\n")
for(var/gas_type, gas_amount in mix.gas)
to_chat(mob, "ZONE GASES: [gas_type]: [gas_amount]\n")

/client/proc/Test_ZAS_Connection(var/turf/T)
set category = "Debug"
Expand Down
64 changes: 26 additions & 38 deletions code/modules/ZAS/Fire.dm
Original file line number Diff line number Diff line change
Expand Up @@ -187,12 +187,12 @@ If it gains pressure too slowly, it may leak or just rupture instead of explodin
var/total_oxidizers = 0

//*** Get the fuel and oxidizer amounts
for(var/g in gas)
var/decl/material/mat = GET_DECL(g)
for(var/gas_type, gas_amount in gas)
var/decl/material/mat = GET_DECL(gas_type)
if(mat.gas_flags & XGM_GAS_FUEL)
total_fuel += gas[g]
total_fuel += gas_amount
if(mat.gas_flags & XGM_GAS_OXIDIZER)
total_oxidizers += gas[g]
total_oxidizers += gas_amount
total_fuel *= group_multiplier
total_oxidizers *= group_multiplier

Expand Down Expand Up @@ -233,9 +233,9 @@ If it gains pressure too slowly, it may leak or just rupture instead of explodin
//remove_by_flag() and adjust_gas() handle the group_multiplier for us.
remove_by_flag(XGM_GAS_OXIDIZER, used_oxidizers)
var/datum/gas_mixture/burned_fuel = remove_by_flag(XGM_GAS_FUEL, used_fuel)
for(var/g in burned_fuel.gas)
var/decl/material/mat = GET_DECL(g)
mat.add_burn_product(src, burned_fuel.gas[g])
for(var/gas_type, gas_amount in burned_fuel.gas)
var/decl/material/mat = GET_DECL(gas_type)
mat.add_burn_product(src, gas_amount)

//calculate the energy produced by the reaction and then set the new temperature of the mix
temperature = (starting_energy + vsc.fire_fuel_energy_release * used_fuel) / heat_capacity()
Expand All @@ -249,44 +249,32 @@ If it gains pressure too slowly, it may leak or just rupture instead of explodin
return firelevel

/datum/gas_mixture/proc/check_recombustibility()
var/const/HAS_OXIDIZER = BITFLAG(0)
var/const/HAS_FUEL = BITFLAG(1)
. = 0
for(var/g in gas)
if(gas[g] >= 0.1)
var/decl/material/gas = GET_DECL(g)
for(var/gas_type, gas_amount in gas)
if(gas_amount >= 0.1)
var/decl/material/gas = GET_DECL(gas_type)
if(gas.gas_flags & XGM_GAS_OXIDIZER)
. = 1
break

if(!.)
return 0

. = 0
for(var/g in gas)
if(gas[g] >= 0.1)
var/decl/material/gas = GET_DECL(g)
if(gas.gas_flags & XGM_GAS_OXIDIZER)
. = 1
break
. |= HAS_OXIDIZER
if(gas.gas_flags & XGM_GAS_FUEL)
. |= HAS_FUEL
if(. == (HAS_OXIDIZER|HAS_FUEL))
return TRUE

/datum/gas_mixture/proc/check_combustibility()
var/const/HAS_OXIDIZER = BITFLAG(0)
var/const/HAS_FUEL = BITFLAG(1)
. = 0
for(var/g in gas)
if(QUANTIZE(gas[g] * vsc.fire_consuption_rate) >= 0.1)
var/decl/material/gas = GET_DECL(g)
for(var/gas_type, gas_amount in gas)
if(QUANTIZE(gas_amount * vsc.fire_consuption_rate) >= 0.1)
var/decl/material/gas = GET_DECL(gas_type)
if(gas.gas_flags & XGM_GAS_OXIDIZER)
. = 1
break

if(!.)
return 0

. = 0
for(var/g in gas)
if(QUANTIZE(gas[g] * vsc.fire_consuption_rate) >= 0.1)
var/decl/material/gas = GET_DECL(g)
. |= HAS_OXIDIZER
if(gas.gas_flags & XGM_GAS_FUEL)
. = 1
break
. |= HAS_FUEL
if(. == (HAS_OXIDIZER|HAS_FUEL))
return TRUE

//returns a value between 0 and vsc.fire_firelevel_multiplier
/datum/gas_mixture/proc/calculate_firelevel(total_fuel, total_oxidizers, reaction_limit, gas_volume)
Expand Down
2 changes: 1 addition & 1 deletion code/modules/ZAS/Turf.dm
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@
return TRUE
return FALSE

var/global/list/STANDARD_AIRMIX = list(
var/global/alist/STANDARD_AIRMIX = alist(
/decl/material/gas/oxygen = MOLES_O2STANDARD,
/decl/material/gas/nitrogen = MOLES_N2STANDARD
)
Expand Down
16 changes: 8 additions & 8 deletions code/modules/ZAS/Zone.dm
Original file line number Diff line number Diff line change
Expand Up @@ -180,26 +180,26 @@ Class Procs:
/zone/proc/handle_condensation()
set waitfor = FALSE
condensing = TRUE
for(var/g in air.gas)
var/decl/material/mat = GET_DECL(g)
for(var/gas_type, gas_amount in air.gas)
var/decl/material/mat = GET_DECL(gas_type)
if(!isnull(mat.gas_condensation_point) && (air.temperature <= mat.gas_condensation_point))
var/condensation_area = air.group_multiplier / length(air.gas)
while(condensation_area > 0 && length(contents))
condensation_area--
var/turf/flooding = pick(contents)
var/condense_amt = min(air.gas[g], rand(1,3))
var/condense_amt = min(gas_amount, rand(1,3))
if(condense_amt < 1)
break
air.adjust_gas(g, -condense_amt)
flooding.add_to_reagents(g, condense_amt * REAGENT_UNITS_PER_GAS_MOLE)
air.adjust_gas(gas_type, -condense_amt)
flooding.add_to_reagents(gas_type, condense_amt * REAGENT_UNITS_PER_GAS_MOLE)
CHECK_TICK
condensing = FALSE

/zone/proc/dbg_data(mob/M)
to_chat(M, name)
for(var/g in air.gas)
var/decl/material/mat = GET_DECL(g)
to_chat(M, "[capitalize(mat.gas_name)]: [air.gas[g]]")
for(var/gas_type, gas_amount in air.gas)
var/decl/material/mat = GET_DECL(gas_type)
to_chat(M, "[capitalize(mat.gas_name)]: [gas_amount]")
to_chat(M, "P: [air.return_pressure()] kPa V: [air.total_volume]L T: [air.temperature]°K ([air.temperature - T0C]°C)")
to_chat(M, "O2 per N2: [(air.gas[/decl/material/gas/nitrogen] ? air.gas[/decl/material/gas/oxygen]/air.gas[/decl/material/gas/nitrogen] : "N/A")] Moles: [air.total_moles]")
to_chat(M, "Simulated: [contents.len] ([air.group_multiplier])")
Expand Down
4 changes: 2 additions & 2 deletions code/modules/admin/verbs/debug.dm
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
var/t = "<span class='notice'>Coordinates: [T.x],[T.y],[T.z]</span>\n"
t += "<span class='warning'>Temperature: [env.temperature]</span>\n"
t += "<span class='warning'>Pressure: [env.return_pressure()]kPa</span>\n"
for(var/g in env.gas)
t += "<span class='notice'>[g]: [env.gas[g]] / [env.gas[g] * R_IDEAL_GAS_EQUATION * env.temperature / env.total_volume]kPa</span>\n"
for(var/gas_type, gas_amount in env.gas)
t += "<span class='notice'>[gas_type]: [gas_amount] / [gas_amount * R_IDEAL_GAS_EQUATION * env.temperature / env.total_volume]kPa</span>\n"

usr.show_message(t, 1)
SSstatistics.add_field_details("admin_verb","ASL") //If you are copy-pasting this, ensure the 2nd parameter is unique to the new proc!
Expand Down
Loading
Loading