Merge pull request #4627 from Aranclanos/pipenetsandpipestwo

Pipes and pipenets
This commit is contained in:
Cheridan
2014-09-07 19:12:16 -05:00
16 changed files with 496 additions and 659 deletions

View File

@@ -21,13 +21,11 @@ Pipelines + Other Objects -> Pipe network
/obj/machinery/atmospherics/var/initialize_directions = 0
/obj/machinery/atmospherics/var/pipe_color
/obj/machinery/atmospherics/var/pipe_color/
/*
/obj/machinery/atmospherics/process()
if(gc_destroyed) //comments on /vg/ imply that GC'd pipes still process
return PROCESS_KILL
build_network()
//build_network()
*/
/obj/machinery/atmospherics/proc/network_expand(datum/pipe_network/new_network, obj/machinery/atmospherics/pipe/reference)
// Check to see if should be added to network. Add self if so and adjust variables appropriately.
// Note don't forget to have neighbors look as well!
@@ -89,3 +87,6 @@ Pipelines + Other Objects -> Pipe network
qdel(src)
else
return ..()
/obj/machinery/atmospherics/proc/nullifyPipenetwork()
return

View File

@@ -128,3 +128,7 @@
node2 = null
return null
/obj/machinery/atmospherics/binary/nullifyPipenetwork()
network1 = null
network2 = null

View File

@@ -160,3 +160,8 @@
node3 = null
return null
/obj/machinery/atmospherics/trinary/nullifyPipenetwork()
network1 = null
network2 = null
network3 = null

View File

@@ -49,7 +49,7 @@
if(!infiniteloop)
target.initialize(1)
break
build_network()
//build_network()
update_icon()
@@ -97,3 +97,6 @@
del(network)
return null
/obj/machinery/atmospherics/unary/nullifyPipenetwork()
network = null

View File

@@ -11,7 +11,7 @@
can_unwrench = 1
var/open = 0
var/openDuringInit = 0
var/openDuringInit //useless, must remove
var/obj/machinery/atmospherics/node1
var/obj/machinery/atmospherics/node2
@@ -178,12 +178,7 @@ obj/machinery/atmospherics/valve/attack_hand(mob/user as mob)
node2 = target
break
build_network()
if(openDuringInit)
close()
open()
openDuringInit = 0
//build_network()
/*
var/connect_directions
@@ -309,3 +304,7 @@ obj/machinery/atmospherics/valve/attack_hand(mob/user as mob)
close()
else
open()
/obj/machinery/atmospherics/valve/nullifyPipenetwork()
network_node1 = null
network_node2 = null

View File

@@ -12,7 +12,14 @@ var/global/list/datum/pipe_network/pipe_networks = list()
/datum/pipe_network/New()
air_transient = new()
..()
/datum/pipe_network/Destroy()
pipe_networks -= src
for(var/datum/pipeline/P in line_members)
P.network = null
for(var/obj/machinery/atmospherics/A in normal_members)
A.nullifyPipenetwork()
..()
/datum/pipe_network/proc/process()
@@ -30,7 +37,7 @@ var/global/list/datum/pipe_network/pipe_networks = list()
//Notes: Assuming that members will add themselves to appropriate roster in network_expand()
if(!start_normal)
del(src)
qdel(src)
start_normal.network_expand(src, reference)
@@ -39,7 +46,7 @@ var/global/list/datum/pipe_network/pipe_networks = list()
if((normal_members.len>0)||(line_members.len>0))
pipe_networks += src
else
del(src)
qdel(src)
/datum/pipe_network/proc/merge(datum/pipe_network/giver)
if(giver==src) return 0
@@ -56,8 +63,6 @@ var/global/list/datum/pipe_network/pipe_networks = list()
for(var/datum/pipeline/line_member in giver.line_members)
line_member.network = src
del(giver)
update_network_gases()
return 1

View File

@@ -8,16 +8,6 @@
var/alert_pressure = 0
/datum/pipeline/Del()
if(network)
del(network)
if(air && air.volume)
temporarily_store_air()
del(air)
..()
/datum/pipeline/proc/process()//This use to be called called from the pipe networks
//Check to see if pressure is within acceptable limits
@@ -51,9 +41,10 @@
corresponding.moles = trace_gas.moles*member.volume/air.volume
var/pipenetwarnings = 10
/datum/pipeline/proc/build_pipeline(obj/machinery/atmospherics/pipe/base)
air = new
var/list/possible_expansions = list(base)
members = list(base)
edges = list()
@@ -67,7 +58,6 @@
base.air_temporary = null
else
air = new
while(possible_expansions.len>0)
for(var/obj/machinery/atmospherics/pipe/borderline in possible_expansions)
@@ -77,6 +67,13 @@
if(result.len>0)
for(var/obj/machinery/atmospherics/pipe/item in result)
if(!members.Find(item))
if(item.parent)
if(pipenetwarnings > 0)
error("[item.type] added to a pipenet while still having one. ([item.x], [item.y], [item.z])")
pipenetwarnings -= 1
if(pipenetwarnings == 0)
error("further messages about pipenets will be supressed")
members += item
possible_expansions += item
@@ -97,6 +94,57 @@
air.volume = volume
/datum/pipeline/proc/addMember(obj/machinery/atmospherics/pipe/P)
P.parent = src
var/list/adjacent = P.pipeline_expansion()
var/list/oldedges = list()
for(var/obj/machinery/atmospherics/pipe/I in adjacent)
oldedges += I
if(I.parent == src)
continue
var/datum/pipeline/E = I.parent
if(E.members.len > members.len)
members.Add(E.members)
for(var/obj/machinery/atmospherics/pipe/S in E.members)
S.parent = src
edges.Add(E.edges)
air.merge(E.air)
adjacent -= I
if(adjacent.len)
edges |= P
members |= P
if(oldedges.len)
for(var/obj/machinery/atmospherics/pipe/O in oldedges)
var/list/Oedges = O.pipeline_expansion()
for(var/obj/machinery/atmospherics/pipe/Oedgepipes in Oedges)
Oedges -= Oedgepipes
if(Oedges.len)
edges |= O
else
edges -= O
/datum/pipeline/proc/removeLastMember(obj/machinery/atmospherics/pipe/P)
if(members.len == 1 && members.Find(P))
qdel()
if(P.air_temporary)
var/turf/T = P.loc
T.assume_air(P.air_temporary)
/obj/machinery/atmospherics/proc/addMember(obj/machinery/atmospherics/pipe/P)
return
/obj/machinery/atmospherics/pipe/addMember(obj/machinery/atmospherics/pipe/P)
parent.addMember(P)
/datum/pipeline/Destroy()
if(network)
qdel(network)
if(air && air.volume)
temporarily_store_air()
for(var/obj/machinery/atmospherics/pipe/P in members)
P.parent = null
..()
/datum/pipeline/proc/network_expand(datum/pipe_network/new_network, obj/machinery/atmospherics/pipe/reference)
if(new_network.line_members.Find(src))

View File

@@ -4,58 +4,42 @@
icon_state = "intact"
level = 2
var/initialize_directions_he
minimum_temperature_difference = 20
thermal_conductivity = WINDOW_HEAT_TRANSFER_COEFFICIENT
// BubbleWrap
/obj/machinery/atmospherics/pipe/simple/heat_exchanging/New()
..()
initialize_directions_he = initialize_directions // The auto-detection from /pipe is good enough for a simple HE pipe
// BubbleWrap END
/obj/machinery/atmospherics/pipe/simple/heat_exchanging/initialize()
normalize_dir()
var/node1_dir
var/node2_dir
for(var/direction in cardinal)
if(direction&initialize_directions_he)
if (!node1_dir)
node1_dir = direction
else if (!node2_dir)
node2_dir = direction
for(var/obj/machinery/atmospherics/pipe/simple/heat_exchanging/target in get_step(src,node1_dir))
if(target.initialize_directions_he & get_dir(target,src))
node1 = target
break
for(var/obj/machinery/atmospherics/pipe/simple/heat_exchanging/target in get_step(src,node2_dir))
if(target.initialize_directions_he & get_dir(target,src))
node2 = target
break
var/N = 2
for(var/D in cardinal)
if(D & initialize_directions_he)
N--
for(var/obj/machinery/atmospherics/pipe/simple/heat_exchanging/target in get_step(src, D))
if(target.initialize_directions_he & get_dir(target,src))
if(!node1 && N == 1)
node1 = target
break
if(!node2 && N == 0)
node2 = target
break
update_icon()
return
/obj/machinery/atmospherics/pipe/simple/heat_exchanging/process()
if(!parent)
..()
else
var/environment_temperature = 0
if(istype(loc, /turf/simulated/))
if(loc:blocks_air)
environment_temperature = loc:temperature
else
var/datum/gas_mixture/environment = loc.return_air()
environment_temperature = environment.temperature
else
var/environment_temperature = 0
if(istype(loc, /turf/simulated))
if(loc:blocks_air)
environment_temperature = loc:temperature
var/datum/gas_mixture/pipe_air = return_air()
if(abs(environment_temperature-pipe_air.temperature) > minimum_temperature_difference)
parent.temperature_interact(loc, volume, thermal_conductivity)
else
var/datum/gas_mixture/environment = loc.return_air()
environment_temperature = environment.temperature
else
environment_temperature = loc:temperature
var/datum/gas_mixture/pipe_air = return_air()
if(abs(environment_temperature-pipe_air.temperature) > minimum_temperature_difference)
parent.temperature_interact(loc, volume, thermal_conductivity)
/obj/machinery/atmospherics/pipe/simple/heat_exchanging/junction
icon = 'icons/obj/pipes/junction.dmi'
@@ -64,23 +48,21 @@
minimum_temperature_difference = 300
thermal_conductivity = WALL_HEAT_TRANSFER_COEFFICIENT
// BubbleWrap
/obj/machinery/atmospherics/pipe/simple/heat_exchanging/junction/New()
.. ()
switch ( dir )
if ( SOUTH )
..()
switch(dir)
if(SOUTH)
initialize_directions = NORTH
initialize_directions_he = SOUTH
if ( NORTH )
if(NORTH)
initialize_directions = SOUTH
initialize_directions_he = NORTH
if ( EAST )
if(EAST)
initialize_directions = WEST
initialize_directions_he = EAST
if ( WEST )
if(WEST)
initialize_directions = EAST
initialize_directions_he = WEST
// BubbleWrap END
/obj/machinery/atmospherics/pipe/simple/heat_exchanging/junction/update_icon()
if(node1&&node2)
@@ -89,8 +71,6 @@
var/have_node1 = node1?1:0
var/have_node2 = node2?1:0
icon_state = "exposed[have_node1][have_node2]"
if(!node1&&!node2)
qdel(src)
/obj/machinery/atmospherics/pipe/simple/heat_exchanging/junction/initialize()
for(var/obj/machinery/atmospherics/target in get_step(src,initialize_directions))
@@ -101,6 +81,5 @@
if(target.initialize_directions_he & get_dir(target,src))
node2 = target
break
update_icon()
return

File diff suppressed because it is too large Load Diff

View File

@@ -70,7 +70,8 @@ var/datum/controller/garbage_collector/garbage = new()
// This should be overridden to remove all references pointing to the object being destroyed.
// Return true if the the GC controller should allow the object to continue existing. (Useful if pooling objects.)
/datum/proc/Destroy()
del(src)
//del(src)
return
/datum/var/gc_destroyed //Time when this object was destroyed.

View File

@@ -254,8 +254,6 @@ Buildable meters
return 1
// no conflicts found
var/pipefailtext = "<span class='danger'>There's nothing to connect this pipe section to! (with how the pipe code works, at least one end needs to be connected to something, otherwise the game deletes the segment)</span>"
switch(pipe_type)
if(PIPE_SIMPLE_STRAIGHT, PIPE_SIMPLE_BENT)
var/obj/machinery/atmospherics/pipe/simple/P = new( src.loc )
@@ -264,16 +262,13 @@ Buildable meters
var/turf/T = P.loc
P.level = T.intact ? 2 : 1
P.initialize()
if (!P)
usr << pipefailtext
return 1
P.build_network()
if (P.node1)
P.node1.initialize()
P.node1.build_network()
P.node1.addMember(P)
if (P.node2)
P.node2.initialize()
P.node2.build_network()
P.node2.addMember(P)
P.build_network()
if(PIPE_HE_STRAIGHT, PIPE_HE_BENT)
var/obj/machinery/atmospherics/pipe/simple/heat_exchanging/P = new ( src.loc )
@@ -283,16 +278,13 @@ Buildable meters
//var/turf/T = P.loc
//P.level = T.intact ? 2 : 1
P.initialize()
if (!P)
usr << pipefailtext
return 1
P.build_network()
if (P.node1)
P.node1.initialize()
P.node1.build_network()
P.node1.addMember(P)
if (P.node2)
P.node2.initialize()
P.node2.build_network()
P.node2.addMember(P)
P.build_network()
if(PIPE_CONNECTOR) // connector
var/obj/machinery/atmospherics/portables_connector/C = new( src.loc )
@@ -310,26 +302,22 @@ Buildable meters
if(PIPE_MANIFOLD) //manifold
var/obj/machinery/atmospherics/pipe/manifold/M = new( src.loc )
var/obj/machinery/atmospherics/pipe/manifold/M = new(loc)
M.dir = dir
M.initialize_directions = pipe_dir
//M.New()
var/turf/T = M.loc
M.level = T.intact ? 2 : 1
M.initialize()
if (!M)
usr << "There's nothing to connect this manifold to! (with how the pipe code works, at least one end needs to be connected to something, otherwise the game deletes the segment)"
return 1
M.build_network()
if (M.node1)
M.node1.initialize()
M.node1.build_network()
M.node1.addMember(M)
if (M.node2)
M.node2.initialize()
M.node2.build_network()
M.node2.addMember(M)
if (M.node3)
M.node3.initialize()
M.node3.build_network()
M.node3.addMember(M)
M.build_network()
if(PIPE_JUNCTION)
var/obj/machinery/atmospherics/pipe/simple/heat_exchanging/junction/P = new ( src.loc )
@@ -339,16 +327,13 @@ Buildable meters
//var/turf/T = P.loc
//P.level = T.intact ? 2 : 1
P.initialize()
if (!P)
usr << "There's nothing to connect this junction to! (with how the pipe code works, at least one end needs to be connected to something, otherwise the game deletes the segment)"
return 1
P.build_network()
if (P.node1)
P.node1.initialize()
P.node1.build_network()
P.node1.addMember(P)
if (P.node2)
P.node2.initialize()
P.node2.build_network()
P.node2.addMember(P)
P.build_network()
if(PIPE_UVENT) //unary vent
var/obj/machinery/atmospherics/unary/vent_pump/V = new( src.loc )
@@ -479,16 +464,13 @@ Buildable meters
var/turf/T = P.loc
P.level = T.intact ? 2 : 1
P.initialize()
if (!P)
usr << pipefailtext
return 1
P.build_network()
if (P.node1)
P.node1.initialize()
P.node1.build_network()
P.node1.addMember(P)
if (P.node2)
P.node2.initialize()
P.node2.build_network()
P.node2.addMember(P)
P.build_network()
if(PIPE_PASSIVE_GATE) //passive gate
var/obj/machinery/atmospherics/binary/passive_gate/P = new(src.loc)

Binary file not shown.

Before

Width:  |  Height:  |  Size: 18 KiB

After

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.9 KiB

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 80 KiB

After

Width:  |  Height:  |  Size: 82 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.8 KiB

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.8 KiB

After

Width:  |  Height:  |  Size: 883 B