Skip to content

Commit e6e95f4

Browse files
committed
Make gases use alist
1 parent 8266894 commit e6e95f4

File tree

41 files changed

+281
-335
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+281
-335
lines changed
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
#define REQUIRED_DM_VERSION 515
1+
#define REQUIRED_DM_VERSION 516
22

33
#if DM_VERSION < REQUIRED_DM_VERSION
4-
#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.
4+
#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.
55
#endif

code/__defines/math_physics.dm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
#define ATM *ONE_ATMOSPHERE
2828

2929
#define ATMOS_PRECISION 0.0001
30-
#define QUANTIZE(variable) (round(variable, ATMOS_PRECISION))
30+
#define QUANTIZE(variable) (NONUNIT_FLOOR(variable, ATMOS_PRECISION))
3131

3232
#define INFINITY 1.#INF
3333

code/_helpers/lists.dm

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,13 @@ Checks if a list has the same entries and values as an element of big.
272272
else
273273
.[key] = call(merge_method)(.[key], b_value)
274274

275+
// Picks a key in an alist. This is awful but hey, what can you do?
276+
/proc/apick(alist/target_alist)
277+
var/index = rand(1, length(target_alist))
278+
for(var/key in target_alist)
279+
if(--index == 0)
280+
return key
281+
275282
//Pretends to pick an element based on its weight but really just seems to pick a random element.
276283
/proc/pickweight(list/target_list)
277284
var/total = 0

code/game/machinery/air_sensor.dm

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,9 @@
4646
if(total_moles <= 0)
4747
return
4848
. = list()
49-
for(var/gas in air_sample.gas)
50-
var/decl/material/mat = GET_DECL(gas)
51-
var/gaspercent = round(air_sample.gas[gas]*100/total_moles,0.01)
49+
for(var/gas_type, gas_amount in air_sample.gas)
50+
var/decl/material/mat = GET_DECL(gas_type)
51+
var/gaspercent = round(gas_amount*100/total_moles,0.01)
5252
var/gas_list = list("symbol" = mat.gas_symbol_html, "percent" = gaspercent)
5353
. += list(gas_list)
5454

code/game/machinery/atmoalter/portable_atmospherics.dm

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@
1212

1313
/obj/machinery/portable_atmospherics/get_single_monetary_worth()
1414
. = ..()
15-
for(var/gas in air_contents?.gas)
16-
var/decl/material/gas_data = GET_DECL(gas)
17-
. += gas_data.get_value() * air_contents.gas[gas] * GAS_WORTH_MULTIPLIER
15+
for(var/gas_type, gas_amount in air_contents?.gas)
16+
var/decl/material/gas_data = GET_DECL(gas_type)
17+
. += gas_data.get_value() * gas_amount * GAS_WORTH_MULTIPLIER
1818
. = max(1, round(.))
1919

2020
/obj/machinery/portable_atmospherics/Initialize()

code/game/objects/effects/spawners/bombspawner.dm

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,15 +75,15 @@
7575
OT.master = V
7676

7777
PT.valve_welded = TRUE
78-
PT.air_contents.gas = list()
78+
PT.air_contents.gas = alist()
7979
PT.air_contents.gas[accelerant_type] = accelerant_amount
8080
PT.air_contents.gas[filler_type] = filler_amount
8181
PT.air_contents.total_moles = accelerant_amount + filler_amount
8282
PT.air_contents.temperature = FLAMMABLE_GAS_MINIMUM_BURN_TEMPERATURE+1
8383
PT.air_contents.update_values()
8484

8585
OT.valve_welded = TRUE
86-
OT.air_contents.gas = list()
86+
OT.air_contents.gas = alist()
8787
OT.air_contents.gas[oxidizer_type] = oxidizer_amount
8888
OT.air_contents.total_moles = oxidizer_amount
8989
OT.air_contents.temperature = FLAMMABLE_GAS_MINIMUM_BURN_TEMPERATURE+1

code/game/objects/items/weapons/tanks/tanks.dm

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,9 @@ var/global/list/global/tank_gauge_cache = list()
8080

8181
/obj/item/tank/get_single_monetary_worth()
8282
. = ..()
83-
for(var/gas in air_contents?.gas)
84-
var/decl/material/gas_data = GET_DECL(gas)
85-
. += gas_data.get_value() * air_contents.gas[gas] * GAS_WORTH_MULTIPLIER
83+
for(var/gas_type, gas_amount in air_contents?.gas)
84+
var/decl/material/gas_data = GET_DECL(gas_type)
85+
. += gas_data.get_value() * gas_amount * GAS_WORTH_MULTIPLIER
8686
. = max(1, round(.))
8787

8888
/obj/item/tank/get_examine_strings(mob/user, distance, infix, suffix)

code/game/objects/structures/fires.dm

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,8 +151,8 @@
151151

152152
/obj/structure/fire_source/proc/check_atmos()
153153
var/datum/gas_mixture/GM = loc?.return_air()
154-
for(var/g in GM?.gas)
155-
var/decl/material/oxidizer = GET_DECL(g)
154+
for(var/gas_type in GM?.gas)
155+
var/decl/material/oxidizer = GET_DECL(gas_type)
156156
if(oxidizer.gas_flags & XGM_GAS_OXIDIZER)
157157
return TRUE
158158

code/game/turfs/floors/subtypes/floor_circuit.dm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
temperature = TCMB
2626

2727
/turf/floor/greengrid/nitrogen
28-
initial_gas = list(/decl/material/gas/nitrogen = MOLES_N2STANDARD)
28+
initial_gas = alist(/decl/material/gas/nitrogen = MOLES_N2STANDARD)
2929

3030
/turf/floor/blackgrid
3131
name = "mainframe floor"

code/game/turfs/floors/subtypes/floor_reinforced.dm

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,32 +8,32 @@
88
initial_gas = null
99

1010
/turf/floor/reinforced/airmix
11-
initial_gas = list(
11+
initial_gas = alist(
1212
/decl/material/gas/oxygen = MOLES_O2ATMOS,
1313
/decl/material/gas/nitrogen = MOLES_N2ATMOS
1414
)
1515

1616
/turf/floor/reinforced/nitrogen
17-
initial_gas = list(/decl/material/gas/nitrogen = ATMOSTANK_NITROGEN)
17+
initial_gas = alist(/decl/material/gas/nitrogen = ATMOSTANK_NITROGEN)
1818

1919
/turf/floor/reinforced/hydrogen
20-
initial_gas = list(/decl/material/gas/hydrogen = ATMOSTANK_HYDROGEN)
20+
initial_gas = alist(/decl/material/gas/hydrogen = ATMOSTANK_HYDROGEN)
2121

2222
/turf/floor/reinforced/oxygen
23-
initial_gas = list(/decl/material/gas/oxygen = ATMOSTANK_OXYGEN)
23+
initial_gas = alist(/decl/material/gas/oxygen = ATMOSTANK_OXYGEN)
2424

2525
/turf/floor/reinforced/nitrogen/engine
2626
name = "engine floor"
27-
initial_gas = list(/decl/material/gas/nitrogen = MOLES_N2STANDARD)
27+
initial_gas = alist(/decl/material/gas/nitrogen = MOLES_N2STANDARD)
2828

2929
/turf/floor/reinforced/hydrogen/fuel
30-
initial_gas = list(/decl/material/gas/hydrogen = ATMOSTANK_HYDROGEN_FUEL)
30+
initial_gas = alist(/decl/material/gas/hydrogen = ATMOSTANK_HYDROGEN_FUEL)
3131

3232
/turf/floor/reinforced/carbon_dioxide
33-
initial_gas = list(/decl/material/gas/carbon_dioxide = ATMOSTANK_CO2)
33+
initial_gas = alist(/decl/material/gas/carbon_dioxide = ATMOSTANK_CO2)
3434

3535
/turf/floor/reinforced/n20
36-
initial_gas = list(/decl/material/gas/nitrous_oxide = ATMOSTANK_NITROUSOXIDE)
36+
initial_gas = alist(/decl/material/gas/nitrous_oxide = ATMOSTANK_NITROUSOXIDE)
3737

3838
/turf/floor/reinforced/airless
3939
name = "vacuum floor"

0 commit comments

Comments
 (0)