From a3867b46a62bbf4b538f7cee41ec295ea5edfa36 Mon Sep 17 00:00:00 2001 From: Mloc-Argent Date: Sat, 12 Oct 2013 17:24:54 +0100 Subject: [PATCH] Cleanup of pipe unwrenching code. Fixes #1509 Signed-off-by: Mloc-Argent --- code/ATMOSPHERICS/atmospherics.dm | 34 ++++++++++++++++- .../components/binary_devices/passive_gate.dm | 23 ++--------- .../components/binary_devices/pump.dm | 23 ++--------- .../components/binary_devices/volume_pump.dm | 23 ++--------- .../components/portables_connector.dm | 24 ++---------- .../components/trinary_devices/filter.dm | 28 ++------------ .../components/trinary_devices/mixer.dm | 25 +----------- .../components/unary/heat_exchanger.dm | 25 +----------- .../components/unary/vent_pump.dm | 22 ++--------- .../components/unary/vent_scrubber.dm | 22 ++--------- code/ATMOSPHERICS/components/valve.dm | 22 ++--------- code/ATMOSPHERICS/pipes.dm | 38 ++++--------------- 12 files changed, 70 insertions(+), 239 deletions(-) diff --git a/code/ATMOSPHERICS/atmospherics.dm b/code/ATMOSPHERICS/atmospherics.dm index 1b89db43be1..bcc5050bc08 100644 --- a/code/ATMOSPHERICS/atmospherics.dm +++ b/code/ATMOSPHERICS/atmospherics.dm @@ -16,6 +16,7 @@ obj/machinery/atmospherics active_power_usage = 0 power_channel = ENVIRON var/nodealert = 0 + var/can_unwrench = 0 @@ -54,4 +55,35 @@ obj/machinery/atmospherics/proc/return_network_air(datum/network/reference) obj/machinery/atmospherics/proc/disconnect(obj/machinery/atmospherics/reference) obj/machinery/atmospherics/update_icon() - return null \ No newline at end of file + return null + +obj/machinery/atmospherics/attackby(var/obj/item/weapon/W as obj, var/mob/user as mob) + if(can_unwrench && istype(W, /obj/item/weapon/wrench)) + var/turf/T = src.loc + if (level==1 && isturf(T) && T.intact) + user << "\red You must remove the plating first." + return 1 + var/datum/gas_mixture/int_air = return_air() + var/datum/gas_mixture/env_air = loc.return_air() + if ((int_air.return_pressure()-env_air.return_pressure()) > 2*ONE_ATMOSPHERE) + user << "\red You cannot unwrench this [src], it too exerted due to internal pressure." + add_fingerprint(user) + return 1 + playsound(src.loc, 'sound/items/Ratchet.ogg', 50, 1) + user << "\blue You begin to unfasten \the [src]..." + add_fingerprint(user) + if (do_after(user, 40)) + user.visible_message( \ + "[user] unfastens \the [src].", \ + "\blue You have unfastened \the [src].", \ + "You hear ratchet.") + var/obj/item/pipe/newpipe = new(loc, make_from=src) + transfer_fingerprints_to(newpipe) + if(istype(src, /obj/machinery/atmospherics/pipe)) + for(var/obj/machinery/meter/meter in T) + if(meter.target == src) + new /obj/item/pipe_meter(T) + del(meter) + del(src) + else + return ..() diff --git a/code/ATMOSPHERICS/components/binary_devices/passive_gate.dm b/code/ATMOSPHERICS/components/binary_devices/passive_gate.dm index 1185463bb7c..8944d905d7d 100644 --- a/code/ATMOSPHERICS/components/binary_devices/passive_gate.dm +++ b/code/ATMOSPHERICS/components/binary_devices/passive_gate.dm @@ -7,6 +7,8 @@ obj/machinery/atmospherics/binary/passive_gate name = "Passive gate" desc = "A one-way air valve that does not require power" + can_unwrench = 1 + var/on = 0 var/target_pressure = ONE_ATMOSPHERE @@ -166,23 +168,4 @@ obj/machinery/atmospherics/binary/passive_gate if (on) user << "\red You cannot unwrench this [src], turn it off first." return 1 - var/turf/T = src.loc - if (level==1 && isturf(T) && T.intact) - user << "\red You must remove the plating first." - return 1 - var/datum/gas_mixture/int_air = return_air() - var/datum/gas_mixture/env_air = loc.return_air() - if ((int_air.return_pressure()-env_air.return_pressure()) > 2*ONE_ATMOSPHERE) - user << "\red You cannot unwrench this [src], it too exerted due to internal pressure." - add_fingerprint(user) - return 1 - playsound(src.loc, 'sound/items/Ratchet.ogg', 50, 1) - user << "\blue You begin to unfasten \the [src]..." - if (do_after(user, 40)) - user.visible_message( \ - "[user] unfastens \the [src].", \ - "\blue You have unfastened \the [src].", \ - "You hear ratchet.") - new /obj/item/pipe(loc, make_from=src) - del(src) - + return ..() diff --git a/code/ATMOSPHERICS/components/binary_devices/pump.dm b/code/ATMOSPHERICS/components/binary_devices/pump.dm index 0fdabe08c8b..3efaa3797af 100644 --- a/code/ATMOSPHERICS/components/binary_devices/pump.dm +++ b/code/ATMOSPHERICS/components/binary_devices/pump.dm @@ -19,6 +19,8 @@ obj/machinery/atmospherics/binary/pump name = "Gas pump" desc = "A pump" + can_unwrench = 1 + var/on = 0 var/target_pressure = ONE_ATMOSPHERE @@ -178,22 +180,5 @@ obj/machinery/atmospherics/binary/pump if (!(stat & NOPOWER) && on) user << "\red You cannot unwrench this [src], turn it off first." return 1 - var/turf/T = src.loc - if (level==1 && isturf(T) && T.intact) - user << "\red You must remove the plating first." - return 1 - var/datum/gas_mixture/int_air = return_air() - var/datum/gas_mixture/env_air = loc.return_air() - if ((int_air.return_pressure()-env_air.return_pressure()) > 2*ONE_ATMOSPHERE) - user << "\red You cannot unwrench this [src], it too exerted due to internal pressure." - add_fingerprint(user) - return 1 - playsound(src.loc, 'sound/items/Ratchet.ogg', 50, 1) - user << "\blue You begin to unfasten \the [src]..." - if (do_after(user, 40)) - user.visible_message( \ - "[user] unfastens \the [src].", \ - "\blue You have unfastened \the [src].", \ - "You hear ratchet.") - new /obj/item/pipe(loc, make_from=src) - del(src) + return ..() + diff --git a/code/ATMOSPHERICS/components/binary_devices/volume_pump.dm b/code/ATMOSPHERICS/components/binary_devices/volume_pump.dm index 65a51c3dbf0..9c2f4ce795b 100644 --- a/code/ATMOSPHERICS/components/binary_devices/volume_pump.dm +++ b/code/ATMOSPHERICS/components/binary_devices/volume_pump.dm @@ -19,6 +19,8 @@ obj/machinery/atmospherics/binary/volume_pump name = "Volumetric gas pump" desc = "A volumetric pump" + can_unwrench = 1 + var/on = 0 var/transfer_rate = 200 @@ -177,23 +179,4 @@ obj/machinery/atmospherics/binary/volume_pump if (!(stat & NOPOWER) && on) user << "\red You cannot unwrench this [src], turn it off first." return 1 - var/turf/T = src.loc - if (level==1 && isturf(T) && T.intact) - user << "\red You must remove the plating first." - return 1 - var/datum/gas_mixture/int_air = return_air() - var/datum/gas_mixture/env_air = loc.return_air() - if ((int_air.return_pressure()-env_air.return_pressure()) > 2*ONE_ATMOSPHERE) - user << "\red You cannot unwrench this [src], it too exerted due to internal pressure." - add_fingerprint(user) - return 1 - playsound(src.loc, 'sound/items/Ratchet.ogg', 50, 1) - user << "\blue You begin to unfasten \the [src]..." - if (do_after(user, 40)) - user.visible_message( \ - "[user] unfastens \the [src].", \ - "\blue You have unfastened \the [src].", \ - "You hear ratchet.") - new /obj/item/pipe(loc, make_from=src) - del(src) - + return ..() diff --git a/code/ATMOSPHERICS/components/portables_connector.dm b/code/ATMOSPHERICS/components/portables_connector.dm index 5a66f687867..60a42eccf92 100644 --- a/code/ATMOSPHERICS/components/portables_connector.dm +++ b/code/ATMOSPHERICS/components/portables_connector.dm @@ -8,6 +8,8 @@ dir = SOUTH initialize_directions = SOUTH + can_unwrench = 1 + var/obj/machinery/portable_atmospherics/connected_device var/obj/machinery/atmospherics/node @@ -137,24 +139,4 @@ if (connected_device) user << "\red You cannot unwrench this [src], dettach [connected_device] first." return 1 - if (locate(/obj/machinery/portable_atmospherics, src.loc)) - return 1 - var/turf/T = src.loc - if (level==1 && isturf(T) && T.intact) - user << "\red You must remove the plating first." - return 1 - var/datum/gas_mixture/int_air = return_air() - var/datum/gas_mixture/env_air = loc.return_air() - if ((int_air.return_pressure()-env_air.return_pressure()) > 2*ONE_ATMOSPHERE) - user << "\red You cannot unwrench this [src], it too exerted due to internal pressure." - add_fingerprint(user) - return 1 - playsound(src.loc, 'sound/items/Ratchet.ogg', 50, 1) - user << "\blue You begin to unfasten \the [src]..." - if (do_after(user, 40)) - user.visible_message( \ - "[user] unfastens \the [src].", \ - "\blue You have unfastened \the [src].", \ - "You hear ratchet.") - new /obj/item/pipe(loc, make_from=src) - del(src) + return ..() \ No newline at end of file diff --git a/code/ATMOSPHERICS/components/trinary_devices/filter.dm b/code/ATMOSPHERICS/components/trinary_devices/filter.dm index a4aba30228c..d401503fb0f 100644 --- a/code/ATMOSPHERICS/components/trinary_devices/filter.dm +++ b/code/ATMOSPHERICS/components/trinary_devices/filter.dm @@ -7,6 +7,8 @@ obj/machinery/atmospherics/trinary/filter req_access = list(access_atmospherics) + can_unwrench = 1 + var/on = 0 var/temp = null // -- TLE @@ -134,31 +136,7 @@ Filter types: initialize() set_frequency(frequency) - ..() - - attackby(var/obj/item/weapon/W as obj, var/mob/user as mob) - if (!istype(W, /obj/item/weapon/wrench)) - return ..() - var/turf/T = src.loc - if (level==1 && isturf(T) && T.intact) - user << "\red You must remove the plating first." - return 1 - var/datum/gas_mixture/int_air = return_air() - var/datum/gas_mixture/env_air = loc.return_air() - if ((int_air.return_pressure()-env_air.return_pressure()) > 2*ONE_ATMOSPHERE) - user << "\red You cannot unwrench this [src], it too exerted due to internal pressure." - add_fingerprint(user) - return 1 - playsound(src.loc, 'sound/items/Ratchet.ogg', 50, 1) - user << "\blue You begin to unfasten \the [src]..." - if (do_after(user, 40)) - user.visible_message( \ - "[user] unfastens \the [src].", \ - "\blue You have unfastened \the [src].", \ - "You hear ratchet.") - new /obj/item/pipe(loc, make_from=src) - del(src) - + return ..() obj/machinery/atmospherics/trinary/filter/attack_hand(user as mob) // -- TLE if(..()) diff --git a/code/ATMOSPHERICS/components/trinary_devices/mixer.dm b/code/ATMOSPHERICS/components/trinary_devices/mixer.dm index 71688f511d0..34c5bd18a29 100644 --- a/code/ATMOSPHERICS/components/trinary_devices/mixer.dm +++ b/code/ATMOSPHERICS/components/trinary_devices/mixer.dm @@ -7,6 +7,8 @@ obj/machinery/atmospherics/trinary/mixer req_access = list(access_atmospherics) + can_unwrench = 1 + var/on = 0 var/target_pressure = ONE_ATMOSPHERE @@ -95,29 +97,6 @@ obj/machinery/atmospherics/trinary/mixer return 1 - attackby(var/obj/item/weapon/W as obj, var/mob/user as mob) - if (!istype(W, /obj/item/weapon/wrench)) - return ..() - var/turf/T = src.loc - if (level==1 && isturf(T) && T.intact) - user << "\red You must remove the plating first." - return 1 - var/datum/gas_mixture/int_air = return_air() - var/datum/gas_mixture/env_air = loc.return_air() - if ((int_air.return_pressure()-env_air.return_pressure()) > 2*ONE_ATMOSPHERE) - user << "\red You cannot unwrench this [src], it too exerted due to internal pressure." - add_fingerprint(user) - return 1 - playsound(src.loc, 'sound/items/Ratchet.ogg', 50, 1) - user << "\blue You begin to unfasten \the [src]..." - if (do_after(user, 40)) - user.visible_message( \ - "[user] unfastens \the [src].", \ - "\blue You have unfastened \the [src].", \ - "You hear ratchet.") - new /obj/item/pipe(loc, make_from=src) - del(src) - attack_hand(user as mob) if(..()) return diff --git a/code/ATMOSPHERICS/components/unary/heat_exchanger.dm b/code/ATMOSPHERICS/components/unary/heat_exchanger.dm index 7d03ad98838..a278167b830 100644 --- a/code/ATMOSPHERICS/components/unary/heat_exchanger.dm +++ b/code/ATMOSPHERICS/components/unary/heat_exchanger.dm @@ -7,6 +7,8 @@ name = "Heat Exchanger" desc = "Exchanges heat between two input gases. Setup for fast heat transfer" + can_unwrench = 1 + var/obj/machinery/atmospherics/unary/heat_exchanger/partner = null var/update_cycle @@ -64,26 +66,3 @@ partner.network.update = 1 return 1 - - attackby(var/obj/item/weapon/W as obj, var/mob/user as mob) - if (!istype(W, /obj/item/weapon/wrench)) - return ..() - var/turf/T = src.loc - if (level==1 && isturf(T) && T.intact) - user << "\red You must remove the plating first." - return 1 - var/datum/gas_mixture/int_air = return_air() - var/datum/gas_mixture/env_air = loc.return_air() - if ((int_air.return_pressure()-env_air.return_pressure()) > 2*ONE_ATMOSPHERE) - user << "\red You cannot unwrench this [src], it too exerted due to internal pressure." - add_fingerprint(user) - return 1 - playsound(src.loc, 'sound/items/Ratchet.ogg', 50, 1) - user << "\blue You begin to unfasten \the [src]..." - if (do_after(user, 40)) - user.visible_message( \ - "[user] unfastens \the [src].", \ - "\blue You have unfastened \the [src].", \ - "You hear ratchet.") - new /obj/item/pipe(loc, make_from=src) - del(src) \ No newline at end of file diff --git a/code/ATMOSPHERICS/components/unary/vent_pump.dm b/code/ATMOSPHERICS/components/unary/vent_pump.dm index bd9ce4f3304..0e94d816302 100644 --- a/code/ATMOSPHERICS/components/unary/vent_pump.dm +++ b/code/ATMOSPHERICS/components/unary/vent_pump.dm @@ -6,6 +6,8 @@ desc = "Has a valve and pump attached to it" use_power = 1 + can_unwrench = 1 + var/area/initial_loc level = 1 var/area_uid @@ -312,25 +314,7 @@ if (!(stat & NOPOWER) && on) user << "\red You cannot unwrench this [src], turn it off first." return 1 - var/turf/T = src.loc - if (level==1 && isturf(T) && T.intact) - user << "\red You must remove the plating first." - return 1 - var/datum/gas_mixture/int_air = return_air() - var/datum/gas_mixture/env_air = loc.return_air() - if ((int_air.return_pressure()-env_air.return_pressure()) > 2*ONE_ATMOSPHERE) - user << "\red You cannot unwrench this [src], it too exerted due to internal pressure." - add_fingerprint(user) - return 1 - playsound(src.loc, 'sound/items/Ratchet.ogg', 50, 1) - user << "\blue You begin to unfasten \the [src]..." - if (do_after(user, 40)) - user.visible_message( \ - "[user] unfastens \the [src].", \ - "\blue You have unfastened \the [src].", \ - "You hear ratchet.") - new /obj/item/pipe(loc, make_from=src) - del(src) + return ..() /obj/machinery/atmospherics/unary/vent_pump/Del() if(initial_loc) diff --git a/code/ATMOSPHERICS/components/unary/vent_scrubber.dm b/code/ATMOSPHERICS/components/unary/vent_scrubber.dm index 67386b9630d..26aa0c3d9ba 100644 --- a/code/ATMOSPHERICS/components/unary/vent_scrubber.dm +++ b/code/ATMOSPHERICS/components/unary/vent_scrubber.dm @@ -8,6 +8,8 @@ level = 1 + can_unwrench = 1 + var/area/initial_loc var/id_tag = null var/frequency = 1439 @@ -248,25 +250,7 @@ if (!(stat & NOPOWER) && on) user << "\red You cannot unwrench this [src], turn it off first." return 1 - var/turf/T = src.loc - if (level==1 && isturf(T) && T.intact) - user << "\red You must remove the plating first." - return 1 - var/datum/gas_mixture/int_air = return_air() - var/datum/gas_mixture/env_air = loc.return_air() - if ((int_air.return_pressure()-env_air.return_pressure()) > 2*ONE_ATMOSPHERE) - user << "\red You cannot unwrench this [src], it too exerted due to internal pressure." - add_fingerprint(user) - return 1 - playsound(src.loc, 'sound/items/Ratchet.ogg', 50, 1) - user << "\blue You begin to unfasten \the [src]..." - if (do_after(user, 40)) - user.visible_message( \ - "[user] unfastens \the [src].", \ - "\blue You have unfastened \the [src].", \ - "You hear ratchet.") - new /obj/item/pipe(loc, make_from=src) - del(src) + return ..() /obj/machinery/atmospherics/unary/vent_scrubber/Del() if(initial_loc) diff --git a/code/ATMOSPHERICS/components/valve.dm b/code/ATMOSPHERICS/components/valve.dm index 6350c955073..671edcf9914 100644 --- a/code/ATMOSPHERICS/components/valve.dm +++ b/code/ATMOSPHERICS/components/valve.dm @@ -8,6 +8,8 @@ obj/machinery/atmospherics/valve dir = SOUTH initialize_directions = SOUTH|NORTH + can_unwrench = 1 + var/open = 0 var/openDuringInit = 0 @@ -317,22 +319,4 @@ obj/machinery/atmospherics/valve if (istype(src, /obj/machinery/atmospherics/valve/digital)) user << "\red You cannot unwrench this [src], it's too complicated." return 1 - var/turf/T = src.loc - if (level==1 && isturf(T) && T.intact) - user << "\red You must remove the plating first." - return 1 - var/datum/gas_mixture/int_air = return_air() - var/datum/gas_mixture/env_air = loc.return_air() - if ((int_air.return_pressure()-env_air.return_pressure()) > 2*ONE_ATMOSPHERE) - user << "\red You cannot unwrench this [src], it too exerted due to internal pressure." - add_fingerprint(user) - return 1 - playsound(src.loc, 'sound/items/Ratchet.ogg', 50, 1) - user << "\blue You begin to unfasten \the [src]..." - if (do_after(user, 40)) - user.visible_message( \ - "[user] unfastens \the [src].", \ - "\blue You have unfastened \the [src].", \ - "You hear ratchet.") - new /obj/item/pipe(loc, make_from=src) - del(src) + return ..() \ No newline at end of file diff --git a/code/ATMOSPHERICS/pipes.dm b/code/ATMOSPHERICS/pipes.dm index 05ffb0cafac..c0d3b5af0ac 100644 --- a/code/ATMOSPHERICS/pipes.dm +++ b/code/ATMOSPHERICS/pipes.dm @@ -9,6 +9,8 @@ obj/machinery/atmospherics/pipe layer = 2.4 //under wires with their 2.44 use_power = 0 + can_unwrench = 1 + var/alert_pressure = 80*ONE_ATMOSPHERE //minimum pressure before check_pressure(...) should be called @@ -343,6 +345,8 @@ obj/machinery/atmospherics/pipe initialize_directions = SOUTH density = 1 + can_unwrench = 0 + var/obj/machinery/atmospherics/node1 New() @@ -500,6 +504,8 @@ obj/machinery/atmospherics/pipe dir = SOUTH initialize_directions = SOUTH + can_unwrench = 0 + var/build_killswitch = 1 var/obj/machinery/atmospherics/node1 @@ -805,35 +811,7 @@ obj/machinery/atmospherics/pipe icon_state = "manifold-y-f" obj/machinery/atmospherics/pipe/attackby(var/obj/item/weapon/W as obj, var/mob/user as mob) - if (istype(src, /obj/machinery/atmospherics/pipe/tank)) - return ..() - else if (istype(src, /obj/machinery/atmospherics/pipe/vent)) - return ..() - else if (istype(W, /obj/item/weapon/wrench)) - var/turf/T = src.loc - if (level==1 && isturf(T) && T.intact) - user << "\red You must remove the plating first." - return 1 - var/datum/gas_mixture/int_air = return_air() - var/datum/gas_mixture/env_air = loc.return_air() - if ((int_air.return_pressure()-env_air.return_pressure()) > 2*ONE_ATMOSPHERE) - user << "\red You cannot unwrench this [src], it too exerted due to internal pressure." - add_fingerprint(user) - return 1 - playsound(src.loc, 'sound/items/Ratchet.ogg', 50, 1) - user << "\blue You begin to unfasten \the [src]..." - if (do_after(user, 40)) - user.visible_message( \ - "[user] unfastens \the [src].", \ - "\blue You have unfastened \the [src].", \ - "You hear ratchet.") - 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) - else if (istype(W, /obj/item/device/analyzer) && get_dist(user, src) <= 1) + if (istype(W, /obj/item/device/analyzer) && get_dist(user, src) <= 1) atmosanalyzer_scan(parent.air, user) else - return ..() \ No newline at end of file + return ..()