Reverted in r847 pipes-related changes is returning. With small improvements.

git-svn-id: http://tgstation13.googlecode.com/svn/trunk@856 316c924e-a436-60f5-8080-3fe189b3f50e
This commit is contained in:
rastaf.zero@gmail.com
2011-01-15 17:22:24 +00:00
parent 00f81c99e6
commit 1b5f4611bd
8 changed files with 147 additions and 110 deletions

View File

@@ -196,5 +196,5 @@ obj/machinery/atmospherics/binary/pump
"[user] unfastens \the [src].", \ "[user] unfastens \the [src].", \
"\blue You have unfastened \the [src].", \ "\blue You have unfastened \the [src].", \
"You hear ratchet.") "You hear ratchet.")
new /obj/item/weapon/pipe(loc, make_from=src) new /obj/item/pipe(loc, make_from=src)
del(src) del(src)

View File

@@ -134,6 +134,8 @@
if (connected_device) if (connected_device)
user << "\red You cannot unwrench this [src], dettach [connected_device] first." user << "\red You cannot unwrench this [src], dettach [connected_device] first."
return 1 return 1
if (locate(/obj/machinery/portable_atmospherics, src.loc))
return 1
var/turf/T = src.loc var/turf/T = src.loc
if (level==1 && isturf(T) && T.intact) if (level==1 && isturf(T) && T.intact)
user << "\red You must remove the plating first." user << "\red You must remove the plating first."
@@ -151,5 +153,5 @@
"[user] unfastens \the [src].", \ "[user] unfastens \the [src].", \
"\blue You have unfastened \the [src].", \ "\blue You have unfastened \the [src].", \
"You hear ratchet.") "You hear ratchet.")
new /obj/item/weapon/pipe(loc, make_from=src) new /obj/item/pipe(loc, make_from=src)
del(src) del(src)

View File

@@ -274,5 +274,5 @@
"[user] unfastens \the [src].", \ "[user] unfastens \the [src].", \
"\blue You have unfastened \the [src].", \ "\blue You have unfastened \the [src].", \
"You hear ratchet.") "You hear ratchet.")
new /obj/item/weapon/pipe(loc, make_from=src) new /obj/item/pipe(loc, make_from=src)
del(src) del(src)

View File

@@ -213,5 +213,5 @@
"[user] unfastens \the [src].", \ "[user] unfastens \the [src].", \
"\blue You have unfastened \the [src].", \ "\blue You have unfastened \the [src].", \
"You hear ratchet.") "You hear ratchet.")
new /obj/item/weapon/pipe(loc, make_from=src) new /obj/item/pipe(loc, make_from=src)
del(src) del(src)

View File

@@ -106,6 +106,12 @@ obj/machinery/atmospherics/valve
build_network() build_network()
return 1 return 1
proc/normalize_dir()
if(dir==3)
dir = 1
else if(dir==12)
dir = 4
attack_ai(mob/user as mob) attack_ai(mob/user as mob)
return return
@@ -129,10 +135,28 @@ obj/machinery/atmospherics/valve
return return
initialize() initialize()
if(node1 && node2) return normalize_dir()
var/node1_dir
var/node2_dir
for(var/direction in cardinal)
if(direction&initialize_directions)
if (!node1_dir)
node1_dir = direction
else if (!node2_dir)
node2_dir = direction
for(var/obj/machinery/atmospherics/target in get_step(src,node1_dir))
if(target.initialize_directions & get_dir(target,src))
node1 = target
break
for(var/obj/machinery/atmospherics/target in get_step(src,node2_dir))
if(target.initialize_directions & get_dir(target,src))
node2 = target
break
/*
var/connect_directions var/connect_directions
switch(dir) switch(dir)
if(NORTH) if(NORTH)
connect_directions = NORTH|SOUTH connect_directions = NORTH|SOUTH
@@ -163,7 +187,7 @@ obj/machinery/atmospherics/valve
break break
if(node1) if(node1)
break break
*/
build_network() build_network()
if(!network_node1 && node1) if(!network_node1 && node1)
network_node1 = new /datum/pipe_network() network_node1 = new /datum/pipe_network()
@@ -283,5 +307,5 @@ obj/machinery/atmospherics/valve
"[user] unfastens \the [src].", \ "[user] unfastens \the [src].", \
"\blue You have unfastened \the [src].", \ "\blue You have unfastened \the [src].", \
"You hear ratchet.") "You hear ratchet.")
new /obj/item/weapon/pipe(loc, make_from=src) new /obj/item/pipe(loc, make_from=src)
del(src) del(src)

View File

@@ -155,8 +155,17 @@ obj/machinery/atmospherics/pipe
proc/burst() proc/burst()
src.visible_message("\red \bold [src] bursts!"); src.visible_message("\red \bold [src] bursts!");
playsound(src.loc, 'bang.ogg', 25, 1) playsound(src.loc, 'bang.ogg', 25, 1)
var/datum/effects/system/harmless_smoke_spread/smoke = new
smoke.set_up(1,0, src.loc, 0)
smoke.start()
del(src) del(src)
proc/normalize_dir()
if(dir==3)
dir = 1
else if(dir==12)
dir = 4
Del() Del()
if(node1) if(node1)
node1.disconnect(src) node1.disconnect(src)
@@ -169,8 +178,6 @@ obj/machinery/atmospherics/pipe
return list(node1, node2) return list(node1, node2)
update_icon() update_icon()
if(dir==3) dir = 1
else if(dir==12) dir = 4
if(node1&&node2) if(node1&&node2)
var/C = "" var/C = ""
switch(color) switch(color)
@@ -187,36 +194,35 @@ obj/machinery/atmospherics/pipe
//dir = node1_direction|node2_direction //dir = node1_direction|node2_direction
else else
if(!node1&&!node2)
del(src) //TODO: silent deleting looks weird
var/have_node1 = node1?1:0 var/have_node1 = node1?1:0
var/have_node2 = node2?1:0 var/have_node2 = node2?1:0
icon_state = "exposed[have_node1][have_node2][invisibility ? "-f" : "" ]" icon_state = "exposed[have_node1][have_node2][invisibility ? "-f" : "" ]"
if(!node1&&!node2)
del(src)
initialize() initialize()
var/connect_directions = initialize_directions normalize_dir()
var/node1_dir
var/node2_dir
for(var/direction in cardinal) for(var/direction in cardinal)
if(direction&connect_directions) if(direction&initialize_directions)
for(var/obj/machinery/atmospherics/target in get_step(src,direction)) if (!node1_dir)
if(target.initialize_directions & get_dir(target,src)) node1_dir = direction
node1 = target else if (!node2_dir)
connect_directions &= ~direction node2_dir = direction
break
if (node1) for(var/obj/machinery/atmospherics/target in get_step(src,node1_dir))
break if(target.initialize_directions & get_dir(target,src))
node1 = target
break
for(var/obj/machinery/atmospherics/target in get_step(src,node2_dir))
if(target.initialize_directions & get_dir(target,src))
node2 = target
break
for(var/direction in cardinal)
if(direction&connect_directions)
for(var/obj/machinery/atmospherics/target in get_step(src,direction))
if(target.initialize_directions & get_dir(target,src))
node2 = target
connect_directions &= ~direction
break
if(node2)
break
var/turf/T = src.loc // hide if turf is not intact var/turf/T = src.loc // hide if turf is not intact
hide(T.intact) hide(T.intact)
update_icon() update_icon()
@@ -268,16 +274,14 @@ obj/machinery/atmospherics/pipe
del(src) del(src)
initialize() initialize()
if(!node1) for(var/obj/machinery/atmospherics/target in get_step(src,initialize_directions))
for(var/obj/machinery/atmospherics/pipe/simple/target in get_step(src,initialize_directions)) if(target.initialize_directions & get_dir(target,src))
if(target.initialize_directions & get_dir(target,src)) node1 = target
node1 = target break
break for(var/obj/machinery/atmospherics/pipe/simple/heat_exchanging/target in get_step(src,initialize_directions_he))
if(!node2) if(target.initialize_directions_he & get_dir(target,src))
for(var/obj/machinery/atmospherics/pipe/simple/heat_exchanging/target in get_step(src,initialize_directions_he)) node2 = target
if(target.initialize_directions_he & get_dir(target,src)) break
node2 = target
break
update_icon() update_icon()
@@ -291,26 +295,26 @@ obj/machinery/atmospherics/pipe
thermal_conductivity = WINDOW_HEAT_TRANSFER_COEFFICIENT thermal_conductivity = WINDOW_HEAT_TRANSFER_COEFFICIENT
initialize() initialize()
var/connect_directions = initialize_directions_he normalize_dir()
var/node1_dir
var/node2_dir
for(var/direction in cardinal) for(var/direction in cardinal)
if(direction&connect_directions) if(direction&initialize_directions_he)
for(var/obj/machinery/atmospherics/pipe/simple/heat_exchanging/target in get_step(src,direction)) if (!node1_dir)
if(target.initialize_directions_he & get_dir(target,src)) node1_dir = direction
node1 = target else if (!node2_dir)
connect_directions &= ~direction node2_dir = direction
break
if (node1) for(var/obj/machinery/atmospherics/pipe/simple/heat_exchanging/target in get_step(src,node1_dir))
break 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
for(var/direction in cardinal)
if(direction&connect_directions)
for(var/obj/machinery/atmospherics/pipe/simple/heat_exchanging/target in get_step(src,direction))
if(target.initialize_directions_he & get_dir(target,src))
node2 = target
connect_directions &= ~direction
break
if (node2)
break
update_icon() update_icon()
@@ -711,9 +715,9 @@ obj/machinery/atmospherics/pipe
update_icon() update_icon()
obj/machinery/atmospherics/pipe/attackby(var/obj/item/weapon/W as obj, var/mob/user as mob) obj/machinery/atmospherics/pipe/attackby(var/obj/item/weapon/W as obj, var/mob/user as mob)
if (istype(W, /obj/machinery/atmospherics/pipe/tank)) if (istype(src, /obj/machinery/atmospherics/pipe/tank))
return ..() return ..()
if (istype(W, /obj/machinery/atmospherics/pipe/vent)) if (istype(src, /obj/machinery/atmospherics/pipe/vent))
return ..() return ..()
if (!istype(W, /obj/item/weapon/wrench)) if (!istype(W, /obj/item/weapon/wrench))
return ..() return ..()
@@ -734,5 +738,9 @@ obj/machinery/atmospherics/pipe/attackby(var/obj/item/weapon/W as obj, var/mob/u
"[user] unfastens \the [src].", \ "[user] unfastens \the [src].", \
"\blue You have unfastened \the [src].", \ "\blue You have unfastened \the [src].", \
"You hear ratchet.") "You hear ratchet.")
new /obj/item/weapon/pipe(loc, make_from=src) new /obj/item/pipe(loc, make_from=src)
for (var/obj/machinery/meter/meter in T)
if (meter.target == src)
new /obj/item/pipe_meter(T)
del(meter)
del(src) del(src)

View File

@@ -54,6 +54,7 @@
var/datum/pipe_network/network = connected_port.return_network(src) var/datum/pipe_network/network = connected_port.return_network(src)
if(network && !network.gases.Find(air_contents)) if(network && !network.gases.Find(air_contents))
network.gases += air_contents network.gases += air_contents
network.update = 1
return 1 return 1

View File

@@ -16,7 +16,7 @@ Buildable meters
#define PIPE_INSULATED_STRAIGHT 11 #define PIPE_INSULATED_STRAIGHT 11
#define PIPE_INSULATED_BENT 12 #define PIPE_INSULATED_BENT 12
/obj/item/weapon/pipe /obj/item/pipe
name = "pipe" name = "pipe"
desc = "A pipe" desc = "A pipe"
var/pipe_type = 0 var/pipe_type = 0
@@ -28,8 +28,8 @@ Buildable meters
flags = TABLEPASS|FPRINT flags = TABLEPASS|FPRINT
w_class = 4 w_class = 4
level = 2 level = 2
//TODO: список номер_типа -> тип
/obj/item/weapon/pipe/New(var/loc, var/pipe_type as num, var/dir as num, var/obj/machinery/atmospherics/make_from = null) /obj/item/pipe/New(var/loc, var/pipe_type as num, var/dir as num, var/obj/machinery/atmospherics/make_from = null)
..() ..()
if (make_from) if (make_from)
src.dir = make_from.dir src.dir = make_from.dir
@@ -41,8 +41,10 @@ Buildable meters
is_bent = 1 is_bent = 1
if (istype(make_from, /obj/machinery/atmospherics/pipe/simple/heat_exchanging/junction)) if (istype(make_from, /obj/machinery/atmospherics/pipe/simple/heat_exchanging/junction))
src.pipe_type = PIPE_JUNCTION src.pipe_type = PIPE_JUNCTION
else if(istype(make_from, /obj/machinery/atmospherics/pipe/simple/heat_exchanging)) else if(istype(make_from, /obj/machinery/atmospherics/pipe/simple/heat_exchanging))
src.pipe_type = PIPE_HE_STRAIGHT + is_bent src.pipe_type = PIPE_HE_STRAIGHT + is_bent
else if(istype(make_from, /obj/machinery/atmospherics/pipe/simple/insulated))
src.pipe_type = PIPE_INSULATED_STRAIGHT + is_bent
else if(istype(make_from, /obj/machinery/atmospherics/pipe/simple)) else if(istype(make_from, /obj/machinery/atmospherics/pipe/simple))
src.pipe_type = PIPE_SIMPLE_STRAIGHT + is_bent src.pipe_type = PIPE_SIMPLE_STRAIGHT + is_bent
else if(istype(make_from, /obj/machinery/atmospherics/portables_connector)) else if(istype(make_from, /obj/machinery/atmospherics/portables_connector))
@@ -57,19 +59,17 @@ Buildable meters
src.pipe_type = PIPE_PUMP src.pipe_type = PIPE_PUMP
else if(istype(make_from, /obj/machinery/atmospherics/unary/vent_scrubber)) else if(istype(make_from, /obj/machinery/atmospherics/unary/vent_scrubber))
src.pipe_type = PIPE_SCRUBBER src.pipe_type = PIPE_SCRUBBER
else if(istype(make_from, /obj/machinery/atmospherics/pipe/simple/insulated))
src.pipe_type = PIPE_INSULATED_STRAIGHT + is_bent
if (is_bent)
src.dir = make_from.initialize_directions //workaround. Bent pipes with one node==null have cardinal direction. - rastaf0
else else
src.pipe_type = pipe_type src.pipe_type = pipe_type
src.dir = dir src.dir = dir
//src.pipe_dir = get_pipe_dir() //src.pipe_dir = get_pipe_dir()
update() update()
src.pixel_x = rand(-5, 5)
src.pixel_y = rand(-5, 5)
//update the name and icon of the pipe item depending on the type //update the name and icon of the pipe item depending on the type
/obj/item/weapon/pipe/proc/update() /obj/item/pipe/proc/update()
var/list/nlist = list( \ var/list/nlist = list( \
"pipe", \ "pipe", \
"bent pipe", \ "bent pipe", \
@@ -102,31 +102,13 @@ Buildable meters
"insulated", \ "insulated", \
) )
icon_state = islist[pipe_type + 1] icon_state = islist[pipe_type + 1]
updateicon()
//update the icon of the item
/obj/item/weapon/pipe/proc/updateicon()
if(invisibility) // true if placed under floor
icon -= rgb(0,0,0,128) // fade the icon
else
icon = initial(icon) // otherwise reset to inital icon
// called to hide or unhide a pipe
// i=true if hiding
/obj/item/weapon/pipe/hide(var/i)
invisibility = i ? 101 : 0 // make hidden pipe items invisible
updateicon()
//called when a turf is attacked with a pipe item //called when a turf is attacked with a pipe item
// place the pipe on the turf, setting pipe level to 1 (underfloor) if the turf is not intact // place the pipe on the turf, setting pipe level to 1 (underfloor) if the turf is not intact
// rotate the pipe item clockwise // rotate the pipe item clockwise
/obj/item/weapon/pipe/verb/rotate() /obj/item/pipe/verb/rotate()
set name = "Rotate Pipe" set name = "Rotate Pipe"
set src in view(1) set src in view(1)
@@ -134,18 +116,30 @@ Buildable meters
return return
src.dir = turn(src.dir, -90) src.dir = turn(src.dir, -90)
if (pipe_type in list (PIPE_SIMPLE_STRAIGHT, PIPE_HE_STRAIGHT, PIPE_INSULATED_STRAIGHT, PIPE_MVALVE))
if(dir==2)
dir = 1
else if(dir==8)
dir = 4
//src.pipe_dir = get_pipe_dir() //src.pipe_dir = get_pipe_dir()
return return
/obj/item/weapon/pipe/Move() /obj/item/pipe/Move()
var/dir = src.dir
..() ..()
src.dir = dir if ((pipe_type in list (PIPE_SIMPLE_BENT, PIPE_HE_BENT, PIPE_INSULATED_BENT)) \
&& (src.dir in cardinal))
src.dir = src.dir|turn(src.dir, 90)
else if (pipe_type in list (PIPE_SIMPLE_STRAIGHT, PIPE_HE_STRAIGHT, PIPE_INSULATED_STRAIGHT, PIPE_MVALVE))
if(dir==2)
dir = 1
else if(dir==8)
dir = 4
return return
// returns all pipe's endpoints // returns all pipe's endpoints
/obj/item/weapon/pipe/proc/get_pipe_dir() /obj/item/pipe/proc/get_pipe_dir()
if (!dir) if (!dir)
return 0 return 0
var/flip = turn(dir, 180) var/flip = turn(dir, 180)
@@ -169,7 +163,7 @@ Buildable meters
return flip|cw|acw return flip|cw|acw
return 0 return 0
/obj/item/weapon/pipe/proc/get_pdir() //endpoints for regular pipes /obj/item/pipe/proc/get_pdir() //endpoints for regular pipes
var/flip = turn(dir, 180) var/flip = turn(dir, 180)
// var/cw = turn(dir, -90) // var/cw = turn(dir, -90)
@@ -186,7 +180,7 @@ Buildable meters
// return the h_dir (heat-exchange pipes) from the type and the dir // return the h_dir (heat-exchange pipes) from the type and the dir
/obj/item/weapon/pipe/proc/get_hdir() //endpoints for h/e pipes /obj/item/pipe/proc/get_hdir() //endpoints for h/e pipes
// var/flip = turn(dir, 180) // var/flip = turn(dir, 180)
// var/cw = turn(dir, -90) // var/cw = turn(dir, -90)
@@ -201,15 +195,20 @@ Buildable meters
else else
return 0 return 0
/obj/item/weapon/pipe/attack_self(mob/user as mob) /obj/item/pipe/attack_self(mob/user as mob)
return rotate() return rotate()
/obj/item/weapon/pipe/attackby(var/obj/item/weapon/W as obj, var/mob/user as mob) /obj/item/pipe/attackby(var/obj/item/weapon/W as obj, var/mob/user as mob)
//* //*
if (!istype(W, /obj/item/weapon/wrench)) if (!istype(W, /obj/item/weapon/wrench))
return ..() return ..()
if (!isturf(src.loc)) if (!isturf(src.loc))
return 1 return 1
if (pipe_type in list (PIPE_SIMPLE_STRAIGHT, PIPE_HE_STRAIGHT, PIPE_INSULATED_STRAIGHT, PIPE_MVALVE))
if(dir==2)
dir = 1
else if(dir==8)
dir = 4
var/pipe_dir = get_pipe_dir() var/pipe_dir = get_pipe_dir()
for(var/obj/machinery/atmospherics/M in src.loc) for(var/obj/machinery/atmospherics/M in src.loc)
@@ -264,6 +263,8 @@ Buildable meters
C.initialize_directions = pipe_dir C.initialize_directions = pipe_dir
if (pipename) if (pipename)
C.name = pipename C.name = pipename
var/turf/T = C.loc
C.level = T.intact ? 2 : 1
C.initialize() C.initialize()
C.build_network() C.build_network()
if (C.node) if (C.node)
@@ -311,20 +312,15 @@ Buildable meters
if (P.node2) if (P.node2)
P.node2.initialize() P.node2.initialize()
P.node2.build_network() P.node2.build_network()
/*
if(6) //junctions
var/obj/machinery/junction/J = new( src.loc )
J.dir = dir
J.p_dir = src.get_pdir()
J.h_dir = src.get_hdir()
J.level = 2
*/
if(PIPE_UVENT) //unary vent if(PIPE_UVENT) //unary vent
var/obj/machinery/atmospherics/unary/vent_pump/V = new( src.loc ) var/obj/machinery/atmospherics/unary/vent_pump/V = new( src.loc )
V.dir = dir V.dir = dir
V.initialize_directions = pipe_dir V.initialize_directions = pipe_dir
if (pipename) if (pipename)
V.name = pipename V.name = pipename
var/turf/T = V.loc
V.level = T.intact ? 2 : 1
V.initialize() V.initialize()
V.build_network() V.build_network()
if (V.node) if (V.node)
@@ -338,6 +334,8 @@ Buildable meters
V.initialize_directions = pipe_dir V.initialize_directions = pipe_dir
if (pipename) if (pipename)
V.name = pipename V.name = pipename
var/turf/T = V.loc
V.level = T.intact ? 2 : 1
V.initialize() V.initialize()
V.build_network() V.build_network()
if (V.node1) if (V.node1)
@@ -355,6 +353,8 @@ Buildable meters
P.initialize_directions = pipe_dir P.initialize_directions = pipe_dir
if (pipename) if (pipename)
P.name = pipename P.name = pipename
var/turf/T = P.loc
P.level = T.intact ? 2 : 1
P.initialize() P.initialize()
P.build_network() P.build_network()
if (P.node1) if (P.node1)
@@ -371,6 +371,8 @@ Buildable meters
S.initialize_directions = pipe_dir S.initialize_directions = pipe_dir
if (pipename) if (pipename)
S.name = pipename S.name = pipename
var/turf/T = S.loc
S.level = T.intact ? 2 : 1
S.initialize() S.initialize()
S.build_network() S.build_network()
if (S.node) if (S.node)
@@ -397,8 +399,8 @@ Buildable meters
playsound(src.loc, 'Ratchet.ogg', 50, 1) playsound(src.loc, 'Ratchet.ogg', 50, 1)
user.visible_message( \ user.visible_message( \
"[user] fastens the pipe.", \ "[user] fastens the [src].", \
"\blue You have fastened the pipe.", \ "\blue You have fastened the [src].", \
"You hear ratchet.") "You hear ratchet.")
del(src) // remove the pipe item del(src) // remove the pipe item
@@ -409,7 +411,7 @@ Buildable meters
/obj/item/weapon/pipe_meter /obj/item/pipe_meter
name = "meter" name = "meter"
desc = "A meter that can be laid on pipes" desc = "A meter that can be laid on pipes"
icon = 'pipe-item.dmi' icon = 'pipe-item.dmi'
@@ -418,7 +420,7 @@ Buildable meters
flags = TABLEPASS|FPRINT flags = TABLEPASS|FPRINT
w_class = 4 w_class = 4
/obj/item/weapon/pipe_meter/attackby(var/obj/item/weapon/W as obj, var/mob/user as mob) /obj/item/pipe_meter/attackby(var/obj/item/weapon/W as obj, var/mob/user as mob)
if (!istype(W, /obj/item/weapon/wrench)) if (!istype(W, /obj/item/weapon/wrench))
return ..() return ..()