Defers pipenet and powernet rebuilds upon destruction of pipes and cables so explosions are faster

This commit is contained in:
Tastyfish
2016-04-29 23:42:47 -04:00
parent b8d9108c9c
commit 3b59d2cd15
35 changed files with 199 additions and 163 deletions
@@ -8,7 +8,7 @@
var/obj/machinery/atmospherics/node1
var/obj/machinery/atmospherics/node2
var/datum/pipeline/parent1
var/datum/pipeline/parent2
@@ -23,7 +23,7 @@
initialize_directions = EAST|WEST
if(WEST)
initialize_directions = EAST|WEST
air1 = new
air2 = new
@@ -89,6 +89,8 @@
/obj/machinery/atmospherics/binary/nullifyPipenet(datum/pipeline/P)
..()
if(!P)
return
if(P == parent1)
parent1.other_airs -= air1
parent1 = null
@@ -128,7 +130,7 @@
parent1 = New
else if(Old == parent2)
parent2 = New
/obj/machinery/atmospherics/binary/unsafe_pressure_release(var/mob/user,var/pressures)
..()
@@ -144,4 +146,7 @@
to_release.merge(air2.remove(shared_loss))
T.assume_air(to_release)
air_update_turf(1)
/obj/machinery/atmospherics/binary/process()
..()
return parent1 && parent2
@@ -48,7 +48,8 @@
return removed
/obj/machinery/atmospherics/binary/circulator/process()
..()
if(!..())
return 0
if(last_worldtime_transfer < world.time - 50)
recent_moles_transferred = 0
update_icon()
@@ -32,19 +32,19 @@
//1: Do not pass external_pressure_bound
//2: Do not pass input_pressure_min
//4: Do not pass output_pressure_max
/obj/machinery/atmospherics/binary/dp_vent_pump/New()
..()
if (!id_tag)
assign_uid()
id_tag = num2text(uid)
icon = null
/obj/machinery/atmospherics/binary/dp_vent_pump/initialize()
..()
if(frequency)
set_frequency(frequency)
/obj/machinery/atmospherics/binary/dp_vent_pump/high_volume
name = "large dual port air vent"
@@ -103,9 +103,7 @@
add_underlay(T, node2, dir)
/obj/machinery/atmospherics/binary/dp_vent_pump/process()
..()
if(!on)
if(!..() || !on)
return 0
var/datum/gas_mixture/environment = loc.return_air()
@@ -236,7 +234,7 @@
if(istype(W, /obj/item/device/multitool))
update_multitool_menu(user)
return 1
return ..()
/obj/machinery/atmospherics/binary/dp_vent_pump/multitool_menu(var/mob/user,var/obj/item/device/multitool/P)
@@ -254,5 +252,4 @@
return .
if("toggleadvcontrol" in href_list)
advcontrol = !advcontrol
return MT_UPDATE
return MT_UPDATE
@@ -6,7 +6,7 @@
name = "passive gate"
desc = "A one-way air valve that does not require power"
can_unwrench = 1
var/on = 0
@@ -15,7 +15,7 @@
var/frequency = 0
var/id = null
var/datum/radio_frequency/radio_connection
/obj/machinery/atmospherics/binary/passive_gate/initialize()
..()
if(frequency)
@@ -34,8 +34,7 @@
add_underlay(T, node2, dir)
/obj/machinery/atmospherics/binary/passive_gate/process()
..()
if(!on)
if(!..() || !on)
return 0
var/output_starting_pressure = air2.return_pressure()
@@ -60,6 +59,7 @@
parent1.update = 1
parent2.update = 1
return 1
//Radio remote control
/obj/machinery/atmospherics/binary/passive_gate/proc/set_frequency(new_frequency)
@@ -100,7 +100,7 @@
/obj/machinery/atmospherics/binary/passive_gate/receive_signal(datum/signal/signal)
if(!signal.data["tag"] || (signal.data["tag"] != id) || (signal.data["sigtype"]!="command"))
return 0
var/old_on = on //for logging
if("power" in signal.data)
@@ -115,7 +115,7 @@
text2num(signal.data["set_output_pressure"]),
ONE_ATMOSPHERE*50
)
if(on != old_on)
investigate_log("was turned [on ? "on" : "off"] by a remote signal", "atmos")
@@ -161,4 +161,3 @@
to_chat(user, "<span class='alert'>You cannot unwrench this [src], turn it off first.</span>")
return 1
return ..()
@@ -15,10 +15,10 @@ Thus, the two variables affect pump operation are set in New():
/obj/machinery/atmospherics/binary/pump
icon = 'icons/atmos/pump.dmi'
icon_state = "map_off"
name = "gas pump"
desc = "A pump"
can_unwrench = 1
var/on = 0
@@ -54,10 +54,7 @@ Thus, the two variables affect pump operation are set in New():
add_underlay(T, node2, dir)
/obj/machinery/atmospherics/binary/pump/process()
// ..()
if(stat & (NOPOWER|BROKEN))
return
if(!on)
if(!..() || (stat & (NOPOWER|BROKEN)) || !on)
return 0
var/output_starting_pressure = air2.return_pressure()
@@ -123,7 +120,7 @@ Thus, the two variables affect pump operation are set in New():
/obj/machinery/atmospherics/binary/pump/receive_signal(datum/signal/signal)
if(!signal.data["tag"] || (signal.data["tag"] != id) || (signal.data["sigtype"]!="command"))
return 0
var/old_on = on //for logging
if(signal.data["power"])
@@ -138,7 +135,7 @@ Thus, the two variables affect pump operation are set in New():
text2num(signal.data["set_output_pressure"]),
ONE_ATMOSPHERE*50
)
if(on != old_on)
investigate_log("was turned [on ? "on" : "off"] by a remote signal", "atmos")
@@ -164,7 +161,7 @@ Thus, the two variables affect pump operation are set in New():
return
/obj/machinery/atmospherics/binary/pump/Topic(href,href_list)
if(..())
if(..())
return 1
if(href_list["power"])
on = !on
@@ -18,7 +18,7 @@ Thus, the two variables affect pump operation are set in New():
name = "volumetric gas pump"
desc = "A volumetric pump"
can_unwrench = 1
var/on = 0
@@ -31,7 +31,7 @@ Thus, the two variables affect pump operation are set in New():
/obj/machinery/atmospherics/binary/volume_pump/on
on = 1
icon_state = "map_on"
/obj/machinery/atmospherics/binary/volume_pump/initialize()
..()
set_frequency(frequency)
@@ -52,9 +52,7 @@ Thus, the two variables affect pump operation are set in New():
add_underlay(T, node2, dir)
/obj/machinery/atmospherics/binary/volume_pump/process()
if(stat & (NOPOWER|BROKEN))
return
if(!on)
if(!..() || (stat & (NOPOWER|BROKEN)) || !on)
return 0
// Pump mechanism just won't do anything if the pressure is too high/too low
@@ -114,7 +112,7 @@ Thus, the two variables affect pump operation are set in New():
/obj/machinery/atmospherics/binary/volume_pump/receive_signal(datum/signal/signal)
if(!signal.data["tag"] || (signal.data["tag"] != id) || (signal.data["sigtype"]!="command"))
return 0
var/old_on = on //for logging
if(signal.data["power"])
@@ -129,7 +127,7 @@ Thus, the two variables affect pump operation are set in New():
text2num(signal.data["set_transfer_rate"]),
air1.volume
)
if(on != old_on)
investigate_log("was turned [on ? "on" : "off"] by a remote signal", "atmos")
@@ -154,7 +152,7 @@ Thus, the two variables affect pump operation are set in New():
return
/obj/machinery/atmospherics/binary/volume_pump/Topic(href,href_list)
if(..())
if(..())
return 1
if(href_list["power"])
on = !on
@@ -43,12 +43,11 @@
return 0
/obj/machinery/atmospherics/omni/filter/process()
..()
if(!on)
if(!..() || !on)
return 0
if(!input || !output)
return
return 0
var/datum/gas_mixture/output_air = output.air //BYOND doesn't like referencing "output.air.return_pressure()" so we need to make a direct reference
var/datum/gas_mixture/input_air = input.air // it's completely happy with them if they're in a loop though i.e. "P.air.return_pressure()"... *shrug*
@@ -56,10 +55,10 @@
var/output_pressure = output_air.return_pressure()
if(output_pressure >= target_pressure)
return
return 1
for(var/datum/omni_port/P in filters)
if(P.air.return_pressure() >= target_pressure)
return
return 1
var/pressure_delta = target_pressure - output_pressure
@@ -70,7 +69,7 @@
var/datum/gas_mixture/removed = input_air.remove(input.transfer_moles)
if(!removed)
return
return 1
for(var/datum/omni_port/P in filters)
var/datum/gas_mixture/filtered_out = new
@@ -107,7 +106,7 @@
input.transfer_moles = 0
input.parent.update = 1
return
return 1
/obj/machinery/atmospherics/omni/filter/ui_interact(mob/user, ui_key = "main", var/datum/nanoui/ui = null)
usr.set_machine(src)
@@ -177,7 +176,7 @@
return null
/obj/machinery/atmospherics/omni/filter/Topic(href, href_list)
if(..())
if(..())
return 1
switch(href_list["command"])
if("power")
@@ -277,4 +276,3 @@
initialize_directions |= P.dir
P.connect()
P.update = 1
@@ -84,8 +84,7 @@
return 0
/obj/machinery/atmospherics/omni/mixer/process()
..()
if(!on)
if(!..() || !on)
return 0
var/datum/gas_mixture/output_air = output.air
@@ -108,7 +107,7 @@
for(var/datum/omni_port/P in inputs)
if(!P.transfer_moles)
return
return 1
if(P.air.total_moles() < P.transfer_moles)
ratio_check = 1
continue
@@ -180,7 +179,7 @@
return data
/obj/machinery/atmospherics/omni/mixer/Topic(href, href_list)
if(..())
if(..())
return 1
switch(href_list["command"])
@@ -295,4 +294,3 @@
for(var/datum/omni_port/P in inputs)
if(P.dir == port)
P.con_lock = !P.con_lock
@@ -7,7 +7,7 @@
icon_state = "base"
use_power = 1
initialize_directions = 0
can_unwrench = 1
var/on = 0
@@ -47,7 +47,7 @@
ports += new_port
build_icons()
/obj/machinery/atmospherics/omni/Destroy()
for(var/datum/omni_port/P in ports)
if(P.node)
@@ -234,13 +234,13 @@
/obj/machinery/atmospherics/omni/proc/sort_ports()
return
// Pipenet procs
// Pipenet procs
/obj/machinery/atmospherics/omni/build_network()
for(var/datum/omni_port/P in ports)
if(!P.parent)
P.parent = new /datum/pipeline()
P.parent.build_pipeline(src)
P.parent.build_pipeline(src)
/obj/machinery/atmospherics/omni/disconnect(obj/machinery/atmospherics/reference)
for(var/datum/omni_port/P in ports)
if(reference == P.node)
@@ -248,14 +248,16 @@
qdel(P.parent)
P.node = null
update_ports()
/obj/machinery/atmospherics/omni/nullifyPipenet(datum/pipeline/P)
..()
if(!P)
return
for(var/datum/omni_port/PO in ports)
if(P == PO.parent)
PO.parent.other_airs -= PO.air
PO.parent = null
/obj/machinery/atmospherics/omni/returnPipenetAir(datum/pipeline/P)
for(var/datum/omni_port/PO in ports)
if(P == PO.parent)
@@ -270,14 +272,14 @@
var/list/nodes = list()
for(var/datum/omni_port/PO in ports)
nodes += PO.node
return nodes
/obj/machinery/atmospherics/omni/setPipenet(datum/pipeline/P, obj/machinery/atmospherics/A)
for(var/datum/omni_port/PO in ports)
if(A == PO.node)
PO.parent = P
/obj/machinery/atmospherics/omni/returnPipenet(obj/machinery/atmospherics/A)
for(var/datum/omni_port/P in ports)
if(A == P.node)
@@ -287,3 +289,11 @@
for(var/datum/omni_port/P in ports)
if(Old == P.parent)
P.parent = New
/obj/machinery/atmospherics/omni/process()
..()
for(var/datum/omni_port/port in ports)
if(!port.parent)
return 0
return 1
@@ -3,7 +3,7 @@
icon_state = "map"
can_unwrench = 1
name = "gas filter"
var/temp = null // -- TLE
@@ -23,7 +23,7 @@ Filter types:
var/frequency = 0
var/datum/radio_frequency/radio_connection
/obj/machinery/atmospherics/trinary/filter/flipped
icon_state = "mmap"
flipped = 1
@@ -71,8 +71,7 @@ Filter types:
update_icon()
/obj/machinery/atmospherics/trinary/filter/process()
..()
if(!on)
if(!..() || !on)
return 0
var/output_starting_pressure = air3.return_pressure()
@@ -223,4 +222,3 @@ Filter types:
src.attack_hand(M)
*/
return
@@ -3,7 +3,7 @@
icon_state = "map"
can_unwrench = 1
name = "gas mixer"
var/target_pressure = ONE_ATMOSPHERE
@@ -11,15 +11,15 @@
var/node2_concentration = 0.5
//node 3 is the outlet, nodes 1 & 2 are intakes
/obj/machinery/atmospherics/trinary/mixer/flipped
icon_state = "mmap"
flipped = 1
/obj/machinery/atmospherics/trinary/mixer/update_icon(var/safety = 0)
if(flipped)
icon_state = "m"
else
icon_state = "m"
else
icon_state = ""
if(!powered())
@@ -57,8 +57,7 @@
air3.volume = 300
/obj/machinery/atmospherics/trinary/mixer/process()
..()
if(!on)
if(!..() || !on)
return 0
var/output_starting_pressure = air3.return_pressure()
@@ -141,7 +140,7 @@
return
/obj/machinery/atmospherics/trinary/mixer/Topic(href,href_list)
if(..())
if(..())
return 1
if(href_list["power"])
on = !on
@@ -21,7 +21,7 @@
/obj/machinery/atmospherics/trinary/New()
..()
if(!flipped)
switch(dir)
if(NORTH)
@@ -41,8 +41,8 @@
if(EAST)
initialize_directions = WEST|EAST|NORTH
if(WEST)
initialize_directions = EAST|WEST|SOUTH
initialize_directions = EAST|WEST|SOUTH
air1 = new
air2 = new
air3 = new
@@ -65,7 +65,7 @@
node3 = null
nullifyPipenet(parent3)
return ..()
/obj/machinery/atmospherics/trinary/initialize()
..()
//Mixer:
@@ -134,6 +134,8 @@
/obj/machinery/atmospherics/trinary/nullifyPipenet(datum/pipeline/P)
..()
if(!P)
return
if(P == parent1)
parent1.other_airs -= air1
parent1 = null
@@ -185,7 +187,7 @@
parent2 = New
else if(Old == parent3)
parent3 = New
/obj/machinery/atmospherics/trinary/unsafe_pressure_release(var/mob/user,var/pressures)
..()
@@ -203,4 +205,7 @@
to_release.merge(air3.remove(shared_loss))
T.assume_air(to_release)
air_update_turf(1)
/obj/machinery/atmospherics/trinary/process()
..()
return parent1 && parent2 && parent3
@@ -23,9 +23,9 @@
return
/obj/machinery/atmospherics/unary/cold_sink/process()
..()
if(!on)
if(!..() || !on)
return 0
var/air_heat_capacity = air_contents.heat_capacity()
var/combined_heat_capacity = current_heat_capacity + air_heat_capacity
var/old_temperature = air_contents.temperature
@@ -5,7 +5,7 @@
name = "heat exchanger"
desc = "Exchanges heat between two input gases. Setup for fast heat transfer"
can_unwrench = 1
var/obj/machinery/atmospherics/unary/heat_exchanger/partner = null
@@ -32,7 +32,8 @@
..()
/obj/machinery/atmospherics/unary/heat_exchanger/process()
..()
if(!..())
return 0
if(!partner)
return 0
@@ -23,8 +23,7 @@
return
/obj/machinery/atmospherics/unary/heat_reservoir/process()
..()
if(!on)
if(!..() || !on)
return 0
var/air_heat_capacity = air_contents.heat_capacity()
var/combined_heat_capacity = current_heat_capacity + air_heat_capacity
@@ -5,7 +5,7 @@
layer = 3
can_unwrench = 1
name = "air injector"
desc = "Has a valve and pump attached to it"
@@ -22,7 +22,7 @@
var/datum/radio_frequency/radio_connection
Mtoollink = 1
settagwhitelist = list("id_tag")
/obj/machinery/atmospherics/unary/outlet_injector/on
on = 1
@@ -52,7 +52,9 @@
update_icon()
/obj/machinery/atmospherics/unary/outlet_injector/process()
..()
if(!..())
return 0
injecting = 0
if(!on || stat & NOPOWER)
@@ -29,8 +29,7 @@
air_contents.volume = 50
/obj/machinery/atmospherics/unary/oxygen_generator/process()
..()
if(!on)
if(!..() || !on)
return 0
var/total_moles = air_contents.total_moles()
@@ -6,38 +6,39 @@
desc = "A large air vent"
can_unwrench = 1
var/volume = 250
/obj/machinery/atmospherics/unary/passive_vent/high_volume
name = "large passive vent"
volume = 1000
/obj/machinery/atmospherics/unary/passive_vent/New()
..()
air_contents.volume = volume
/obj/machinery/atmospherics/unary/passive_vent/process()
..()
if(!..())
return 0
if(!node)
return 0
var/datum/gas_mixture/environment = loc.return_air()
var/pressure_delta = air_contents.return_pressure() - environment.return_pressure()
// based on pressure_pump to equalize pressure
// already equalized
if(abs(pressure_delta) < 0.01)
return 1
if(pressure_delta > 0)
// transfer from pipe air to environment
if((air_contents.total_moles() > 0) && (air_contents.temperature > 0))
var/transfer_moles = pressure_delta * environment.volume / (air_contents.temperature * R_IDEAL_GAS_EQUATION)
transfer_moles = min(transfer_moles, volume)
var/datum/gas_mixture/removed = air_contents.remove(transfer_moles)
loc.assume_air(removed)
air_update_turf()
@@ -47,11 +48,11 @@
if((environment.total_moles() > 0) && (environment.temperature > 0))
var/transfer_moles = pressure_delta * air_contents.volume / (environment.temperature * R_IDEAL_GAS_EQUATION)
transfer_moles = min(transfer_moles, volume)
var/datum/gas_mixture/removed = loc.remove_air(transfer_moles)
air_contents.merge(removed)
air_update_turf()
parent.update = 1
return 1
@@ -7,11 +7,11 @@
can_unwrench = 1
layer = 2.4
var/obj/machinery/portable_atmospherics/connected_device
var/on = 0
/obj/machinery/atmospherics/unary/portables_connector/Destroy()
if(connected_device)
connected_device.disconnect()
@@ -29,8 +29,8 @@
add_underlay(T, node, dir)
/obj/machinery/atmospherics/unary/portables_connector/process()
if(!connected_device)
return
if(!..() || !connected_device)
return 0
parent.update = 1
/obj/machinery/atmospherics/unary/portables_connector/attackby(var/obj/item/weapon/W as obj, var/mob/user as mob, params)
@@ -39,7 +39,7 @@
to_chat(user, "<span class='danger'>You cannot unwrench this [src], detach [connected_device] first.</span>")
return 1
return ..()
/obj/machinery/atmospherics/unary/portables_connector/portableConnectorReturnAir()
return connected_device.portableConnectorReturnAir()
@@ -4,7 +4,7 @@
//Transfers heat between a pipe system and environment, based on which has a greater thermal energy concentration
icon = 'icons/obj/atmospherics/cold_sink.dmi'
icon_state = "off"
can_unwrench = 1
name = "thermal tansfer plate"
@@ -18,7 +18,8 @@
icon_state = "[prefix]off"
/obj/machinery/atmospherics/unary/thermal_plate/process()
..()
if(!..())
return 0
var/datum/gas_mixture/environment = loc.return_air()
@@ -64,8 +64,11 @@
/obj/machinery/atmospherics/unary/nullifyPipenet(datum/pipeline/P)
..()
parent.other_airs -= air_contents
parent = null
if(!P)
return
if(P == parent)
parent.other_airs -= air_contents
parent = null
/obj/machinery/atmospherics/unary/returnPipenetAir()
return air_contents
@@ -81,8 +84,8 @@
/obj/machinery/atmospherics/unary/replacePipenet(datum/pipeline/Old, datum/pipeline/New)
if(Old == parent)
parent = New
parent = New
/obj/machinery/atmospherics/unary/unsafe_pressure_release(var/mob/user,var/pressures)
..()
@@ -95,4 +98,7 @@
var/datum/gas_mixture/to_release = air_contents.remove(lost)
T.assume_air(to_release)
air_update_turf(1)
/obj/machinery/atmospherics/unary/process()
..()
return parent
@@ -119,9 +119,8 @@
update_underlays()
/obj/machinery/atmospherics/unary/vent_pump/process()
..()
if(stat & (NOPOWER|BROKEN))
return
if(!..() || (stat & (NOPOWER|BROKEN)))
return 0
if (!node)
on = 0
//broadcast_status() // from now air alarm/control computer should request update purposely --rastaf0
@@ -12,7 +12,7 @@
active_power_usage = 60
can_unwrench = 1
var/area/initial_loc
var/id_tag = null
var/frequency = 1439
@@ -175,7 +175,8 @@
check_turfs()
/obj/machinery/atmospherics/unary/vent_scrubber/process()
..()
if(!..())
return 0
if (widenet)
check_turfs()
@@ -364,7 +365,7 @@
return MT_UPDATE
return ..()
/obj/machinery/atmospherics/unary/vent_scrubber/can_crawl_through()
return !welded