Skip to content

Commit

Permalink
Fix pipes going invisible and not re-connecting when re-anchored
Browse files Browse the repository at this point in the history
  • Loading branch information
Drulikar committed Nov 24, 2024
1 parent cf5ce2c commit ea1e01d
Show file tree
Hide file tree
Showing 2 changed files with 107 additions and 152 deletions.
258 changes: 107 additions & 151 deletions code/game/machinery/pipe/construction.dm
Original file line number Diff line number Diff line change
Expand Up @@ -271,8 +271,17 @@ Buildable meters
else
return ..()

// rotate the pipe item clockwise
/obj/item/pipe/pickup(mob/user, silent)
var/old_dir = dir
..()
setDir(old_dir) // Retain old dir since these rotate in hand

/obj/item/pipe/equipped(mob/user, slot, silent)
var/old_dir = dir
..()
setDir(old_dir) // Retain old dir since these rotate in hand

// rotate the pipe item clockwise
/obj/item/pipe/verb/rotate()
set category = "Object"
set name = "Rotate Pipe"
Expand Down Expand Up @@ -384,241 +393,188 @@ Buildable meters
rotate()

/obj/item/pipe/attackby(obj/item/W, mob/user)
..()
//*
if (!HAS_TRAIT(W, TRAIT_TOOL_WRENCH))
return ..()
if (!isturf(loc))
return 1
var/turf/T = loc
var/pipelevel = T.intact_tile ? 2 : 1

if (pipe_type in list (PIPE_SIMPLE_STRAIGHT, PIPE_SUPPLY_STRAIGHT, PIPE_SCRUBBERS_STRAIGHT, PIPE_HE_STRAIGHT, PIPE_INSULATED_STRAIGHT, PIPE_MVALVE))
if(dir==2)
. = ..()
if(!HAS_TRAIT(W, TRAIT_TOOL_WRENCH))
return .
if(!isturf(loc))
return TRUE
var/turf/turf = loc
var/pipelevel = turf.intact_tile ? 2 : 1

if(pipe_type in list (PIPE_SIMPLE_STRAIGHT, PIPE_SUPPLY_STRAIGHT, PIPE_SCRUBBERS_STRAIGHT, PIPE_HE_STRAIGHT, PIPE_INSULATED_STRAIGHT, PIPE_MVALVE))
if(dir == SOUTH)
setDir(NORTH)
else if(dir==8)
else if(dir == WEST)
setDir(EAST)
else if (pipe_type in list(PIPE_MANIFOLD4W, PIPE_SUPPLY_MANIFOLD4W, PIPE_SCRUBBERS_MANIFOLD4W, PIPE_OMNI_MIXER, PIPE_OMNI_FILTER))
else if(pipe_type in list(PIPE_MANIFOLD4W, PIPE_SUPPLY_MANIFOLD4W, PIPE_SCRUBBERS_MANIFOLD4W, PIPE_OMNI_MIXER, PIPE_OMNI_FILTER))
setDir(SOUTH)
var/pipe_dir = get_pipe_dir()

for(var/obj/structure/pipes/M in src.loc)
if((M.valid_directions & pipe_dir)) // matches at least one direction on either type of pipe & same connection type
for(var/obj/structure/pipes/existing_pipe in loc)
if((existing_pipe.valid_directions & pipe_dir)) // matches at least one direction on either type of pipe & same connection type
to_chat(user, SPAN_WARNING("There is already a pipe of the same type at this location."))
return 1
return TRUE
// no conflicts found

//TODO: Move all of this stuff into the various pipe constructors.
var/obj/structure/pipes/new_pipe
switch(pipe_type)
if(PIPE_SIMPLE_STRAIGHT, PIPE_SIMPLE_BENT)
var/obj/structure/pipes/standard/simple/P = new( src.loc )
P.pipe_color = color
P.setDir(dir)
P.valid_directions = list(pipe_dir)
P.level = pipelevel
new_pipe = new /obj/structure/pipes/standard/simple(loc)
new_pipe.pipe_color = color
new_pipe.level = pipelevel

if(PIPE_SUPPLY_STRAIGHT, PIPE_SUPPLY_BENT)
var/obj/structure/pipes/standard/simple/hidden/supply/P = new( src.loc )
P.color = color
P.setDir(dir)
P.valid_directions = list(pipe_dir)
P.level = pipelevel
new_pipe = new /obj/structure/pipes/standard/simple/hidden/supply(loc)
new_pipe.color = color
new_pipe.level = pipelevel

if(PIPE_SCRUBBERS_STRAIGHT, PIPE_SCRUBBERS_BENT)
var/obj/structure/pipes/standard/simple/hidden/scrubbers/P = new( src.loc )
P.color = color
P.setDir(dir)
P.valid_directions = list(pipe_dir)
P.level = pipelevel
new_pipe = new /obj/structure/pipes/standard/simple/hidden/scrubbers(loc)
new_pipe.color = color
new_pipe.level = pipelevel

if(PIPE_UNIVERSAL)
var/obj/structure/pipes/standard/simple/hidden/universal/P = new( src.loc )
P.color = color
P.setDir(dir)
P.valid_directions = list(pipe_dir)
P.level = pipelevel
new_pipe = new /obj/structure/pipes/standard/simple/hidden/universal(loc)
new_pipe.color = color
new_pipe.level = pipelevel

if(PIPE_CONNECTOR) // connector
var/obj/structure/pipes/portables_connector/C = new( src.loc )
C.setDir(dir)
C.valid_directions = list(pipe_dir)
new_pipe = new /obj/structure/pipes/portables_connector(loc)
if (pipename)
C.name = pipename
C.level = pipelevel
new_pipe.name = pipename
new_pipe.level = pipelevel

if(PIPE_MANIFOLD) //manifold
var/obj/structure/pipes/standard/manifold/M = new( src.loc )
M.pipe_color = color
M.setDir(dir)
M.valid_directions = list(pipe_dir)
M.level = pipelevel
new_pipe = new /obj/structure/pipes/standard/manifold(loc)
new_pipe.pipe_color = color
new_pipe.level = pipelevel

if(PIPE_SUPPLY_MANIFOLD) //manifold
var/obj/structure/pipes/standard/manifold/hidden/supply/M = new( src.loc )
M.color = color
M.setDir(dir)
M.valid_directions = list(pipe_dir)
M.level = pipelevel
new_pipe = new /obj/structure/pipes/standard/manifold/hidden/supply(loc)
new_pipe.color = color
new_pipe.level = pipelevel

if(PIPE_SCRUBBERS_MANIFOLD) //manifold
var/obj/structure/pipes/standard/manifold/hidden/scrubbers/M = new( src.loc )
M.color = color
M.setDir(dir)
M.valid_directions = list(pipe_dir)
M.level = pipelevel
new_pipe = new /obj/structure/pipes/standard/manifold/hidden/scrubbers(loc)
new_pipe.color = color
new_pipe.level = pipelevel

if(PIPE_MANIFOLD4W) //4-way manifold
var/obj/structure/pipes/standard/manifold/fourway/M = new( src.loc )
M.pipe_color = color
M.setDir(dir)
M.valid_directions = list(pipe_dir)
M.level = pipelevel
new_pipe = new /obj/structure/pipes/standard/manifold/fourway(loc)
new_pipe.pipe_color = color
new_pipe.level = pipelevel

if(PIPE_SUPPLY_MANIFOLD4W) //4-way manifold
var/obj/structure/pipes/standard/manifold/fourway/hidden/supply/M = new( src.loc )
M.color = color
M.setDir(dir)
M.valid_directions = list(pipe_dir)
M.level = pipelevel
new_pipe = new /obj/structure/pipes/standard/manifold/fourway/hidden/supply(loc)
new_pipe.color = color
new_pipe.level = pipelevel

if(PIPE_SCRUBBERS_MANIFOLD4W) //4-way manifold
var/obj/structure/pipes/standard/manifold/fourway/hidden/scrubbers/M = new( src.loc )
M.color = color
M.setDir(dir)
M.valid_directions = list(pipe_dir)
M.level = pipelevel
new_pipe = new /obj/structure/pipes/standard/manifold/fourway/hidden/scrubbers(loc)
new_pipe.color = color
new_pipe.level = pipelevel

if(PIPE_UVENT) //unary vent
var/obj/structure/pipes/vents/pump/V = new( src.loc )
V.setDir(dir)
V.valid_directions = list(pipe_dir)
new_pipe = new /obj/structure/pipes/vents/pump(loc)
if(pipename)
V.name = pipename
V.level = pipelevel
new_pipe.name = pipename
new_pipe.level = pipelevel

if(PIPE_MVALVE) //manual valve
var/obj/structure/pipes/valve/V = new( src.loc)
V.setDir(dir)
V.valid_directions = list(pipe_dir)
new_pipe = new /obj/structure/pipes/valve(loc)
if (pipename)
V.name = pipename
V.level = pipelevel
new_pipe.name = pipename
new_pipe.level = pipelevel

if(PIPE_PUMP) //gas pump
var/obj/structure/pipes/binary/pump/P = new(src.loc)
P.setDir(dir)
P.valid_directions = list(pipe_dir)
new_pipe = new /obj/structure/pipes/binary/pump(loc)
if (pipename)
P.name = pipename
P.level = pipelevel
new_pipe.name = pipename
new_pipe.level = pipelevel

if(PIPE_GAS_FILTER) //gas filter
var/obj/structure/pipes/trinary/filter/P = new(src.loc)
P.setDir(dir)
P.valid_directions = list(pipe_dir)
new_pipe = new /obj/structure/pipes/trinary/filter(loc)
if (pipename)
P.name = pipename
P.level = pipelevel
new_pipe.name = pipename
new_pipe.level = pipelevel

if(PIPE_GAS_MIXER) //gas mixer
var/obj/structure/pipes/trinary/mixer/P = new(src.loc)
P.setDir(dir)
P.valid_directions = list(pipe_dir)
new_pipe = new /obj/structure/pipes/trinary/mixer(loc)
if (pipename)
P.name = pipename
P.level = pipelevel
new_pipe.name = pipename
new_pipe.level = pipelevel

if(PIPE_GAS_FILTER_M) //gas filter mirrored
var/obj/structure/pipes/trinary/filter/m_filter/P = new(src.loc)
P.setDir(dir)
P.valid_directions = list(pipe_dir)
new_pipe = new /obj/structure/pipes/trinary/filter/m_filter(loc)
if (pipename)
P.name = pipename
P.level = pipelevel
new_pipe.name = pipename
new_pipe.level = pipelevel

if(PIPE_GAS_MIXER_T) //gas mixer-t
var/obj/structure/pipes/trinary/mixer/t_mixer/P = new(src.loc)
P.setDir(dir)
P.valid_directions = list(pipe_dir)
new_pipe = new /obj/structure/pipes/trinary/mixer/t_mixer(loc)
if (pipename)
P.name = pipename
P.level = pipelevel
new_pipe.name = pipename
new_pipe.level = pipelevel

if(PIPE_GAS_MIXER_M) //gas mixer mirrored
var/obj/structure/pipes/trinary/mixer/m_mixer/P = new(src.loc)
P.setDir(dir)
P.valid_directions = list(pipe_dir)
new_pipe = new /obj/structure/pipes/trinary/mixer/m_mixer(loc)
if(pipename)
P.name = pipename
P.level = pipelevel
new_pipe.name = pipename
new_pipe.level = pipelevel

if(PIPE_SCRUBBER) //scrubber
var/obj/structure/pipes/vents/scrubber/S = new(src.loc)
S.setDir(dir)
S.valid_directions = list(pipe_dir)
new_pipe = new /obj/structure/pipes/vents/scrubber(loc)
if (pipename)
S.name = pipename
S.level = pipelevel
new_pipe.name = pipename
new_pipe.level = pipelevel

if(PIPE_INSULATED_STRAIGHT, PIPE_INSULATED_BENT)
var/obj/structure/pipes/standard/simple/insulated/P = new( src.loc )
P.setDir(dir)
P.valid_directions = list(pipe_dir)
P.level = pipelevel
new_pipe = new /obj/structure/pipes/standard/simple/insulated(loc)
new_pipe.level = pipelevel


if(PIPE_MTVALVE) //manual t-valve
var/obj/structure/pipes/tvalve/V = new(src.loc)
V.setDir(dir)
V.valid_directions = list(pipe_dir)
new_pipe = new /obj/structure/pipes/tvalve(loc)
if (pipename)
V.name = pipename
V.level = pipelevel
new_pipe.name = pipename
new_pipe.level = pipelevel


if(PIPE_CAP)
var/obj/structure/pipes/standard/cap/C = new(src.loc)
C.setDir(dir)
C.valid_directions = list(pipe_dir)
new_pipe = new /obj/structure/pipes/standard/cap(loc)

if(PIPE_SUPPLY_CAP)
var/obj/structure/pipes/standard/cap/hidden/supply/C = new(src.loc)
C.setDir(dir)
C.valid_directions = list(pipe_dir)
new_pipe = new /obj/structure/pipes/standard/cap/hidden/supply(loc)

if(PIPE_SCRUBBERS_CAP)
var/obj/structure/pipes/standard/cap/hidden/scrubbers/C = new(src.loc)
C.setDir(dir)
C.valid_directions = list(pipe_dir)
new_pipe = new /obj/structure/pipes/standard/cap/hidden/scrubbers(loc)

if(PIPE_PASSIVE_GATE) //passive gate
var/obj/structure/pipes/binary/passive_gate/P = new(src.loc)
P.setDir(dir)
P.valid_directions = list(pipe_dir)
new_pipe = new /obj/structure/pipes/binary/passive_gate(loc)
if (pipename)
P.name = pipename
P.level = pipelevel
new_pipe.name = pipename
new_pipe.level = pipelevel


if(PIPE_VOLUME_PUMP) //volume pump
var/obj/structure/pipes/binary/pump/high_power/P = new(src.loc)
P.setDir(dir)
P.valid_directions = list(pipe_dir)
new_pipe = new /obj/structure/pipes/binary/pump/high_power(loc)
if (pipename)
P.name = pipename
P.level = pipelevel
new_pipe.name = pipename
new_pipe.level = pipelevel


if(PIPE_HEAT_EXCHANGE) // heat exchanger
var/obj/structure/pipes/unary/heat_exchanger/C = new( src.loc )
C.setDir(dir)
C.valid_directions = list(pipe_dir)
new_pipe = new /obj/structure/pipes/unary/heat_exchanger(loc)
if (pipename)
C.name = pipename
C.level = pipelevel
new_pipe.name = pipename
new_pipe.level = pipelevel

new_pipe.setDir(dir)
new_pipe.create_valid_directions()
new_pipe.search_for_connections()

playsound(src.loc, 'sound/items/Ratchet.ogg', 25, 1)
playsound(loc, 'sound/items/Ratchet.ogg', 25, 1)
user.visible_message( \
"[user] fastens [src].", \
SPAN_NOTICE("You have fastened [src]."), \
Expand Down
1 change: 0 additions & 1 deletion code/game/objects/structures/pipes/pipes.dm
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@

if(mapload)
create_valid_directions()

search_for_connections()

if(!is_mainship_level(z))
Expand Down

0 comments on commit ea1e01d

Please sign in to comment.