Skip to content
This repository was archived by the owner on May 22, 2025. It is now read-only.

Commit a9b511d

Browse files
committed
AGH
1 parent bd9f5d0 commit a9b511d

10 files changed

Lines changed: 71 additions & 50 deletions

File tree

code/__DEFINES/atmospherics.dm

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -497,3 +497,8 @@ GLOBAL_LIST_INIT(pipe_paint_colors, list(
497497

498498
#define MIASMA_CORPSE_MOLES 0.02
499499
#define MIASMA_GIBS_MOLES 0.005
500+
501+
//PIPENET UPDATE STATUS
502+
#define PIPENET_UPDATE_STATUS_DORMANT 0
503+
#define PIPENET_UPDATE_STATUS_REACT_NEEDED 1
504+
#define PIPENET_UPDATE_STATUS_RECONCILE_NEEDED 2

code/modules/atmospherics/gasmixtures/reactions.dm

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,20 @@ nobliumformation = 1001
157157
if(istype(location) && prob(10))
158158
radiation_pulse(location, energy_released/TRITIUM_BURN_RADIOACTIVITY_FACTOR)
159159

160+
/proc/fusion_ball(datum/holder, reaction_energy, instability)
161+
var/turf/open/location
162+
if (istype(holder,/datum/pipeline)) //Find the tile the reaction is occuring on, or a random part of the network if it's a pipenet.
163+
var/datum/pipeline/fusion_pipenet = holder
164+
location = get_turf(pick(fusion_pipenet.members))
165+
else
166+
location = get_turf(holder)
167+
if(location)
168+
var/particle_chance = ((PARTICLE_CHANCE_CONSTANT)/(reaction_energy-PARTICLE_CHANCE_CONSTANT)) + 1//Asymptopically approaches 100% as the energy of the reaction goes up.
169+
if(prob(PERCENT(particle_chance)))
170+
location.fire_nuclear_particle()
171+
var/rad_power = max((FUSION_RAD_COEFFICIENT/instability) + FUSION_RAD_MAX,0)
172+
radiation_pulse(location,rad_power)
173+
160174
/datum/gas_reaction/tritfire/react(datum/gas_mixture/air, datum/holder)
161175
var/energy_released = 0
162176
var/old_heat_capacity = air.heat_capacity()

code/modules/atmospherics/machinery/components/binary_devices/dp_vent_pump.dm

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,8 @@
5353

5454
/obj/machinery/atmospherics/components/binary/dp_vent_pump/process_atmos()
5555
..()
56-
56+
if(welded || !is_operational() || !isopenturf(loc))
57+
return FALSE
5758
if(!on)
5859
return
5960
var/datum/gas_mixture/air1 = airs[1]
@@ -75,30 +76,29 @@
7576
var/transfer_moles = pressure_delta*environment.return_volume()/(air1.return_temperature() * R_IDEAL_GAS_EQUATION)
7677

7778
loc.assume_air_moles(air1, transfer_moles)
79+
7880
air_update_turf()
7981

8082
var/datum/pipeline/parent1 = parents[1]
81-
parent1.update = 1
83+
parent1.update = PIPENET_UPDATE_STATUS_RECONCILE_NEEDED
8284

8385
else //external -> output
84-
8586
if(environment.return_pressure() > 0)
8687
var/our_multiplier = air2.return_volume() / (environment.return_temperature() * R_IDEAL_GAS_EQUATION)
8788
var/moles_delta = 10000 * our_multiplier
8889
if(pressure_checks&EXT_BOUND)
8990
moles_delta = min(moles_delta, (environment_pressure - output_pressure_max) * environment.return_volume() / (environment.return_temperature() * R_IDEAL_GAS_EQUATION))
9091
if(pressure_checks&INPUT_MIN)
9192
moles_delta = min(moles_delta, (input_pressure_min - air2.return_pressure()) * our_multiplier)
92-
93+
9394
if(moles_delta > 0)
9495
loc.transfer_air(air2, moles_delta)
9596
air_update_turf()
9697

9798
var/datum/pipeline/parent2 = parents[2]
98-
parent2.update = 1
99-
100-
//Radio remote control
99+
parent2.update = PIPENET_UPDATE_STATUS_RECONCILE_NEEDED
101100

101+
//Radio remote control
102102
/obj/machinery/atmospherics/components/binary/dp_vent_pump/proc/set_frequency(new_frequency)
103103
SSradio.remove_object(src, frequency)
104104
frequency = new_frequency

code/modules/atmospherics/machinery/components/binary_devices/passive_gate.dm

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -57,26 +57,7 @@ Passive gate is similar to the regular pump except:
5757

5858
var/datum/gas_mixture/air1 = airs[1]
5959
var/datum/gas_mixture/air2 = airs[2]
60-
61-
var/output_starting_pressure = air2.return_pressure()
62-
var/input_starting_pressure = air1.return_pressure()
63-
64-
if(output_starting_pressure >= min(target_pressure,input_starting_pressure-10))
65-
//No need to pump gas if target is already reached or input pressure is too low
66-
//Need at least 10 KPa difference to overcome friction in the mechanism
67-
return
68-
69-
//Calculate necessary moles to transfer using PV = nRT
70-
if((air1.total_moles() > 0) && (air1.return_temperature()>0))
71-
var/pressure_delta = min(target_pressure - output_starting_pressure, (input_starting_pressure - output_starting_pressure)/2)
72-
//Can not have a pressure delta that would cause output_pressure > input_pressure
73-
74-
var/transfer_moles = pressure_delta*air2.return_volume()/(air1.return_temperature() * R_IDEAL_GAS_EQUATION)
75-
76-
//Actually transfer the gas
77-
var/datum/gas_mixture/removed = air1.remove(transfer_moles)
78-
air2.merge(removed)
79-
60+
if(air1.release_gas_to(air2, target_pressure))
8061
update_parents()
8162

8263

code/modules/atmospherics/machinery/components/binary_devices/temperature_pump.dm

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,18 +32,31 @@
3232
icon_state = "tpump_[on && is_operational() ? "on" : "off"]-[set_overlay_offset(piping_layer)]"
3333

3434
/obj/machinery/atmospherics/components/binary/temperature_pump/process_atmos()
35-
..()
35+
3636
if(!on || !is_operational())
3737
return
3838

3939
var/datum/gas_mixture/air_input = airs[1]
4040
var/datum/gas_mixture/air_output = airs[2]
4141

42-
if((air_output.return_temperature() + heat_transfer_rate) >= air_input.return_temperature() || (air_input.return_temperature() - heat_transfer_rate) <= TCRYO)
42+
if(!QUANTIZE(air_input.total_moles()) || !QUANTIZE(air_output.total_moles())) //Don't transfer if there's no gas
4343
return
44+
var/datum/gas_mixture/remove_input = air_input.remove_ratio(0.9)
45+
var/datum/gas_mixture/remove_output = air_output.remove_ratio(0.9)
46+
47+
var/coolant_temperature_delta = remove_input.return_temperature() - remove_output.return_temperature()
48+
49+
if(coolant_temperature_delta > 0)
50+
var/input_capacity = remove_input.heat_capacity()
51+
var/output_capacity = air_output.heat_capacity()
52+
53+
var/cooling_heat_amount = (heat_transfer_rate * 0.01) * coolant_temperature_delta * (input_capacity * output_capacity / (input_capacity + output_capacity))
54+
remove_input.set_temperature(max(remove_input.return_temperature() - (cooling_heat_amount / input_capacity), TCMB))
55+
remove_output.set_temperature(max(remove_output.return_temperature() + (cooling_heat_amount / output_capacity), TCMB))
56+
57+
air_input.merge(remove_input)
58+
air_output.merge(remove_output)
4459

45-
air_input.set_temperature(air_input.return_temperature() - heat_transfer_rate)
46-
air_output.set_temperature(air_output.return_temperature() + heat_transfer_rate)
4760
update_parents()
4861

4962
/obj/machinery/atmospherics/components/binary/temperature_pump/ui_interact(mob/user, datum/tgui/ui)

code/modules/atmospherics/machinery/components/binary_devices/valve.dm

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,17 @@ It's like a regular ol' straight pipe, but you can turn it on and off.
2424

2525
var/switching = FALSE
2626

27+
28+
/obj/machinery/atmospherics/components/binary/valve/Destroy()
29+
//Should only happen on extreme circumstances
30+
if(on)
31+
//Let's give presumably now-severed pipenets a chance to scramble for what's happening at next SSair fire()
32+
if(parents[1])
33+
parents[1].update = PIPENET_UPDATE_STATUS_RECONCILE_NEEDED
34+
if(parents[2])
35+
parents[2].update = PIPENET_UPDATE_STATUS_RECONCILE_NEEDED
36+
. = ..()
37+
2738
/obj/machinery/atmospherics/components/binary/valve/update_icon_nopipes(animation = FALSE)
2839
normalize_cardinal_directions()
2940
if(animation)

code/modules/atmospherics/machinery/components/components_base.dm

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -133,10 +133,11 @@
133133
for(var/i in 1 to device_type)
134134
var/datum/pipeline/parent = parents[i]
135135
if(!parent)
136-
WARNING("Component is missing a pipenet! Rebuilding...")
136+
//WARNING("Component is missing a pipenet! Rebuilding...")
137+
//At pre-SSair_rebuild_pipenets times, not having a parent wasn't supposed to happen
137138
SSair.add_to_rebuild_queue(src)
138-
else
139-
parent.update = 1
139+
continue
140+
parent.update = PIPENET_UPDATE_STATUS_RECONCILE_NEEDED
140141

141142
/obj/machinery/atmospherics/components/returnPipenets()
142143
. = list()

code/modules/atmospherics/machinery/components/trinary_devices/mixer.dm

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,15 +110,15 @@
110110
if(transfer_moles1)
111111
air1.transfer_to(air3, transfer_moles1)
112112
var/datum/pipeline/parent1 = parents[1]
113-
parent1.update = TRUE
113+
parent1.update = PIPENET_UPDATE_STATUS_RECONCILE_NEEDED
114114

115115
if(transfer_moles2)
116116
air2.transfer_to(air3, transfer_moles2)
117117
var/datum/pipeline/parent2 = parents[2]
118-
parent2.update = TRUE
118+
parent2.update = PIPENET_UPDATE_STATUS_RECONCILE_NEEDED
119119

120120
var/datum/pipeline/parent3 = parents[3]
121-
parent3.update = TRUE
121+
parent3.update = PIPENET_UPDATE_STATUS_RECONCILE_NEEDED
122122

123123
/obj/machinery/atmospherics/components/trinary/mixer/ui_interact(mob/user, datum/tgui/ui)
124124
ui = SStgui.try_update_ui(user, src, ui)

code/modules/atmospherics/machinery/portable/canister.dm

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -466,21 +466,17 @@
466466
if(timing && valve_timer < world.time)
467467
valve_open = !valve_open
468468
timing = FALSE
469+
470+
// Handle gas transfer.
469471
if(valve_open)
470472
var/turf/T = get_turf(src)
471-
pump.airs[1] = air_contents
472-
pump.airs[2] = holding ? holding.air_contents : T.return_air()
473-
pump.target_pressure = release_pressure
474-
475-
pump.process_atmos() // Pump gas.
476-
if(!holding)
477-
air_update_turf() // Update the environment if needed.
478-
else
479-
pump.airs[1] = null
480-
pump.airs[2] = null
473+
var/datum/gas_mixture/target_air = holding ? holding.air_contents : T.return_air()
481474

475+
if(air_contents.release_gas_to(target_air, release_pressure) && !holding)
476+
air_update_turf()
482477
update_icon()
483478

479+
484480
/obj/machinery/portable_atmospherics/canister/ui_state(mob/user)
485481
return GLOB.physical_state
486482

code/modules/atmospherics/machinery/portable/portable_atmospherics.dm

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
return ..()
4646

4747
/obj/machinery/portable_atmospherics/process_atmos()
48-
if(!connected_port) // Pipe network handles reactions if connected.
48+
if(!connected_port && air_contents != null && src != null) // Pipe network handles reactions if connected.
4949
air_contents.react(src)
5050

5151
/obj/machinery/portable_atmospherics/return_air()
@@ -63,15 +63,15 @@
6363
//Perform the connection
6464
connected_port = new_port
6565
connected_port.connected_device = src
66-
var/datum/pipeline/connected_port_parent = connected_port.parents[1]
67-
connected_port_parent.reconcile_air()
66+
connected_port.parents[1].update = PIPENET_UPDATE_STATUS_RECONCILE_NEEDED
6867

6968
anchored = TRUE //Prevent movement
7069
pixel_x = new_port.pixel_x
7170
pixel_y = new_port.pixel_y
7271
update_icon()
7372
return TRUE
7473

74+
7575
/obj/machinery/portable_atmospherics/Move()
7676
. = ..()
7777
if(.)

0 commit comments

Comments
 (0)