From 9ff1be35cc7897e18138d75489d1a709c6201eed Mon Sep 17 00:00:00 2001 From: oranges Date: Wed, 17 Jan 2018 09:26:11 +1300 Subject: [PATCH 1/2] Merge pull request #34429 from AutomaticFrenzy/patch/rpd-bad-placement Fix RPD embedding fixtures inside lattices and girders --- code/game/objects/items/RPD.dm | 41 ++++++++++++++-------------------- 1 file changed, 17 insertions(+), 24 deletions(-) diff --git a/code/game/objects/items/RPD.dm b/code/game/objects/items/RPD.dm index eac887acb5..8ad78c2481 100644 --- a/code/game/objects/items/RPD.dm +++ b/code/game/objects/items/RPD.dm @@ -272,26 +272,24 @@ GLOBAL_LIST_INIT(disposal_pipe_recipes, list( if(!user.IsAdvancedToolUser() || istype(A, /turf/open/space/transit)) return ..() - var/atmos_piping_mode = mode == ATMOS_MODE || mode == METER_MODE - var/temp_piping_layer - if(atmos_piping_mode) - if(istype(A, /obj/machinery/atmospherics)) - var/obj/machinery/atmospherics/AM = A - temp_piping_layer = AM.piping_layer - A = get_turf(user) - - var/static/list/make_pipe_whitelist - if(!make_pipe_whitelist) - make_pipe_whitelist = list(/obj/structure/lattice, /obj/structure/girder, /obj/item/pipe) - - //make sure what we're clicking is valid for the current mode - var/can_make_pipe = (atmos_piping_mode || mode == DISPOSALS_MODE) && (isturf(A) || is_type_in_list(A, make_pipe_whitelist)) - //So that changing the menu settings doesn't affect the pipes already being built. + var/temp_piping_layer = piping_layer var/queued_p_type = recipe.id var/queued_p_dir = p_dir var/queued_p_flipped = p_flipped + // clicking on an existing component puts the new one on the same layer + if ((mode == ATMOS_MODE || mode == METER_MODE) && istype(A, /obj/machinery/atmospherics)) + var/obj/machinery/atmospherics/AM = A + temp_piping_layer = AM.piping_layer + A = get_turf(user) + + //make sure what we're clicking is valid for the current mode + var/static/list/make_pipe_whitelist + if(!make_pipe_whitelist) + make_pipe_whitelist = typecacheof(list(/obj/structure/lattice, /obj/structure/girder, /obj/item/pipe)) + var/can_make_pipe = (isturf(A) || is_type_in_typecache(A, make_pipe_whitelist)) + . = FALSE switch(mode) //if we've gotten this var, the target is valid if(PAINT_MODE) //Paint pipes @@ -323,7 +321,7 @@ GLOBAL_LIST_INIT(disposal_pipe_recipes, list( var/obj/machinery/atmospherics/path = queued_p_type var/pipe_item_type = initial(path.construction_type) || /obj/item/pipe - var/obj/item/pipe/P = new pipe_item_type(A, queued_p_type, queued_p_dir) + var/obj/item/pipe/P = new pipe_item_type(get_turf(A), queued_p_type, queued_p_dir) if(queued_p_flipped && istype(P, /obj/item/pipe/trinary/flippable)) var/obj/item/pipe/trinary/flippable/F = P @@ -331,10 +329,7 @@ GLOBAL_LIST_INIT(disposal_pipe_recipes, list( P.update() P.add_fingerprint(usr) - if(!isnull(temp_piping_layer)) - P.setPipingLayer(temp_piping_layer) - else - P.setPipingLayer(piping_layer) + P.setPipingLayer(temp_piping_layer) P.add_atom_colour(GLOB.pipe_paint_colors[paint_color], FIXED_COLOUR_PRIORITY) if(METER_MODE) //Making pipe meters @@ -345,14 +340,12 @@ GLOBAL_LIST_INIT(disposal_pipe_recipes, list( if(do_after(user, 2, target = A)) activate() var/obj/item/pipe_meter/PM = new /obj/item/pipe_meter(get_turf(A)) - if(!isnull(temp_piping_layer)) - PM.setAttachLayer(temp_piping_layer) - else - PM.setAttachLayer(piping_layer) + PM.setAttachLayer(temp_piping_layer) if(DISPOSALS_MODE) //Making disposals pipes if(!can_make_pipe) return ..() + A = get_turf(A) if(isclosedturf(A)) to_chat(user, "[src]'s error light flickers; there's something in the way!") return