From d3585beb8b68ddb5a96b3bac0bb88b5b8d1352cb Mon Sep 17 00:00:00 2001 From: Citinited Date: Tue, 7 May 2019 21:59:43 +0100 Subject: [PATCH] Code cleanup, runtime fixing --- code/ATMOSPHERICS/datum_pipeline.dm | 8 +- .../airlock_controllers.dm | 2 +- .../effects/spawners/airlock_spawner.dm | 79 +++++++++---------- 3 files changed, 39 insertions(+), 50 deletions(-) diff --git a/code/ATMOSPHERICS/datum_pipeline.dm b/code/ATMOSPHERICS/datum_pipeline.dm index 11ce632d917..43082c38ded 100644 --- a/code/ATMOSPHERICS/datum_pipeline.dm +++ b/code/ATMOSPHERICS/datum_pipeline.dm @@ -100,8 +100,6 @@ var/pipenetwarnings = 10 addMachineryMember(A) /datum/pipeline/proc/merge(datum/pipeline/E) - if(!E) //Uh oh - return air.volume += E.air.volume members.Add(E.members) for(var/obj/machinery/atmospherics/pipe/S in E.members) @@ -117,12 +115,10 @@ var/pipenetwarnings = 10 /obj/machinery/atmospherics/proc/addMember(obj/machinery/atmospherics/A) var/datum/pipeline/P = returnPipenet(A) - if(P) //Sanity checking - P.addMember(A, src) + P.addMember(A, src) /obj/machinery/atmospherics/pipe/addMember(obj/machinery/atmospherics/A) - if(parent && A) //Sanity checking - parent.addMember(A, src) + parent.addMember(A, src) /datum/pipeline/proc/temporarily_store_air() //Update individual gas_mixtures by volume ratio diff --git a/code/game/machinery/embedded_controller/airlock_controllers.dm b/code/game/machinery/embedded_controller/airlock_controllers.dm index 2580eaf760b..b1a6f96e2eb 100644 --- a/code/game/machinery/embedded_controller/airlock_controllers.dm +++ b/code/game/machinery/embedded_controller/airlock_controllers.dm @@ -76,7 +76,7 @@ name = "Airlock Controller" tag_secure = 1 -/obj/machinery/embedded_controller/radio/airlock/airlock_controller/New(loc, given_id_tag, given_frequency, given_tag_exterior_door, given_tag_interior_door, given_tag_airpump, given_tag_chamber_sensor) +/obj/machinery/embedded_controller/radio/airlock/airlock_controller/Initialize(mapload, given_id_tag, given_frequency, given_tag_exterior_door, given_tag_interior_door, given_tag_airpump, given_tag_chamber_sensor) if(given_id_tag) id_tag = given_id_tag if(given_frequency) diff --git a/code/game/objects/effects/spawners/airlock_spawner.dm b/code/game/objects/effects/spawners/airlock_spawner.dm index 90156c2926d..496f02c61d1 100644 --- a/code/game/objects/effects/spawners/airlock_spawner.dm +++ b/code/game/objects/effects/spawners/airlock_spawner.dm @@ -54,8 +54,8 @@ This spawner places pipe leading up to the interior door, you will need to finis var/turf/turf_exterior = get_airlock_location(exterior_direction) handle_door_creation(turf_interior, TRUE, one_door_interior) handle_door_creation(turf_exterior, FALSE, one_door_exterior) + handle_pipes_creation(turf_interior) handle_control_placement() - handle_pipes_n_shit(turf_interior) qdel(src) /obj/effect/spawner/airlock/proc/get_airlock_location(desired_direction) //Finds a turf to place an airlock and returns it, this turf will be in the middle of the relevant wall @@ -143,13 +143,10 @@ This spawner places pipe leading up to the interior door, you will need to finis AS.pixel_x += 25 AS.pixel_y -= 9 -/obj/effect/spawner/airlock/proc/handle_pipes_n_shit(turf/T) //This places all required piping down, then properly initializes it. T is the turf that the interior airlock occupies - var/list/initialize_these_pipes = list() //All the pipes and stuff that needs to be initialized properly. We'll use a list for neater code +/obj/effect/spawner/airlock/proc/handle_pipes_creation(turf/T) //This places all required piping down, then properly initializes it. T is the turf that the interior airlock occupies var/turf/below_T = get_step(T, opposite_interior_direction) - var/obj/machinery/atmospherics/pipe/manifold/visible/M - var/obj/machinery/atmospherics/pipe/manifold4w/visible/M4W - var/obj/machinery/atmospherics/unary/vent_pump/high_volume/VP + var/two_way_pipe = interior_direction | opposite_interior_direction var/chamber_shape //This determines the layout of the chamber and therefore how many vents should be present if(tiles_in_x_direction == 2 && tiles_in_y_direction == 2) chamber_shape = CHAMBER_SQUARE @@ -157,54 +154,50 @@ This spawner places pipe leading up to the interior door, you will need to finis chamber_shape = CHAMBER_BIGGER else chamber_shape = CHAMBER_LONG - + pipe_creation_helper(/obj/machinery/atmospherics/pipe/simple/visible, T, interior_direction, two_way_pipe) switch(chamber_shape) if(CHAMBER_LONG) //Easy enough, place a single vent - VP = new(below_T) - VP.dir = interior_direction - initialize_these_pipes.Add(VP) + pipe_creation_helper(/obj/machinery/atmospherics/unary/vent_pump/high_volume, + below_T, + interior_direction) if(CHAMBER_SQUARE) //We need a T-manifold and two vents for this - M = new(below_T) - initialize_these_pipes.Add(M) - VP = new(get_step(below_T, opposite_interior_direction)) - VP.dir = interior_direction - initialize_these_pipes.Add(VP) - VP = new(north_or_south_interior ? EAST_OF_TURF(below_T) : NORTH_OF_TURF(below_T)) - VP.dir = turn(interior_direction, interior_direction == SOUTH || interior_direction == EAST ? -90 : 90) - initialize_these_pipes.Add(VP) + pipe_creation_helper(/obj/machinery/atmospherics/pipe/manifold/visible, + below_T, + north_or_south_interior ? WEST : SOUTH, + NORTH | EAST | (north_or_south_interior ? SOUTH : WEST)) + pipe_creation_helper(/obj/machinery/atmospherics/unary/vent_pump/high_volume, + get_step(below_T, opposite_interior_direction), + interior_direction) + pipe_creation_helper(/obj/machinery/atmospherics/unary/vent_pump/high_volume, + north_or_south_interior ? EAST_OF_TURF(below_T) : NORTH_OF_TURF(below_T), + turn(interior_direction, interior_direction == SOUTH || interior_direction == EAST ? -90 : 90)) if(CHAMBER_BIGGER) //We need a central column of manifolds and a vent either side of each manifold var/depth = north_or_south_interior ? tiles_in_y_direction : tiles_in_x_direction var/turf/put_thing_here = below_T for(var/i in 1 to depth) if(i != depth)//We're placing more pipe later, so we need a 4-way manifold - M4W = new(put_thing_here) - initialize_these_pipes.Add(M4W) + pipe_creation_helper(/obj/machinery/atmospherics/pipe/manifold4w/visible, put_thing_here, interior_direction, NORTH | EAST | SOUTH | WEST) else //We stop here, so place a T-manifold down - M = new(put_thing_here) - M.on_construction(opposite_interior_direction, interior_direction_cw | interior_direction | interior_direction_ccw, null) - VP = new(get_step(put_thing_here, interior_direction_cw)) - VP.dir = interior_direction_ccw - initialize_these_pipes.Add(VP) - VP = new(get_step(put_thing_here, interior_direction_ccw)) - VP.dir = interior_direction_cw - initialize_these_pipes.Add(VP) + pipe_creation_helper(/obj/machinery/atmospherics/pipe/manifold/visible, + put_thing_here, + opposite_interior_direction, + interior_direction_cw | interior_direction | interior_direction_ccw) + pipe_creation_helper(/obj/machinery/atmospherics/unary/vent_pump/high_volume, + get_step(put_thing_here, interior_direction_cw), + interior_direction_ccw) + pipe_creation_helper(/obj/machinery/atmospherics/unary/vent_pump/high_volume, + get_step(put_thing_here, interior_direction_ccw), + interior_direction_cw) put_thing_here = get_step(put_thing_here, opposite_interior_direction) //Now move the turf we're generating stuff from 1 forward - var/obj/machinery/atmospherics/pipe/simple/visible/P = new(T) - initialize_these_pipes.Add(P) - - var/two_way_pipe = interior_direction | opposite_interior_direction - - for(var/obj/machinery/atmospherics/pipe/simple/visible/HS in initialize_these_pipes) - HS.on_construction(interior_direction, two_way_pipe, null) - for(var/obj/machinery/atmospherics/pipe/manifold4w/visible/HM4W in initialize_these_pipes) - HM4W.on_construction(interior_direction, NORTH | SOUTH | EAST | WEST, null) - for(var/obj/machinery/atmospherics/pipe/manifold/visible/HM in initialize_these_pipes) - HM.on_construction(north_or_south_interior ? WEST : SOUTH, NORTH | EAST | (north_or_south_interior ? SOUTH : WEST), null) - for(var/obj/machinery/atmospherics/unary/vent_pump/high_volume/HVP in initialize_these_pipes) - HVP.on_construction(HVP.dir, HVP.dir, null) - HVP.id_tag = AIRPUMP_TAG - HVP.set_frequency(radio_frequency) +/obj/effect/spawner/airlock/proc/pipe_creation_helper(path, location, direction, initialization_directions) //Create some kind of atmospherics machinery and initialize it properly + var/obj/machinery/atmospherics/A = new path(location) + A.dir = direction + A.on_construction(A.dir, initialization_directions ? initialization_directions : A.dir) + if(istype(A, /obj/machinery/atmospherics/unary/vent_pump/high_volume)) + var/obj/machinery/atmospherics/unary/vent_pump/high_volume/created_pump = A + created_pump.id_tag = AIRPUMP_TAG + created_pump.set_frequency(radio_frequency) //Premade airlocks for mappers, probably won't need all of these but whatever