From 0d691189aa85f3d96a9c1207127d2711aa4dfad4 Mon Sep 17 00:00:00 2001 From: ACCount Date: Tue, 7 Nov 2017 23:25:16 +0300 Subject: [PATCH 1/2] Multiple fixes in RPD and pipe construciton (#32399) * Multiple fixes in RPD and pipe construciton * Integrates another fix PR to avoid conflicts --- code/controllers/subsystem/air.dm | 13 +++++++++++++ code/game/machinery/pipe/construction.dm | 19 +++---------------- code/game/objects/items/RPD.dm | 10 +++++++++- 3 files changed, 25 insertions(+), 17 deletions(-) diff --git a/code/controllers/subsystem/air.dm b/code/controllers/subsystem/air.dm index 90690c934a..fe1d4916c7 100644 --- a/code/controllers/subsystem/air.dm +++ b/code/controllers/subsystem/air.dm @@ -377,6 +377,19 @@ SUBSYSTEM_DEF(air) AM.build_network() CHECK_TICK +/datum/controller/subsystem/air/proc/get_pipe_cache(type, direction=NORTH) + if(!pipe_construction_generation_cache[type]) + pipe_construction_generation_cache[type] = list() + + if(!pipe_construction_generation_cache[type]["[direction]"]) + var/obj/machinery/atmospherics/cached = new type(null, FALSE, direction) + pipe_construction_generation_cache[type]["[direction]"] = cached + STOP_PROCESSING(SSmachines, cached) + STOP_PROCESSING(SSfastprocess, cached) + GLOB.machines -= cached + + return pipe_construction_generation_cache[type]["[direction]"] + #undef SSAIR_PIPENETS #undef SSAIR_ATMOSMACHINERY diff --git a/code/game/machinery/pipe/construction.dm b/code/game/machinery/pipe/construction.dm index eb79ab72f3..8d6658c372 100644 --- a/code/game/machinery/pipe/construction.dm +++ b/code/game/machinery/pipe/construction.dm @@ -69,7 +69,7 @@ Buildable meters return ..() /obj/item/pipe/proc/setPipingLayer(new_layer = PIPING_LAYER_DEFAULT) - var/obj/machinery/atmospherics/fakeA = get_pipe_cache(pipe_type) + var/obj/machinery/atmospherics/fakeA = SSair.get_pipe_cache(pipe_type) if(fakeA.pipe_flags & PIPING_ALL_LAYER) new_layer = PIPING_LAYER_DEFAULT @@ -80,7 +80,7 @@ Buildable meters layer = initial(layer) + ((piping_layer - PIPING_LAYER_DEFAULT) * PIPING_LAYER_LCHANGE) /obj/item/pipe/proc/update() - var/obj/machinery/atmospherics/A = get_pipe_cache(pipe_type) + var/obj/machinery/atmospherics/A = SSair.get_pipe_cache(pipe_type) name = "[A.name] fitting" icon_state = A.pipe_state @@ -147,19 +147,6 @@ Buildable meters /obj/item/pipe/attack_self(mob/user) return rotate() -/obj/item/pipe/proc/get_pipe_cache(type, direction) - var/list/obj/machinery/atmospherics/check_cache = SSair.pipe_construction_generation_cache - if(!islist(check_cache)) - check_cache = list() - if(!check_cache[type]) - check_cache[type] = list() - if(!check_cache[type]["[direction]"]) - var/obj/machinery/atmospherics/A = new type(null, FALSE, direction) - A.name = "\[CACHE\] [A.name]" - check_cache[type]["[direction]"] = A - - return check_cache[type]["[direction]"] - /obj/item/pipe/attackby(obj/item/W, mob/user, params) if (!istype(W, /obj/item/wrench)) return ..() @@ -169,7 +156,7 @@ Buildable meters fixdir() - var/obj/machinery/atmospherics/fakeA = get_pipe_cache(pipe_type, dir) + var/obj/machinery/atmospherics/fakeA = SSair.get_pipe_cache(pipe_type, dir) for(var/obj/machinery/atmospherics/M in loc) if((M.pipe_flags & fakeA.pipe_flags & PIPING_ONE_PER_TURF)) //Only one dense/requires density object per tile, eg connectors/cryo/heater/coolers. diff --git a/code/game/objects/items/RPD.dm b/code/game/objects/items/RPD.dm index e1f10b81d2..9b9f7e6000 100644 --- a/code/game/objects/items/RPD.dm +++ b/code/game/objects/items/RPD.dm @@ -579,10 +579,18 @@ GLOBAL_LIST_INIT(RPD_recipes, list( playsound(get_turf(src), 'sound/machines/click.ogg', 50, 1) if(do_after(user, 2, target = A)) activate() - var/obj/item/pipe/P = new(get_turf(A), queued_p_type, queued_p_dir) + + var/pipe_item_type = /obj/item/pipe + var/obj/machinery/atmospherics/cached_pipe = SSair.get_pipe_cache(queued_p_type) + if(istype(cached_pipe) && cached_pipe.construction_type) + pipe_item_type = cached_pipe.construction_type + + var/obj/item/pipe/P = new pipe_item_type(A, queued_p_type, queued_p_dir) + if(queued_p_flipped) var/obj/item/pipe/trinary/flippable/F = P F.flipped = queued_p_flipped + P.update() P.add_fingerprint(usr) if(!isnull(temp_piping_layer))