From 4cf3fb392f32cce01b4135c0d6c92b121030a448 Mon Sep 17 00:00:00 2001 From: Camper12345 Date: Wed, 5 Apr 2017 15:43:24 +0400 Subject: [PATCH 1/6] Disposals fix - Sorting junctions may now have list of indexes in sortType - Refactoring --- code/game/machinery/pipe/pipe_dispenser.dm | 36 +- .../recycling/disposal-construction.dm | 446 ++++----- code/modules/recycling/disposal.dm | 886 +++++++++--------- code/modules/recycling/sortingmachinery.dm | 2 +- 4 files changed, 694 insertions(+), 676 deletions(-) diff --git a/code/game/machinery/pipe/pipe_dispenser.dm b/code/game/machinery/pipe/pipe_dispenser.dm index c8188cddd0c..470b172bb7d 100644 --- a/code/game/machinery/pipe/pipe_dispenser.dm +++ b/code/game/machinery/pipe/pipe_dispenser.dm @@ -207,42 +207,42 @@ Nah var/obj/structure/disposalconstruct/C = new (src.loc) switch(p_type) if(0) - C.ptype = 0 + C.pipe_type = 0 if(1) - C.ptype = 1 + C.pipe_type = 1 if(2) - C.ptype = 2 + C.pipe_type = 2 if(3) - C.ptype = 4 + C.pipe_type = 4 if(4) - C.ptype = 5 + C.pipe_type = 5 if(5) - C.ptype = 6 + C.pipe_type = 6 C.density = 1 if(6) - C.ptype = 7 + C.pipe_type = 7 C.density = 1 if(7) - C.ptype = 8 + C.pipe_type = 8 C.density = 1 if(8) - C.ptype = 9 - C.subtype = 0 + C.pipe_type = 9 + C.sort_type = 0 if(9) - C.ptype = 9 - C.subtype = 1 + C.pipe_type = 9 + C.sort_type = 1 if(10) - C.ptype = 9 - C.subtype = 2 + C.pipe_type = 9 + C.sort_type = 2 if(11) - C.ptype = 13 + C.pipe_type = 13 if(12) - C.ptype = 14 + C.pipe_type = 14 ///// Z-Level stuff if(21) - C.ptype = 11 + C.pipe_type = 11 if(22) - C.ptype = 12 + C.pipe_type = 12 ///// Z-Level stuff C.add_fingerprint(usr) C.update() diff --git a/code/modules/recycling/disposal-construction.dm b/code/modules/recycling/disposal-construction.dm index c5277920898..e766f59e8e2 100644 --- a/code/modules/recycling/disposal-construction.dm +++ b/code/modules/recycling/disposal-construction.dm @@ -1,6 +1,26 @@ // Disposal pipe construction // This is the pipe that you drag around, not the attached ones. +#define PIPE_TYPE_STRAIGHT 0 +#define PIPE_TYPE_BENT 1 +#define PIPE_TYPE_JUNC 2 +#define PIPE_TYPE_JUNC_FLIP 3 +#define PIPE_TYPE_JUNC_Y 4 +#define PIPE_TYPE_TRUNK 5 +#define PIPE_TYPE_BIN 6 +#define PIPE_TYPE_OUTLET 7 +#define PIPE_TYPE_INTAKE 8 +#define PIPE_TYPE_JUNC_SORT 9 +#define PIPE_TYPE_JUNC_SORT_FLIP 10 +#define PIPE_TYPE_UP 11 +#define PIPE_TYPE_DOWN 12 +#define PIPE_TYPE_TAGGER 13 +#define PIPE_TYPE_TAGGER_PART 14 + +#define SORT_TYPE_NORMAL 0 +#define SORT_TYPE_WILDCARD 1 +#define SORT_TYPE_UNTAGGED 2 + /obj/structure/disposalconstruct name = "disposal pipe segment" @@ -12,9 +32,8 @@ matter = list(DEFAULT_WALL_MATERIAL = 1850) level = 2 var/sortType = "" - var/ptype = 0 - // 0=straight, 1=bent, 2=junction-j1, 3=junction-j2, 4=junction-y, 5=trunk, 6=disposal bin, 7=outlet, 8=inlet 9=pipe-j1s 10=pipe-j2s - var/subtype = 0 + var/pipe_type = 0 + var/sort_type = 0 var/dpdir = 0 // directions as disposalpipe var/base_state = "pipe-s" @@ -23,66 +42,65 @@ var/flip = turn(dir, 180) var/left = turn(dir, 90) var/right = turn(dir, -90) - - switch(ptype) - if(0) + switch(pipe_type) + if(PIPE_TYPE_STRAIGHT) base_state = "pipe-s" dpdir = dir | flip - if(1) + if(PIPE_TYPE_BENT) base_state = "pipe-c" dpdir = dir | right - if(2) + if(PIPE_TYPE_JUNC) base_state = "pipe-j1" dpdir = dir | right | flip - if(3) + if(PIPE_TYPE_JUNC_FLIP) base_state = "pipe-j2" dpdir = dir | left | flip - if(4) + if(PIPE_TYPE_JUNC_Y) base_state = "pipe-y" dpdir = dir | left | right - if(5) + if(PIPE_TYPE_TRUNK) base_state = "pipe-t" dpdir = dir // disposal bin has only one dir, thus we don't need to care about setting it - if(6) + if(PIPE_TYPE_BIN) if(anchored) base_state = "disposal" else base_state = "condisposal" - if(7) + if(PIPE_TYPE_OUTLET) base_state = "outlet" dpdir = dir - if(8) + if(PIPE_TYPE_INTAKE) base_state = "intake" dpdir = dir - if(9) + if(PIPE_TYPE_JUNC_SORT) base_state = "pipe-j1s" dpdir = dir | right | flip - if(10) + if(PIPE_TYPE_JUNC_SORT_FLIP) base_state = "pipe-j2s" dpdir = dir | left | flip ///// Z-Level stuff - if(11) + if(PIPE_TYPE_UP) base_state = "pipe-u" dpdir = dir - if(12) + if(PIPE_TYPE_DOWN) base_state = "pipe-d" dpdir = dir ///// Z-Level stuff - if(13) + if(PIPE_TYPE_TAGGER) base_state = "pipe-tagger" dpdir = dir | flip - if(14) + if(PIPE_TYPE_TAGGER_PART) base_state = "pipe-tagger-partial" dpdir = dir | flip ///// Z-Level stuff - if(!(ptype in list(6, 7, 8, 11, 12, 13, 14))) + if(!(pipe_type in list(6, 7, 8, 11, 12, 13, 14))) ///// Z-Level stuff icon_state = "con[base_state]" else @@ -96,93 +114,93 @@ // hide called by levelupdate if turf intact status changes // change visibility status and force update of icon - hide(var/intact) - invisibility = (intact && level==1) ? 101: 0 // hide if floor is intact - update() +/obj/structure/disposalconstruct/hide(var/intact) + invisibility = (intact && level==1) ? 101: 0 // hide if floor is intact + update() // flip and rotate verbs - verb/rotate() - set category = "Object" - set name = "Rotate Pipe" - set src in view(1) +/obj/structure/disposalconstruct/verb/rotate() + set category = "Object" + set name = "Rotate Pipe" + set src in view(1) - if(usr.stat) - return + if(usr.stat) + return - if(anchored) - usr << "You must unfasten the pipe before rotating it." - return + if(anchored) + usr << "You must unfasten the pipe before rotating it." + return - set_dir(turn(dir, -90)) - update() + set_dir(turn(dir, -90)) + update() - verb/flip() - set category = "Object" - set name = "Flip Pipe" - set src in view(1) - if(usr.stat) - return +/obj/structure/disposalconstruct/verb/flip() + set category = "Object" + set name = "Flip Pipe" + set src in view(1) + if(usr.stat) + return - if(anchored) - usr << "You must unfasten the pipe before flipping it." - return + if(anchored) + usr << "You must unfasten the pipe before flipping it." + return - set_dir(turn(dir, 180)) - switch(ptype) - if(2) - ptype = 3 - if(3) - ptype = 2 - if(9) - ptype = 10 - if(10) - ptype = 9 + set_dir(turn(dir, 180)) + switch(pipe_type) + if(PIPE_TYPE_JUNC) + pipe_type = PIPE_TYPE_JUNC_FLIP + if(PIPE_TYPE_JUNC_FLIP) + pipe_type = PIPE_TYPE_JUNC + if(PIPE_TYPE_JUNC_SORT) + pipe_type = PIPE_TYPE_JUNC_SORT_FLIP + if(PIPE_TYPE_JUNC_SORT_FLIP) + pipe_type = PIPE_TYPE_JUNC_SORT - update() + update() // returns the type path of disposalpipe corresponding to this item dtype - proc/dpipetype() - switch(ptype) - if(0,1) - return /obj/structure/disposalpipe/segment - if(2,3,4) - return /obj/structure/disposalpipe/junction - if(5) - return /obj/structure/disposalpipe/trunk - if(6) - return /obj/machinery/disposal - if(7) - return /obj/structure/disposaloutlet - if(8) - return /obj/machinery/disposal/deliveryChute - if(9) - switch(subtype) - if(0) - return /obj/structure/disposalpipe/sortjunction - if(1) - return /obj/structure/disposalpipe/sortjunction/wildcard - if(2) - return /obj/structure/disposalpipe/sortjunction/untagged - if(10) - switch(subtype) - if(0) - return /obj/structure/disposalpipe/sortjunction/flipped - if(1) - return /obj/structure/disposalpipe/sortjunction/wildcard/flipped - if(2) - return /obj/structure/disposalpipe/sortjunction/untagged/flipped +/obj/structure/disposalconstruct/proc/dpipetype() + switch(pipe_type) + if(PIPE_TYPE_STRAIGHT, PIPE_TYPE_BENT) + return /obj/structure/disposalpipe/segment + if(PIPE_TYPE_JUNC, PIPE_TYPE_JUNC_FLIP, PIPE_TYPE_JUNC_Y) + return /obj/structure/disposalpipe/junction + if(PIPE_TYPE_TRUNK) + return /obj/structure/disposalpipe/trunk + if(PIPE_TYPE_BIN) + return /obj/machinery/disposal + if(PIPE_TYPE_OUTLET) + return /obj/structure/disposaloutlet + if(PIPE_TYPE_INTAKE) + return /obj/machinery/disposal/deliveryChute + if(PIPE_TYPE_JUNC_SORT) + switch(sort_type) + if(SORT_TYPE_NORMAL) + return /obj/structure/disposalpipe/sortjunction + if(SORT_TYPE_WILDCARD) + return /obj/structure/disposalpipe/sortjunction/wildcard + if(SORT_TYPE_UNTAGGED) + return /obj/structure/disposalpipe/sortjunction/untagged + if(PIPE_TYPE_JUNC_SORT_FLIP) + switch(sort_type) + if(SORT_TYPE_NORMAL) + return /obj/structure/disposalpipe/sortjunction/flipped + if(SORT_TYPE_WILDCARD) + return /obj/structure/disposalpipe/sortjunction/wildcard/flipped + if(SORT_TYPE_UNTAGGED) + return /obj/structure/disposalpipe/sortjunction/untagged/flipped ///// Z-Level stuff - if(11) - return /obj/structure/disposalpipe/up - if(12) - return /obj/structure/disposalpipe/down + if(PIPE_TYPE_UP) + return /obj/structure/disposalpipe/up + if(PIPE_TYPE_DOWN) + return /obj/structure/disposalpipe/down ///// Z-Level stuff - if(13) - return /obj/structure/disposalpipe/tagger - if(14) - return /obj/structure/disposalpipe/tagger/partial - return + if(PIPE_TYPE_TAGGER) + return /obj/structure/disposalpipe/tagger + if(PIPE_TYPE_TAGGER_PART) + return /obj/structure/disposalpipe/tagger/partial + return @@ -190,136 +208,136 @@ // wrench: (un)anchor // weldingtool: convert to real pipe - attackby(var/obj/item/I, var/mob/user) - var/nicetype = "pipe" - var/ispipe = 0 // Indicates if we should change the level of this pipe - src.add_fingerprint(user) - switch(ptype) - if(6) - nicetype = "disposal bin" - if(7) - nicetype = "disposal outlet" - if(8) - nicetype = "delivery chute" - if(9, 10) - switch(subtype) - if(0) - nicetype = "sorting pipe" - if(1) - nicetype = "wildcard sorting pipe" - if(2) - nicetype = "untagged sorting pipe" - ispipe = 1 - if(13) - nicetype = "tagging pipe" - ispipe = 1 - if(14) - nicetype = "partial tagging pipe" - ispipe = 1 - else - nicetype = "pipe" - ispipe = 1 +/obj/structure/disposalconstruct/attackby(var/obj/item/I, var/mob/user) + var/nicetype = "pipe" + var/ispipe = 0 // Indicates if we should change the level of this pipe + src.add_fingerprint(user) + switch(pipe_type) + if(PIPE_TYPE_BIN) + nicetype = "disposal bin" + if(PIPE_TYPE_OUTLET) + nicetype = "disposal outlet" + if(PIPE_TYPE_INTAKE) + nicetype = "delivery chute" + if(PIPE_TYPE_JUNC_SORT, PIPE_TYPE_JUNC_SORT_FLIP) + switch(sort_type) + if(SORT_TYPE_NORMAL) + nicetype = "sorting pipe" + if(SORT_TYPE_WILDCARD) + nicetype = "wildcard sorting pipe" + if(SORT_TYPE_UNTAGGED) + nicetype = "untagged sorting pipe" + ispipe = 1 + if(PIPE_TYPE_TAGGER) + nicetype = "tagging pipe" + ispipe = 1 + if(PIPE_TYPE_TAGGER_PART) + nicetype = "partial tagging pipe" + ispipe = 1 + else + nicetype = "pipe" + ispipe = 1 - var/turf/T = src.loc - if(!T.is_plating()) - user << "You can only attach the [nicetype] if the floor plating is removed." - return + var/turf/T = src.loc + if(!T.is_plating()) + user << "You can only attach the [nicetype] if the floor plating is removed." + return - var/obj/structure/disposalpipe/CP = locate() in T + var/obj/structure/disposalpipe/CP = locate() in T - if(istype(I, /obj/item/weapon/wrench)) - if(anchored) - anchored = 0 - if(ispipe) - level = 2 - density = 0 - else - density = 1 - user << "You detach the [nicetype] from the underfloor." + if(istype(I, /obj/item/weapon/wrench)) + if(anchored) + anchored = 0 + if(ispipe) + level = 2 + density = 0 else - if(ptype>=6 && ptype <= 8) // Disposal or outlet - if(CP) // There's something there - if(!istype(CP,/obj/structure/disposalpipe/trunk)) - user << "The [nicetype] requires a trunk underneath it in order to work." - return - else // Nothing under, fuck. + density = 1 + user << "You detach the [nicetype] from the underfloor." + else + if(pipe_type in list(PIPE_TYPE_BIN, PIPE_TYPE_OUTLET, PIPE_TYPE_INTAKE)) + if(CP) // There's something there + if(!istype(CP,/obj/structure/disposalpipe/trunk)) user << "The [nicetype] requires a trunk underneath it in order to work." return - else - if(CP) - update() - var/pdir = CP.dpdir - if(istype(CP, /obj/structure/disposalpipe/broken)) - pdir = CP.dir - if(pdir & dpdir) - user << "There is already a [nicetype] at that location." - return - - anchored = 1 - if(ispipe) - level = 1 // We don't want disposal bins to disappear under the floors - density = 0 - else - density = 1 // We don't want disposal bins or outlets to go density 0 - user << "You attach the [nicetype] to the underfloor." - playsound(src.loc, 'sound/items/Ratchet.ogg', 100, 1) - update() - - else if(istype(I, /obj/item/weapon/weldingtool)) - if(anchored) - var/obj/item/weapon/weldingtool/W = I - if(W.remove_fuel(0,user)) - playsound(src.loc, 'sound/items/Welder2.ogg', 100, 1) - user << "Welding the [nicetype] in place." - if(do_after(user, 20, src)) - if(!src || !W.isOn()) return - user << "The [nicetype] has been welded in place!" - update() // TODO: Make this neat - if(ispipe) // Pipe - - var/pipetype = dpipetype() - var/obj/structure/disposalpipe/P = new pipetype(src.loc) - src.transfer_fingerprints_to(P) - P.base_icon_state = base_state - P.set_dir(dir) - P.dpdir = dpdir - P.updateicon() - - //Needs some special treatment ;) - if(ptype==9 || ptype==10) - var/obj/structure/disposalpipe/sortjunction/SortP = P - SortP.sortType = sortType - SortP.updatedir() - SortP.updatedesc() - SortP.updatename() - - else if(ptype==6) // Disposal bin - var/obj/machinery/disposal/P = new /obj/machinery/disposal(src.loc) - src.transfer_fingerprints_to(P) - P.mode = 0 // start with pump off - - else if(ptype==7) // Disposal outlet - - var/obj/structure/disposaloutlet/P = new /obj/structure/disposaloutlet(src.loc) - src.transfer_fingerprints_to(P) - P.set_dir(dir) - var/obj/structure/disposalpipe/trunk/Trunk = CP - Trunk.linked = P - - else if(ptype==8) // Disposal outlet - - var/obj/machinery/disposal/deliveryChute/P = new /obj/machinery/disposal/deliveryChute(src.loc) - src.transfer_fingerprints_to(P) - P.set_dir(dir) - - qdel(src) + else // Nothing under, fuck. + user << "The [nicetype] requires a trunk underneath it in order to work." + return + else + if(CP) + update() + var/pdir = CP.dpdir + if(istype(CP, /obj/structure/disposalpipe/broken)) + pdir = CP.dir + if(pdir & dpdir) + user << "There is already a [nicetype] at that location." return - else - user << "You need more welding fuel to complete this task." + + anchored = 1 + if(ispipe) + level = 1 // We don't want disposal bins to disappear under the floors + density = 0 + else + density = 1 // We don't want disposal bins or outlets to go density 0 + user << "You attach the [nicetype] to the underfloor." + playsound(src.loc, 'sound/items/Ratchet.ogg', 100, 1) + update() + + else if(istype(I, /obj/item/weapon/weldingtool)) + if(anchored) + var/obj/item/weapon/weldingtool/W = I + if(W.remove_fuel(0,user)) + playsound(src.loc, 'sound/items/Welder2.ogg', 100, 1) + user << "Welding the [nicetype] in place." + if(do_after(user, 20, src)) + if(!src || !W.isOn()) return + user << "The [nicetype] has been welded in place!" + update() // TODO: Make this neat + if(ispipe) // Pipe + + var/pipetype = dpipetype() + var/obj/structure/disposalpipe/P = new pipetype(src.loc) + src.transfer_fingerprints_to(P) + P.base_icon_state = base_state + P.set_dir(dir) + P.dpdir = dpdir + P.updateicon() + + //Needs some special treatment ;) + if(pipe_type in list(PIPE_TYPE_JUNC_SORT, PIPE_TYPE_JUNC_SORT_FLIP)) + var/obj/structure/disposalpipe/sortjunction/SortP = P + SortP.sortType = sortType + SortP.updatedir() + SortP.updatedesc() + SortP.updatename() + + else if(pipe_type == PIPE_TYPE_BIN) // Disposal bin + var/obj/machinery/disposal/P = new /obj/machinery/disposal(src.loc) + src.transfer_fingerprints_to(P) + P.mode = 0 // start with pump off + + else if(pipe_type == PIPE_TYPE_OUTLET) // Disposal outlet + + var/obj/structure/disposaloutlet/P = new /obj/structure/disposaloutlet(src.loc) + src.transfer_fingerprints_to(P) + P.set_dir(dir) + var/obj/structure/disposalpipe/trunk/Trunk = CP + Trunk.linked = P + + else if(pipe_type == PIPE_TYPE_INTAKE) // Disposal outlet + + var/obj/machinery/disposal/deliveryChute/P = new /obj/machinery/disposal/deliveryChute(src.loc) + src.transfer_fingerprints_to(P) + P.set_dir(dir) + + qdel(src) return else - user << "You need to attach it to the plating first!" + user << "You need more welding fuel to complete this task." return + else + user << "You need to attach it to the plating first!" + return /obj/structure/disposalconstruct/hides_under_flooring() if(anchored) diff --git a/code/modules/recycling/disposal.dm b/code/modules/recycling/disposal.dm index feb38a21ee0..025e11e22ee 100644 --- a/code/modules/recycling/disposal.dm +++ b/code/modules/recycling/disposal.dm @@ -83,7 +83,7 @@ user << "You sliced the floorweld off the disposal unit." var/obj/structure/disposalconstruct/C = new (src.loc) src.transfer_fingerprints_to(C) - C.ptype = 6 // 6 = disposal unit + C.pipe_type = PIPE_TYPE_BIN C.anchored = 1 C.density = 1 C.update() @@ -657,7 +657,7 @@ layer = 2.3 // slightly lower than wires and other pipes var/base_icon_state // initial icon state on map var/sortType = "" - var/subtype = 0 + var/subtype = SORT_TYPE_NORMAL // new pipe, set the icon_state as on map New() ..() @@ -691,242 +691,239 @@ // returns the direction of the next pipe object, given the entrance dir // by default, returns the bitmask of remaining directions - proc/nextdir(var/fromdir) - return dpdir & (~turn(fromdir, 180)) +/obj/structure/disposalpipe/proc/nextdir(var/fromdir) + return dpdir & (~turn(fromdir, 180)) // transfer the holder through this pipe segment // overriden for special behaviour // - proc/transfer(var/obj/structure/disposalholder/H) - var/nextdir = nextdir(H.dir) - H.set_dir(nextdir) - var/turf/T = H.nextloc() - var/obj/structure/disposalpipe/P = H.findpipe(T) - - if(P) - // find other holder in next loc, if inactive merge it with current - var/obj/structure/disposalholder/H2 = locate() in P - if(H2 && !H2.active) - H.merge(H2) - - H.forceMove(P) - else // if wasn't a pipe, then set loc to turf - H.forceMove(T) - return null +/obj/structure/disposalpipe/proc/transfer(var/obj/structure/disposalholder/H) + var/nextdir = nextdir(H.dir) + H.set_dir(nextdir) + var/turf/T = H.nextloc() + var/obj/structure/disposalpipe/P = H.findpipe(T) + + if(P) + // find other holder in next loc, if inactive merge it with current + var/obj/structure/disposalholder/H2 = locate() in P + if(H2 && !H2.active) + H.merge(H2) + + H.forceMove(P) + else // if wasn't a pipe, then set loc to turf + H.forceMove(T) + return null - return P + return P // update the icon_state to reflect hidden status - proc/update() - var/turf/T = src.loc - hide(!T.is_plating() && !istype(T,/turf/space)) // space never hides pipes +/obj/structure/disposalpipe/proc/update() + var/turf/T = src.loc + hide(!T.is_plating() && !istype(T,/turf/space)) // space never hides pipes - // hide called by levelupdate if turf intact status changes - // change visibility status and force update of icon - hide(var/intact) - invisibility = intact ? 101: 0 // hide if floor is intact - updateicon() +// hide called by levelupdate if turf intact status changes +// change visibility status and force update of icon +/obj/structure/disposalpipe/hide(var/intact) + invisibility = intact ? 101: 0 // hide if floor is intact + updateicon() // update actual icon_state depending on visibility // if invisible, append "f" to icon_state to show faded version // this will be revealed if a T-scanner is used // if visible, use regular icon_state - proc/updateicon() -/* if(invisibility) //we hide things with alpha now, no need for transparent icons - icon_state = "[base_icon_state]f" - else - icon_state = base_icon_state*/ - icon_state = base_icon_state - return +/obj/structure/disposalpipe/proc/updateicon() + + icon_state = base_icon_state + return // expel the held objects into a turf // called when there is a break in the pipe - proc/expel(var/obj/structure/disposalholder/H, var/turf/T, var/direction) - if(!istype(H)) - return +/obj/structure/disposalpipe/proc/expel(var/obj/structure/disposalholder/H, var/turf/T, var/direction) + if(!istype(H)) + return - // Empty the holder if it is expelled into a dense turf. - // Leaving it intact and sitting in a wall is stupid. - if(T.density) - for(var/atom/movable/AM in H) - AM.loc = T - AM.pipe_eject(0) - qdel(H) - return + // Empty the holder if it is expelled into a dense turf. + // Leaving it intact and sitting in a wall is stupid. + if(T.density) + for(var/atom/movable/AM in H) + AM.loc = T + AM.pipe_eject(0) + qdel(H) + return - if(!T.is_plating() && istype(T,/turf/simulated/floor)) //intact floor, pop the tile - var/turf/simulated/floor/F = T - F.break_tile() - new /obj/item/stack/tile(H) // add to holder so it will be thrown with other stuff + if(!T.is_plating() && istype(T,/turf/simulated/floor)) //intact floor, pop the tile + var/turf/simulated/floor/F = T + F.break_tile() + new /obj/item/stack/tile(H) // add to holder so it will be thrown with other stuff - var/turf/target - if(direction) // direction is specified - if(istype(T, /turf/space)) // if ended in space, then range is unlimited - target = get_edge_target_turf(T, direction) - else // otherwise limit to 10 tiles - target = get_ranged_target_turf(T, direction, 10) + var/turf/target + if(direction) // direction is specified + if(istype(T, /turf/space)) // if ended in space, then range is unlimited + target = get_edge_target_turf(T, direction) + else // otherwise limit to 10 tiles + target = get_ranged_target_turf(T, direction, 10) - playsound(src, 'sound/machines/hiss.ogg', 50, 0, 0) - if(H) - for(var/atom/movable/AM in H) - AM.forceMove(T) - AM.pipe_eject(direction) - spawn(1) - if(AM) - AM.throw_at(target, 100, 1) - H.vent_gas(T) - qdel(H) + playsound(src, 'sound/machines/hiss.ogg', 50, 0, 0) + if(H) + for(var/atom/movable/AM in H) + AM.forceMove(T) + AM.pipe_eject(direction) + spawn(1) + if(AM) + AM.throw_at(target, 100, 1) + H.vent_gas(T) + qdel(H) - else // no specified direction, so throw in random direction + else // no specified direction, so throw in random direction - playsound(src, 'sound/machines/hiss.ogg', 50, 0, 0) - if(H) - for(var/atom/movable/AM in H) - target = get_offset_target_turf(T, rand(5)-rand(5), rand(5)-rand(5)) + playsound(src, 'sound/machines/hiss.ogg', 50, 0, 0) + if(H) + for(var/atom/movable/AM in H) + target = get_offset_target_turf(T, rand(5)-rand(5), rand(5)-rand(5)) - AM.forceMove(T) - AM.pipe_eject(0) - spawn(1) - if(AM) - AM.throw_at(target, 5, 1) + AM.forceMove(T) + AM.pipe_eject(0) + spawn(1) + if(AM) + AM.throw_at(target, 5, 1) - H.vent_gas(T) // all gas vent to turf - qdel(H) + H.vent_gas(T) // all gas vent to turf + qdel(H) - return + return // call to break the pipe // will expel any holder inside at the time // then delete the pipe // remains : set to leave broken pipe pieces in place - proc/broken(var/remains = 0) - if(remains) - for(var/D in cardinal) - if(D & dpdir) - var/obj/structure/disposalpipe/broken/P = new(src.loc) - P.set_dir(D) - - src.invisibility = 101 // make invisible (since we won't delete the pipe immediately) - var/obj/structure/disposalholder/H = locate() in src - if(H) - // holder was present - H.active = 0 - var/turf/T = src.loc - if(T.density) - // broken pipe is inside a dense turf (wall) - // this is unlikely, but just dump out everything into the turf in case +/obj/structure/disposalpipe/proc/broken(var/remains = 0) + if(remains) + for(var/D in cardinal) + if(D & dpdir) + var/obj/structure/disposalpipe/broken/P = new(src.loc) + P.set_dir(D) + + src.invisibility = 101 // make invisible (since we won't delete the pipe immediately) + var/obj/structure/disposalholder/H = locate() in src + if(H) + // holder was present + H.active = 0 + var/turf/T = src.loc + if(T.density) + // broken pipe is inside a dense turf (wall) + // this is unlikely, but just dump out everything into the turf in case - for(var/atom/movable/AM in H) - AM.forceMove(T) - AM.pipe_eject(0) - qdel(H) - return + for(var/atom/movable/AM in H) + AM.forceMove(T) + AM.pipe_eject(0) + qdel(H) + return - // otherwise, do normal expel from turf - if(H) - expel(H, T, 0) + // otherwise, do normal expel from turf + if(H) + expel(H, T, 0) - spawn(2) // delete pipe after 2 ticks to ensure expel proc finished - qdel(src) + spawn(2) // delete pipe after 2 ticks to ensure expel proc finished + qdel(src) - // pipe affected by explosion - ex_act(severity) +// pipe affected by explosion +ex_act(severity) - switch(severity) - if(1.0) - broken(0) - return - if(2.0) - health -= rand(5,15) - healthcheck() - return - if(3.0) - health -= rand(0,15) - healthcheck() - return + switch(severity) + if(1.0) + broken(0) + return + if(2.0) + health -= rand(5,15) + healthcheck() + return + if(3.0) + health -= rand(0,15) + healthcheck() + return // test health for brokenness - proc/healthcheck() - if(health < -2) - broken(0) - else if(health<1) - broken(1) - return +/obj/structure/disposalpipe/proc/healthcheck() + if(health < -2) + broken(0) + else if(health<1) + broken(1) + return //attack by item //weldingtool: unfasten and convert to obj/disposalconstruct - attackby(var/obj/item/I, var/mob/user) +/obj/structure/disposalpipe/attackby(var/obj/item/I, var/mob/user) - var/turf/T = src.loc - if(!T.is_plating()) - return // prevent interaction with T-scanner revealed pipes - src.add_fingerprint(user) - if(istype(I, /obj/item/weapon/weldingtool)) - var/obj/item/weapon/weldingtool/W = I + var/turf/T = src.loc + if(!T.is_plating()) + return // prevent interaction with T-scanner revealed pipes + src.add_fingerprint(user) + if(istype(I, /obj/item/weapon/weldingtool)) + var/obj/item/weapon/weldingtool/W = I - if(W.remove_fuel(0,user)) - playsound(src.loc, 'sound/items/Welder2.ogg', 100, 1) - // check if anything changed over 2 seconds - var/turf/uloc = user.loc - var/atom/wloc = W.loc - user << "Slicing the disposal pipe." - sleep(30) - if(!W.isOn()) return - if(user.loc == uloc && wloc == W.loc) - welded() - else - user << "You must stay still while welding the pipe." + if(W.remove_fuel(0,user)) + playsound(src.loc, 'sound/items/Welder2.ogg', 100, 1) + // check if anything changed over 2 seconds + var/turf/uloc = user.loc + var/atom/wloc = W.loc + user << "Slicing the disposal pipe." + sleep(30) + if(!W.isOn()) return + if(user.loc == uloc && wloc == W.loc) + welded() else - user << "You need more welding fuel to cut the pipe." - return + user << "You must stay still while welding the pipe." + else + user << "You need more welding fuel to cut the pipe." + return // called when pipe is cut with welder - proc/welded() - - var/obj/structure/disposalconstruct/C = new (src.loc) - switch(base_icon_state) - if("pipe-s") - C.ptype = 0 - if("pipe-c") - C.ptype = 1 - if("pipe-j1") - C.ptype = 2 - if("pipe-j2") - C.ptype = 3 - if("pipe-y") - C.ptype = 4 - if("pipe-t") - C.ptype = 5 - if("pipe-j1s") - C.ptype = 9 - C.sortType = sortType - if("pipe-j2s") - C.ptype = 10 - C.sortType = sortType +/obj/structure/disposalpipe/proc/welded() + + var/obj/structure/disposalconstruct/C = new (src.loc) + switch(base_icon_state) + if("pipe-s") + C.pipe_type = PIPE_TYPE_STRAIGHT + if("pipe-c") + C.pipe_type = PIPE_TYPE_BENT + if("pipe-j1") + C.pipe_type = PIPE_TYPE_JUNC + if("pipe-j2") + C.pipe_type = PIPE_TYPE_JUNC_FLIP + if("pipe-y") + C.pipe_type = PIPE_TYPE_JUNC_Y + if("pipe-t") + C.pipe_type = PIPE_TYPE_TRUNK + if("pipe-j1s") + C.pipe_type = PIPE_TYPE_JUNC_SORT + C.sortType = sortType + if("pipe-j2s") + C.pipe_type = PIPE_TYPE_JUNC_SORT_FLIP + C.sortType = sortType ///// Z-Level stuff - if("pipe-u") - C.ptype = 11 - if("pipe-d") - C.ptype = 12 -///// Z-Level stuff - if("pipe-tagger") - C.ptype = 13 - if("pipe-tagger-partial") - C.ptype = 14 - C.subtype = src.subtype - src.transfer_fingerprints_to(C) - C.set_dir(dir) - C.density = 0 - C.anchored = 1 - C.update() - - qdel(src) + if("pipe-u") + C.pipe_type = PIPE_TYPE_UP + if("pipe-d") + C.pipe_type = PIPE_TYPE_DOWN +///// Z-Level stuff end + if("pipe-tagger") + C.pipe_type = PIPE_TYPE_TAGGER + if("pipe-tagger-partial") + C.pipe_type = PIPE_TYPE_TAGGER_PART + C.sort_type = src.subtype + src.transfer_fingerprints_to(C) + C.set_dir(dir) + C.density = 0 + C.anchored = 1 + C.update() + + qdel(src) // pipe is deleted // ensure if holder is present, it is expelled @@ -978,102 +975,102 @@ /obj/structure/disposalpipe/up icon_state = "pipe-u" - New() - ..() - dpdir = dir - update() - return - - nextdir(var/fromdir) - var/nextdir - if(fromdir == 11) - nextdir = dir - else - nextdir = 12 - return nextdir +/obj/structure/disposalpipe/up/New() + ..() + dpdir = dir + update() + return - transfer(var/obj/structure/disposalholder/H) - var/nextdir = nextdir(H.dir) - H.set_dir(nextdir) +/obj/structure/disposalpipe/up/nextdir(var/fromdir) + var/nextdir + if(fromdir == 11) + nextdir = dir + else + nextdir = 12 + return nextdir - var/turf/T - var/obj/structure/disposalpipe/P +/obj/structure/disposalpipe/up/transfer(var/obj/structure/disposalholder/H) + var/nextdir = nextdir(H.dir) + H.set_dir(nextdir) - if(nextdir == 12) - T = GetAbove(src) - if(!T) - H.forceMove(loc) - return - else - for(var/obj/structure/disposalpipe/down/F in T) - P = F + var/turf/T + var/obj/structure/disposalpipe/P + if(nextdir == 12) + T = GetAbove(src) + if(!T) + H.forceMove(loc) + return else - T = get_step(src.loc, H.dir) - P = H.findpipe(T) - - if(P) - // find other holder in next loc, if inactive merge it with current - var/obj/structure/disposalholder/H2 = locate() in P - if(H2 && !H2.active) - H.merge(H2) - - H.forceMove(P) - else // if wasn't a pipe, then set loc to turf - H.forceMove(T) - return null + for(var/obj/structure/disposalpipe/down/F in T) + P = F + + else + T = get_step(src.loc, H.dir) + P = H.findpipe(T) + + if(P) + // find other holder in next loc, if inactive merge it with current + var/obj/structure/disposalholder/H2 = locate() in P + if(H2 && !H2.active) + H.merge(H2) + + H.forceMove(P) + else // if wasn't a pipe, then set loc to turf + H.forceMove(T) + return null - return P + return P /obj/structure/disposalpipe/down icon_state = "pipe-d" - New() - ..() - dpdir = dir - update() - return - - nextdir(var/fromdir) - var/nextdir - if(fromdir == 12) - nextdir = dir - else - nextdir = 11 - return nextdir +/obj/structure/disposalpipe/down/New() + ..() + dpdir = dir + update() + return - transfer(var/obj/structure/disposalholder/H) - var/nextdir = nextdir(H.dir) - H.dir = nextdir +/obj/structure/disposalpipe/down/nextdir(var/fromdir) + var/nextdir + if(fromdir == 12) + nextdir = dir + else + nextdir = 11 + return nextdir - var/turf/T - var/obj/structure/disposalpipe/P +/obj/structure/disposalpipe/down/transfer(var/obj/structure/disposalholder/H) + var/nextdir = nextdir(H.dir) + H.dir = nextdir - if(nextdir == 11) - T = GetBelow(src) - if(!T) - H.forceMove(src.loc) - return - else - for(var/obj/structure/disposalpipe/up/F in T) - P = F + var/turf/T + var/obj/structure/disposalpipe/P + if(nextdir == 11) + T = GetBelow(src) + if(!T) + H.forceMove(src.loc) + return else - T = get_step(src.loc, H.dir) - P = H.findpipe(T) - - if(P) - // find other holder in next loc, if inactive merge it with current - var/obj/structure/disposalholder/H2 = locate() in P - if(H2 && !H2.active) - H.merge(H2) - - H.forceMove(P) - else // if wasn't a pipe, then set loc to turf - H.forceMove(T) - return null + for(var/obj/structure/disposalpipe/up/F in T) + P = F - return P + else + T = get_step(src.loc, H.dir) + P = H.findpipe(T) + + if(P) + // find other holder in next loc, if inactive merge it with current + var/obj/structure/disposalholder/H2 = locate() in P + if(H2 && !H2.active) + H.merge(H2) + + H.forceMove(P) + else // if wasn't a pipe, then set loc to turf + H.forceMove(T) + return null + + return P ///// Z-Level stuff /obj/structure/disposalpipe/junction/yjunction @@ -1083,45 +1080,45 @@ /obj/structure/disposalpipe/junction icon_state = "pipe-j1" - New() - ..() - if(icon_state == "pipe-j1") - dpdir = dir | turn(dir, -90) | turn(dir,180) - else if(icon_state == "pipe-j2") - dpdir = dir | turn(dir, 90) | turn(dir,180) - else // pipe-y - dpdir = dir | turn(dir,90) | turn(dir, -90) - update() - return +/obj/structure/disposalpipe/junction/New() + ..() + if(icon_state == "pipe-j1") + dpdir = dir | turn(dir, -90) | turn(dir,180) + else if(icon_state == "pipe-j2") + dpdir = dir | turn(dir, 90) | turn(dir,180) + else // pipe-y + dpdir = dir | turn(dir,90) | turn(dir, -90) + update() + return // next direction to move // if coming in from secondary dirs, then next is primary dir // if coming in from primary dir, then next is equal chance of other dirs - nextdir(var/fromdir) - var/flipdir = turn(fromdir, 180) - if(flipdir != dir) // came from secondary dir - return dir // so exit through primary - else // came from primary - // so need to choose either secondary exit - var/mask = ..(fromdir) - - // find a bit which is set - var/setbit = 0 - if(mask & NORTH) - setbit = NORTH - else if(mask & SOUTH) - setbit = SOUTH - else if(mask & EAST) - setbit = EAST - else - setbit = WEST +/obj/structure/disposalpipe/junction/nextdir(var/fromdir) + var/flipdir = turn(fromdir, 180) + if(flipdir != dir) // came from secondary dir + return dir // so exit through primary + else // came from primary + // so need to choose either secondary exit + var/mask = ..(fromdir) + + // find a bit which is set + var/setbit = 0 + if(mask & NORTH) + setbit = NORTH + else if(mask & SOUTH) + setbit = SOUTH + else if(mask & EAST) + setbit = EAST + else + setbit = WEST - if(prob(50)) // 50% chance to choose the found bit or the other one - return setbit - else - return mask & (~setbit) + if(prob(50)) // 50% chance to choose the found bit or the other one + return setbit + else + return mask & (~setbit) /obj/structure/disposalpipe/tagger @@ -1130,46 +1127,46 @@ var/sort_tag = "" var/partial = 0 - proc/updatedesc() - desc = initial(desc) - if(sort_tag) - desc += "\nIt's tagging objects with the '[sort_tag]' tag." - - proc/updatename() - if(sort_tag) - name = "[initial(name)] ([sort_tag])" - else - name = initial(name) +/obj/structure/disposalpipe/tagger/proc/updatedesc() + desc = initial(desc) + if(sort_tag) + desc += "\nIt's tagging objects with the '[sort_tag]' tag." - New() - . = ..() - dpdir = dir | turn(dir, 180) - if(sort_tag) tagger_locations |= sort_tag - updatename() - updatedesc() - update() +/obj/structure/disposalpipe/tagger/proc/updatename() + if(sort_tag) + name = "[initial(name)] ([sort_tag])" + else + name = initial(name) + +/obj/structure/disposalpipe/tagger/New() + . = ..() + dpdir = dir | turn(dir, 180) + if(sort_tag) tagger_locations |= sort_tag + updatename() + updatedesc() + update() - attackby(var/obj/item/I, var/mob/user) - if(..()) - return +/obj/structure/disposalpipe/tagger/attackby(var/obj/item/I, var/mob/user) + if(..()) + return - if(istype(I, /obj/item/device/destTagger)) - var/obj/item/device/destTagger/O = I + if(istype(I, /obj/item/device/destTagger)) + var/obj/item/device/destTagger/O = I - if(O.currTag)// Tag set - sort_tag = O.currTag - playsound(src.loc, 'sound/machines/twobeep.ogg', 100, 1) - user << "\blue Changed tag to '[sort_tag]'." - updatename() - updatedesc() + if(O.currTag)// Tag set + sort_tag = O.currTag + playsound(src.loc, 'sound/machines/twobeep.ogg', 100, 1) + user << "\blue Changed tag to '[sort_tag]'." + updatename() + updatedesc() - transfer(var/obj/structure/disposalholder/H) - if(sort_tag) - if(partial) - H.setpartialtag(sort_tag) - else - H.settag(sort_tag) - return ..() +/obj/structure/disposalpipe/tagger/transfer(var/obj/structure/disposalholder/H) + if(sort_tag) + if(partial) + H.setpartialtag(sort_tag) + else + H.settag(sort_tag) + return ..() /obj/structure/disposalpipe/tagger/partial //needs two passes to tag name = "partial package tagger" @@ -1186,87 +1183,90 @@ var/negdir = 0 var/sortdir = 0 - proc/updatedesc() - desc = initial(desc) - if(sortType) - desc += "\nIt's filtering objects with the '[sortType]' tag." +/obj/structure/disposalpipe/sortjunction/proc/updatedesc() + desc = initial(desc) + if(sortType) + desc += "\nIt's filtering objects with the '[sortType]' tag." - proc/updatename() - if(sortType) - name = "[initial(name)] ([sortType])" - else - name = initial(name) +/obj/structure/disposalpipe/sortjunction/proc/updatename() + if(sortType) + name = "[initial(name)] ([sortType])" + else + name = initial(name) - proc/updatedir() - posdir = dir - negdir = turn(posdir, 180) +/obj/structure/disposalpipe/sortjunction/proc/updatedir() + posdir = dir + negdir = turn(posdir, 180) - if(icon_state == "pipe-j1s") - sortdir = turn(posdir, -90) - else if(icon_state == "pipe-j2s") - sortdir = turn(posdir, 90) + if(icon_state == "pipe-j1s") + sortdir = turn(posdir, -90) + else if(icon_state == "pipe-j2s") + sortdir = turn(posdir, 90) - dpdir = sortdir | posdir | negdir + dpdir = sortdir | posdir | negdir - New() - . = ..() - if(sortType) tagger_locations |= sortType +/obj/structure/disposalpipe/sortjunction/New() + . = ..() + if(sortType) tagger_locations |= sortType - updatedir() - updatename() - updatedesc() - update() + updatedir() + updatename() + updatedesc() + update() - attackby(var/obj/item/I, var/mob/user) - if(..()) - return +/obj/structure/disposalpipe/sortjunction/attackby(var/obj/item/I, var/mob/user) + if(..()) + return - if(istype(I, /obj/item/device/destTagger)) - var/obj/item/device/destTagger/O = I + if(istype(I, /obj/item/device/destTagger)) + var/obj/item/device/destTagger/O = I - if(O.currTag)// Tag set - sortType = O.currTag - playsound(src.loc, 'sound/machines/twobeep.ogg', 100, 1) - user << "\blue Changed filter to '[sortType]'." - updatename() - updatedesc() + if(O.currTag)// Tag set + sortType = O.currTag + playsound(src.loc, 'sound/machines/twobeep.ogg', 100, 1) + user << "\blue Changed filter to '[sortType]'." + updatename() + updatedesc() - proc/divert_check(var/checkTag) - return sortType == checkTag +/obj/structure/disposalpipe/sortjunction/proc/divert_check(var/checkTag) + if(islist(sortType)) + return checkTag in sortType + else + return checkTag == sortType // next direction to move // if coming in from negdir, then next is primary dir or sortdir // if coming in from posdir, then flip around and go back to posdir // if coming in from sortdir, go to posdir - nextdir(var/fromdir, var/sortTag) - if(fromdir != sortdir) // probably came from the negdir - if(divert_check(sortTag)) - return sortdir - else - return posdir - else // came from sortdir - // so go with the flow to positive direction +/obj/structure/disposalpipe/sortjunction/nextdir(var/fromdir, var/sortTag) + if(fromdir != sortdir) // probably came from the negdir + if(divert_check(sortTag)) + return sortdir + else return posdir + else // came from sortdir + // so go with the flow to positive direction + return posdir + +/obj/structure/disposalpipe/sortjunction/transfer(var/obj/structure/disposalholder/H) + var/nextdir = nextdir(H.dir, H.destinationTag) + H.set_dir(nextdir) + var/turf/T = H.nextloc() + var/obj/structure/disposalpipe/P = H.findpipe(T) + + if(P) + // find other holder in next loc, if inactive merge it with current + var/obj/structure/disposalholder/H2 = locate() in P + if(H2 && !H2.active) + H.merge(H2) + + H.forceMove(P) + else // if wasn't a pipe, then set loc to turf + H.forceMove(T) + return null - transfer(var/obj/structure/disposalholder/H) - var/nextdir = nextdir(H.dir, H.destinationTag) - H.set_dir(nextdir) - var/turf/T = H.nextloc() - var/obj/structure/disposalpipe/P = H.findpipe(T) - - if(P) - // find other holder in next loc, if inactive merge it with current - var/obj/structure/disposalholder/H2 = locate() in P - if(H2 && !H2.active) - H.merge(H2) - - H.forceMove(P) - else // if wasn't a pipe, then set loc to turf - H.forceMove(T) - return null - - return P + return P //a three-way junction that filters all wrapped and tagged items /obj/structure/disposalpipe/sortjunction/wildcard @@ -1442,59 +1442,59 @@ // expel the contents of the holder object, then delete it // called when the holder exits the outlet - proc/expel(var/obj/structure/disposalholder/H) +/obj/structure/disposaloutlet/proc/expel(var/obj/structure/disposalholder/H) - flick("outlet-open", src) - playsound(src, 'sound/machines/warning-buzzer.ogg', 50, 0, 0) - sleep(20) //wait until correct animation frame - playsound(src, 'sound/machines/hiss.ogg', 50, 0, 0) + flick("outlet-open", src) + playsound(src, 'sound/machines/warning-buzzer.ogg', 50, 0, 0) + sleep(20) //wait until correct animation frame + playsound(src, 'sound/machines/hiss.ogg', 50, 0, 0) - if(H) - for(var/atom/movable/AM in H) - AM.forceMove(src.loc) - AM.pipe_eject(dir) - if(!istype(AM,/mob/living/silicon/robot/drone)) //Drones keep smashing windows from being fired out of chutes. Bad for the station. ~Z - spawn(5) - AM.throw_at(target, 3, 1) - H.vent_gas(src.loc) - qdel(H) + if(H) + for(var/atom/movable/AM in H) + AM.forceMove(src.loc) + AM.pipe_eject(dir) + if(!istype(AM,/mob/living/silicon/robot/drone)) //Drones keep smashing windows from being fired out of chutes. Bad for the station. ~Z + spawn(5) + AM.throw_at(target, 3, 1) + H.vent_gas(src.loc) + qdel(H) return - attackby(var/obj/item/I, var/mob/user) - if(!I || !user) +/obj/structure/disposaloutlet/attackby(var/obj/item/I, var/mob/user) + if(!I || !user) + return + src.add_fingerprint(user) + if(istype(I, /obj/item/weapon/screwdriver)) + if(mode==0) + mode=1 + playsound(src.loc, 'sound/items/Screwdriver.ogg', 50, 1) + user << "You remove the screws around the power connection." + return + else if(mode==1) + mode=0 + playsound(src.loc, 'sound/items/Screwdriver.ogg', 50, 1) + user << "You attach the screws around the power connection." + return + else if(istype(I,/obj/item/weapon/weldingtool) && mode==1) + var/obj/item/weapon/weldingtool/W = I + if(W.remove_fuel(0,user)) + playsound(src.loc, 'sound/items/Welder2.ogg', 100, 1) + user << "You start slicing the floorweld off the disposal outlet." + if(do_after(user,20, src)) + if(!src || !W.isOn()) return + user << "You sliced the floorweld off the disposal outlet." + var/obj/structure/disposalconstruct/C = new (src.loc) + src.transfer_fingerprints_to(C) + C.pipe_type = PIPE_TYPE_OUTLET + C.update() + C.anchored = 1 + C.density = 1 + qdel(src) + return + else + user << "You need more welding fuel to complete this task." return - src.add_fingerprint(user) - if(istype(I, /obj/item/weapon/screwdriver)) - if(mode==0) - mode=1 - playsound(src.loc, 'sound/items/Screwdriver.ogg', 50, 1) - user << "You remove the screws around the power connection." - return - else if(mode==1) - mode=0 - playsound(src.loc, 'sound/items/Screwdriver.ogg', 50, 1) - user << "You attach the screws around the power connection." - return - else if(istype(I,/obj/item/weapon/weldingtool) && mode==1) - var/obj/item/weapon/weldingtool/W = I - if(W.remove_fuel(0,user)) - playsound(src.loc, 'sound/items/Welder2.ogg', 100, 1) - user << "You start slicing the floorweld off the disposal outlet." - if(do_after(user,20, src)) - if(!src || !W.isOn()) return - user << "You sliced the floorweld off the disposal outlet." - var/obj/structure/disposalconstruct/C = new (src.loc) - src.transfer_fingerprints_to(C) - C.ptype = 7 // 7 = outlet - C.update() - C.anchored = 1 - C.density = 1 - qdel(src) - return - else - user << "You need more welding fuel to complete this task." - return // called when movable is expelled from a disposal pipe or outlet // by default does nothing, override for special behaviour diff --git a/code/modules/recycling/sortingmachinery.dm b/code/modules/recycling/sortingmachinery.dm index 07e0325e9ef..7504ae38144 100644 --- a/code/modules/recycling/sortingmachinery.dm +++ b/code/modules/recycling/sortingmachinery.dm @@ -455,7 +455,7 @@ if(!src || !W.isOn()) return user << "You sliced the floorweld off the delivery chute." var/obj/structure/disposalconstruct/C = new (src.loc) - C.ptype = 8 // 8 = Delivery chute + C.pipe_type = PIPE_TYPE_INTAKE C.update() C.anchored = 1 C.density = 1 From 39016fd7bd1fcfbced5f0f23af21901ee9150078 Mon Sep 17 00:00:00 2001 From: Camper12345 Date: Wed, 5 Apr 2017 20:30:12 +0400 Subject: [PATCH 2/6] Disposals fix 2 - Disposal chute can now throw things - Some refactoring --- code/__defines/machinery.dm | 21 ++ code/game/machinery/pipe/pipe_dispenser.dm | 36 +-- .../recycling/disposal-construction.dm | 22 +- code/modules/recycling/disposal.dm | 257 +++++++++--------- code/modules/recycling/sortingmachinery.dm | 3 + 5 files changed, 174 insertions(+), 165 deletions(-) diff --git a/code/__defines/machinery.dm b/code/__defines/machinery.dm index 0cfba50819e..cb2d0567a97 100644 --- a/code/__defines/machinery.dm +++ b/code/__defines/machinery.dm @@ -95,3 +95,24 @@ var/list/restricted_camera_networks = list(NETWORK_MERCENARY,"Secret") #define ATMOS_DEFAULT_VOLUME_FILTER 200 // L. #define ATMOS_DEFAULT_VOLUME_MIXER 200 // L. #define ATMOS_DEFAULT_VOLUME_PIPE 70 // L. + +//Disposal pipes +#define PIPE_TYPE_STRAIGHT 0 +#define PIPE_TYPE_BENT 1 +#define PIPE_TYPE_JUNC 2 +#define PIPE_TYPE_JUNC_FLIP 3 +#define PIPE_TYPE_JUNC_Y 4 +#define PIPE_TYPE_TRUNK 5 +#define PIPE_TYPE_BIN 6 +#define PIPE_TYPE_OUTLET 7 +#define PIPE_TYPE_INTAKE 8 +#define PIPE_TYPE_JUNC_SORT 9 +#define PIPE_TYPE_JUNC_SORT_FLIP 10 +#define PIPE_TYPE_UP 11 +#define PIPE_TYPE_DOWN 12 +#define PIPE_TYPE_TAGGER 13 +#define PIPE_TYPE_TAGGER_PART 14 + +#define SORT_TYPE_NORMAL 0 +#define SORT_TYPE_WILDCARD 1 +#define SORT_TYPE_UNTAGGED 2 diff --git a/code/game/machinery/pipe/pipe_dispenser.dm b/code/game/machinery/pipe/pipe_dispenser.dm index 470b172bb7d..0f74db9918a 100644 --- a/code/game/machinery/pipe/pipe_dispenser.dm +++ b/code/game/machinery/pipe/pipe_dispenser.dm @@ -207,42 +207,42 @@ Nah var/obj/structure/disposalconstruct/C = new (src.loc) switch(p_type) if(0) - C.pipe_type = 0 + C.pipe_type = PIPE_TYPE_STRAIGHT if(1) - C.pipe_type = 1 + C.pipe_type = PIPE_TYPE_BENT if(2) - C.pipe_type = 2 + C.pipe_type = PIPE_TYPE_JUNC if(3) - C.pipe_type = 4 + C.pipe_type = PIPE_TYPE_JUNC_Y if(4) - C.pipe_type = 5 + C.pipe_type = PIPE_TYPE_TRUNK if(5) - C.pipe_type = 6 + C.pipe_type = PIPE_TYPE_BIN C.density = 1 if(6) - C.pipe_type = 7 + C.pipe_type = PIPE_TYPE_OUTLET C.density = 1 if(7) - C.pipe_type = 8 + C.pipe_type = PIPE_TYPE_INTAKE C.density = 1 if(8) - C.pipe_type = 9 - C.sort_type = 0 + C.pipe_type = PIPE_TYPE_JUNC_SORT + C.sort_type = SORT_TYPE_NORMAL if(9) - C.pipe_type = 9 - C.sort_type = 1 + C.pipe_type = PIPE_TYPE_JUNC_SORT + C.sort_type = SORT_TYPE_WILDCARD if(10) - C.pipe_type = 9 - C.sort_type = 2 + C.pipe_type = PIPE_TYPE_JUNC_SORT + C.sort_type = SORT_TYPE_UNTAGGED if(11) - C.pipe_type = 13 + C.pipe_type = PIPE_TYPE_TAGGER if(12) - C.pipe_type = 14 + C.pipe_type = PIPE_TYPE_TAGGER_PART ///// Z-Level stuff if(21) - C.pipe_type = 11 + C.pipe_type = PIPE_TYPE_UP if(22) - C.pipe_type = 12 + C.pipe_type = PIPE_TYPE_DOWN ///// Z-Level stuff C.add_fingerprint(usr) C.update() diff --git a/code/modules/recycling/disposal-construction.dm b/code/modules/recycling/disposal-construction.dm index e766f59e8e2..5f8eaa6bdc9 100644 --- a/code/modules/recycling/disposal-construction.dm +++ b/code/modules/recycling/disposal-construction.dm @@ -1,26 +1,6 @@ // Disposal pipe construction // This is the pipe that you drag around, not the attached ones. -#define PIPE_TYPE_STRAIGHT 0 -#define PIPE_TYPE_BENT 1 -#define PIPE_TYPE_JUNC 2 -#define PIPE_TYPE_JUNC_FLIP 3 -#define PIPE_TYPE_JUNC_Y 4 -#define PIPE_TYPE_TRUNK 5 -#define PIPE_TYPE_BIN 6 -#define PIPE_TYPE_OUTLET 7 -#define PIPE_TYPE_INTAKE 8 -#define PIPE_TYPE_JUNC_SORT 9 -#define PIPE_TYPE_JUNC_SORT_FLIP 10 -#define PIPE_TYPE_UP 11 -#define PIPE_TYPE_DOWN 12 -#define PIPE_TYPE_TAGGER 13 -#define PIPE_TYPE_TAGGER_PART 14 - -#define SORT_TYPE_NORMAL 0 -#define SORT_TYPE_WILDCARD 1 -#define SORT_TYPE_UNTAGGED 2 - /obj/structure/disposalconstruct name = "disposal pipe segment" @@ -31,7 +11,7 @@ density = 0 matter = list(DEFAULT_WALL_MATERIAL = 1850) level = 2 - var/sortType = "" + var/sortType = list() var/pipe_type = 0 var/sort_type = 0 var/dpdir = 0 // directions as disposalpipe diff --git a/code/modules/recycling/disposal.dm b/code/modules/recycling/disposal.dm index 025e11e22ee..c80554f0d76 100644 --- a/code/modules/recycling/disposal.dm +++ b/code/modules/recycling/disposal.dm @@ -442,13 +442,16 @@ // called when holder is expelled from a disposal // should usually only occur if the pipe network is modified +/obj/machinery/disposal/proc/get_eject_turf() + get_offset_target_turf(src.loc, rand(5)-rand(5), rand(5)-rand(5)) + /obj/machinery/disposal/proc/expel(var/obj/structure/disposalholder/H) var/turf/target playsound(src, 'sound/machines/hiss.ogg', 50, 0, 0) if(H) // Somehow, someone managed to flush a window which broke mid-transit and caused the disposal to go in an infinite loop trying to expel null, hopefully this fixes it for(var/atom/movable/AM in H) - target = get_offset_target_turf(src.loc, rand(5)-rand(5), rand(5)-rand(5)) + target = get_eject_turf() AM.forceMove(src.loc) AM.pipe_eject(0) @@ -495,146 +498,146 @@ // initialize a holder from the contents of a disposal unit - proc/init(var/obj/machinery/disposal/D, var/datum/gas_mixture/flush_gas) - gas = flush_gas// transfer gas resv. into holder object -- let's be explicit about the data this proc consumes, please. - - //Check for any living mobs trigger hasmob. - //hasmob effects whether the package goes to cargo or its tagged destination. - for(var/mob/living/M in D) - if(M && M.stat != 2 && !istype(M,/mob/living/silicon/robot/drone)) - hasmob = 1 - - //Checks 1 contents level deep. This means that players can be sent through disposals... - //...but it should require a second person to open the package. (i.e. person inside a wrapped locker) - for(var/obj/O in D) - if(O.contents) - for(var/mob/living/M in O.contents) - if(M && M.stat != 2 && !istype(M,/mob/living/silicon/robot/drone)) - hasmob = 1 - - // now everything inside the disposal gets put into the holder - // note AM since can contain mobs or objs - for(var/atom/movable/AM in D) - AM.forceMove(src) - if(istype(AM, /obj/structure/bigDelivery) && !hasmob) - var/obj/structure/bigDelivery/T = AM - src.destinationTag = T.sortTag - if(istype(AM, /obj/item/smallDelivery) && !hasmob) - var/obj/item/smallDelivery/T = AM - src.destinationTag = T.sortTag - //Drones can mail themselves through maint. - if(istype(AM, /mob/living/silicon/robot/drone)) - var/mob/living/silicon/robot/drone/drone = AM - src.destinationTag = drone.mail_destination +/obj/structure/disposalholder/proc/init(var/obj/machinery/disposal/D, var/datum/gas_mixture/flush_gas) + gas = flush_gas// transfer gas resv. into holder object -- let's be explicit about the data this proc consumes, please. + + //Check for any living mobs trigger hasmob. + //hasmob effects whether the package goes to cargo or its tagged destination. + for(var/mob/living/M in D) + if(M && M.stat != 2 && !istype(M,/mob/living/silicon/robot/drone)) + hasmob = 1 + + //Checks 1 contents level deep. This means that players can be sent through disposals... + //...but it should require a second person to open the package. (i.e. person inside a wrapped locker) + for(var/obj/O in D) + if(O.contents) + for(var/mob/living/M in O.contents) + if(M && M.stat != 2 && !istype(M,/mob/living/silicon/robot/drone)) + hasmob = 1 + + // now everything inside the disposal gets put into the holder + // note AM since can contain mobs or objs + for(var/atom/movable/AM in D) + AM.forceMove(src) + if(istype(AM, /obj/structure/bigDelivery) && !hasmob) + var/obj/structure/bigDelivery/T = AM + src.destinationTag = T.sortTag + if(istype(AM, /obj/item/smallDelivery) && !hasmob) + var/obj/item/smallDelivery/T = AM + src.destinationTag = T.sortTag + //Drones can mail themselves through maint. + if(istype(AM, /mob/living/silicon/robot/drone)) + var/mob/living/silicon/robot/drone/drone = AM + src.destinationTag = drone.mail_destination // start the movement process // argument is the disposal unit the holder started in - proc/start(var/obj/machinery/disposal/D) - if(!D.trunk) - D.expel(src) // no trunk connected, so expel immediately - return +/obj/structure/disposalholder/proc/start(var/obj/machinery/disposal/D) + if(!D.trunk) + D.expel(src) // no trunk connected, so expel immediately + return - forceMove(D.trunk) - active = 1 - set_dir(DOWN) - spawn(1) - move() // spawn off the movement process + forceMove(D.trunk) + active = 1 + set_dir(DOWN) + spawn(1) + move() // spawn off the movement process - return + return // movement process, persists while holder is moving through pipes - proc/move() - var/obj/structure/disposalpipe/last - while(active) - sleep(1) // was 1 - if(!loc) return // check if we got GC'd +/obj/structure/disposalholder/proc/move() + var/obj/structure/disposalpipe/last + while(active) + sleep(1) // was 1 + if(!loc) return // check if we got GC'd - if(hasmob && prob(3)) - for(var/mob/living/H in src) - if(!istype(H,/mob/living/silicon/robot/drone)) //Drones use the mailing code to move through the disposal system, - H.take_overall_damage(20, 0, "Blunt Trauma")//horribly maim any living creature jumping down disposals. c'est la vie + if(hasmob && prob(3)) + for(var/mob/living/H in src) + if(!istype(H,/mob/living/silicon/robot/drone)) //Drones use the mailing code to move through the disposal system, + H.take_overall_damage(20, 0, "Blunt Trauma")//horribly maim any living creature jumping down disposals. c'est la vie - var/obj/structure/disposalpipe/curr = loc - last = curr - curr = curr.transfer(src) + var/obj/structure/disposalpipe/curr = loc + last = curr + curr = curr.transfer(src) - if(!loc) return //side effects + if(!loc) return //side effects - if(!curr) - last.expel(src, loc, dir) + if(!curr) + last.expel(src, loc, dir) - // - if(!(count--)) - active = 0 - return + // + if(!(count--)) + active = 0 + return // find the turf which should contain the next pipe - proc/nextloc() - return get_step(loc,dir) +/obj/structure/disposalholder/proc/nextloc() + return get_step(loc,dir) // find a matching pipe on a turf - proc/findpipe(var/turf/T) +/obj/structure/disposalholder/proc/findpipe(var/turf/T) - if(!T) - return null - - var/fdir = turn(dir, 180) // flip the movement direction - for(var/obj/structure/disposalpipe/P in T) - if(fdir & P.dpdir) // find pipe direction mask that matches flipped dir - return P - // if no matching pipe, return null + if(!T) return null + var/fdir = turn(dir, 180) // flip the movement direction + for(var/obj/structure/disposalpipe/P in T) + if(fdir & P.dpdir) // find pipe direction mask that matches flipped dir + return P + // if no matching pipe, return null + return null + // merge two holder objects // used when a a holder meets a stuck holder - proc/merge(var/obj/structure/disposalholder/other) - for(var/atom/movable/AM in other) - AM.forceMove(src) // move everything in other holder to this one - if(ismob(AM)) - var/mob/M = AM - if(M.client) // if a client mob, update eye to follow this holder - M.client.eye = src +/obj/structure/disposalholder/proc/merge(var/obj/structure/disposalholder/other) + for(var/atom/movable/AM in other) + AM.forceMove(src) // move everything in other holder to this one + if(ismob(AM)) + var/mob/M = AM + if(M.client) // if a client mob, update eye to follow this holder + M.client.eye = src - qdel(other) + qdel(other) - proc/settag(var/new_tag) - destinationTag = new_tag +/obj/structure/disposalholder/proc/settag(var/new_tag) + destinationTag = new_tag - proc/setpartialtag(var/new_tag) - if(partialTag == new_tag) - destinationTag = new_tag - partialTag = "" - else - partialTag = new_tag +/obj/structure/disposalholder/proc/setpartialtag(var/new_tag) + if(partialTag == new_tag) + destinationTag = new_tag + partialTag = "" + else + partialTag = new_tag // called when player tries to move while in a pipe - relaymove(mob/user as mob) +/obj/structure/disposalholder/relaymove(mob/user as mob) - if(!istype(user,/mob/living)) - return + if(!istype(user,/mob/living)) + return - var/mob/living/U = user + var/mob/living/U = user - if (U.stat || U.last_special <= world.time) - return + if (U.stat || U.last_special <= world.time) + return - U.last_special = world.time+100 + U.last_special = world.time+100 - if (src.loc) - for (var/mob/M in hearers(src.loc.loc)) - M << "CLONG, clong!" + if (src.loc) + for (var/mob/M in hearers(src.loc.loc)) + M << "CLONG, clong!" - playsound(src.loc, 'sound/effects/clang.ogg', 50, 0, 0) + playsound(src.loc, 'sound/effects/clang.ogg', 50, 0, 0) // called to vent all gas in holder to a location - proc/vent_gas(var/atom/location) - location.assume_air(gas) // vent all gas to turf - return +/obj/structure/disposalholder/proc/vent_gas(var/atom/location) + location.assume_air(gas) // vent all gas to turf + return /obj/structure/disposalholder/Destroy() qdel(gas) @@ -656,7 +659,7 @@ var/health = 10 // health points 0-10 layer = 2.3 // slightly lower than wires and other pipes var/base_icon_state // initial icon state on map - var/sortType = "" + var/sortType = list() var/subtype = SORT_TYPE_NORMAL // new pipe, set the icon_state as on map New() @@ -667,27 +670,27 @@ // pipe is deleted // ensure if holder is present, it is expelled - Destroy() - var/obj/structure/disposalholder/H = locate() in src - if(H) - // holder was present - H.active = 0 - var/turf/T = src.loc - if(T.density) - // deleting pipe is inside a dense turf (wall) - // this is unlikely, but just dump out everything into the turf in case - - for(var/atom/movable/AM in H) - AM.forceMove(T) - AM.pipe_eject(0) - qdel(H) - ..() - return +/obj/structure/disposalpipe/Destroy() + var/obj/structure/disposalholder/H = locate() in src + if(H) + // holder was present + H.active = 0 + var/turf/T = src.loc + if(T.density) + // deleting pipe is inside a dense turf (wall) + // this is unlikely, but just dump out everything into the turf in case - // otherwise, do normal expel from turf - if(H) - expel(H, T, 0) - ..() + for(var/atom/movable/AM in H) + AM.forceMove(T) + AM.pipe_eject(0) + qdel(H) + ..() + return + + // otherwise, do normal expel from turf + if(H) + expel(H, T, 0) + ..() // returns the direction of the next pipe object, given the entrance dir // by default, returns the bitmask of remaining directions @@ -831,7 +834,7 @@ // pipe affected by explosion -ex_act(severity) +/obj/structure/disposalpipe/ex_act(severity) switch(severity) if(1.0) @@ -995,7 +998,6 @@ ex_act(severity) var/turf/T var/obj/structure/disposalpipe/P - if(nextdir == 12) T = GetAbove(src) if(!T) @@ -1230,9 +1232,12 @@ ex_act(severity) /obj/structure/disposalpipe/sortjunction/proc/divert_check(var/checkTag) if(islist(sortType)) - return checkTag in sortType + for(var/tag in sortType) + if(tag == checkTag) + return TRUE else return checkTag == sortType + return FALSE // next direction to move // if coming in from negdir, then next is primary dir or sortdir diff --git a/code/modules/recycling/sortingmachinery.dm b/code/modules/recycling/sortingmachinery.dm index 7504ae38144..2d3a75049b1 100644 --- a/code/modules/recycling/sortingmachinery.dm +++ b/code/modules/recycling/sortingmachinery.dm @@ -431,6 +431,9 @@ update() return +/obj/machinery/disposal/deliveryChute/get_eject_turf() + return get_ranged_target_turf(src, dir, 10) + /obj/machinery/disposal/deliveryChute/attackby(var/obj/item/I, var/mob/user) if(!I || !user) return From 8958337cd9762751d238b326f6f515ad0f5abc78 Mon Sep 17 00:00:00 2001 From: Camper12345 Date: Wed, 5 Apr 2017 20:43:48 +0400 Subject: [PATCH 3/6] Magic codes fix --- code/__defines/machinery.dm | 1 + code/modules/recycling/disposal-construction.dm | 3 +-- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/code/__defines/machinery.dm b/code/__defines/machinery.dm index cb2d0567a97..66808535014 100644 --- a/code/__defines/machinery.dm +++ b/code/__defines/machinery.dm @@ -116,3 +116,4 @@ var/list/restricted_camera_networks = list(NETWORK_MERCENARY,"Secret") #define SORT_TYPE_NORMAL 0 #define SORT_TYPE_WILDCARD 1 #define SORT_TYPE_UNTAGGED 2 + diff --git a/code/modules/recycling/disposal-construction.dm b/code/modules/recycling/disposal-construction.dm index 5f8eaa6bdc9..c9b7c9dcba1 100644 --- a/code/modules/recycling/disposal-construction.dm +++ b/code/modules/recycling/disposal-construction.dm @@ -78,9 +78,8 @@ base_state = "pipe-tagger-partial" dpdir = dir | flip - ///// Z-Level stuff - if(!(pipe_type in list(6, 7, 8, 11, 12, 13, 14))) + if(!(pipe_type in list(PIPE_TYPE_BIN, PIPE_TYPE_OUTLET, PIPE_TYPE_INTAKE, PIPE_TYPE_UP, PIPE_TYPE_DOWN, PIPE_TYPE_TAGGER, PIPE_TYPE_TAGGER_PART))) ///// Z-Level stuff icon_state = "con[base_state]" else From ff7741f0a33373f4f03f8d4b7c5c7d750272fa5b Mon Sep 17 00:00:00 2001 From: Camper12345 Date: Thu, 6 Apr 2017 15:57:16 +0400 Subject: [PATCH 4/6] More refactoring --- code/game/machinery/pipe/pipe_dispenser.dm | 8 +- .../recycling/disposal-construction.dm | 198 +++++++++--------- code/modules/recycling/disposal.dm | 80 +++---- 3 files changed, 145 insertions(+), 141 deletions(-) diff --git a/code/game/machinery/pipe/pipe_dispenser.dm b/code/game/machinery/pipe/pipe_dispenser.dm index 0f74db9918a..c6c4371cacc 100644 --- a/code/game/machinery/pipe/pipe_dispenser.dm +++ b/code/game/machinery/pipe/pipe_dispenser.dm @@ -82,9 +82,9 @@ src.add_fingerprint(usr) if(href_list["make"]) if(!wait) - var/p_type = text2num(href_list["make"]) + var/pipe_type = text2num(href_list["make"]) var/p_dir = text2num(href_list["dir"]) - var/obj/item/pipe/P = new (/*usr.loc*/ src.loc, pipe_type=p_type, dir=p_dir) + var/obj/item/pipe/P = new (/*usr.loc*/ src.loc, pipe_type=pipe_type, dir=p_dir) P.update() P.add_fingerprint(usr) wait = 1 @@ -203,9 +203,9 @@ Nah usr << browse(null, "window=pipedispenser") return if(!wait) - var/p_type = text2num(href_list["dmake"]) + var/pipe_type = text2num(href_list["dmake"]) var/obj/structure/disposalconstruct/C = new (src.loc) - switch(p_type) + switch(pipe_type) if(0) C.pipe_type = PIPE_TYPE_STRAIGHT if(1) diff --git a/code/modules/recycling/disposal-construction.dm b/code/modules/recycling/disposal-construction.dm index c9b7c9dcba1..7d234275176 100644 --- a/code/modules/recycling/disposal-construction.dm +++ b/code/modules/recycling/disposal-construction.dm @@ -14,87 +14,87 @@ var/sortType = list() var/pipe_type = 0 var/sort_type = 0 - var/dpdir = 0 // directions as disposalpipe + var/pipe_dir = 0 // directions as disposalpipe var/base_state = "pipe-s" - // update iconstate and dpdir due to dir and type - proc/update() - var/flip = turn(dir, 180) - var/left = turn(dir, 90) - var/right = turn(dir, -90) - switch(pipe_type) - if(PIPE_TYPE_STRAIGHT) - base_state = "pipe-s" - dpdir = dir | flip - if(PIPE_TYPE_BENT) - base_state = "pipe-c" - dpdir = dir | right - if(PIPE_TYPE_JUNC) - base_state = "pipe-j1" - dpdir = dir | right | flip - if(PIPE_TYPE_JUNC_FLIP) - base_state = "pipe-j2" - dpdir = dir | left | flip - if(PIPE_TYPE_JUNC_Y) - base_state = "pipe-y" - dpdir = dir | left | right - if(PIPE_TYPE_TRUNK) - base_state = "pipe-t" - dpdir = dir - // disposal bin has only one dir, thus we don't need to care about setting it - if(PIPE_TYPE_BIN) - if(anchored) - base_state = "disposal" - else - base_state = "condisposal" - - if(PIPE_TYPE_OUTLET) - base_state = "outlet" - dpdir = dir - - if(PIPE_TYPE_INTAKE) - base_state = "intake" - dpdir = dir - - if(PIPE_TYPE_JUNC_SORT) - base_state = "pipe-j1s" - dpdir = dir | right | flip - - if(PIPE_TYPE_JUNC_SORT_FLIP) - base_state = "pipe-j2s" - dpdir = dir | left | flip + // update iconstate and pipe_dir due to dir and type +/obj/structure/disposalconstruct/proc/update() + var/flip = turn(dir, 180) + var/left = turn(dir, 90) + var/right = turn(dir, -90) + switch(pipe_type) + if(PIPE_TYPE_STRAIGHT) + base_state = "pipe-s" + pipe_dir = dir | flip + if(PIPE_TYPE_BENT) + base_state = "pipe-c" + pipe_dir = dir | right + if(PIPE_TYPE_JUNC) + base_state = "pipe-j1" + pipe_dir = dir | right | flip + if(PIPE_TYPE_JUNC_FLIP) + base_state = "pipe-j2" + pipe_dir = dir | left | flip + if(PIPE_TYPE_JUNC_Y) + base_state = "pipe-y" + pipe_dir = dir | left | right + if(PIPE_TYPE_TRUNK) + base_state = "pipe-t" + pipe_dir = dir + // disposal bin has only one dir, thus we don't need to care about setting it + if(PIPE_TYPE_BIN) + if(anchored) + base_state = "disposal" + else + base_state = "condisposal" + + if(PIPE_TYPE_OUTLET) + base_state = "outlet" + pipe_dir = dir + + if(PIPE_TYPE_INTAKE) + base_state = "intake" + pipe_dir = dir + + if(PIPE_TYPE_JUNC_SORT) + base_state = "pipe-j1s" + pipe_dir = dir | right | flip + + if(PIPE_TYPE_JUNC_SORT_FLIP) + base_state = "pipe-j2s" + pipe_dir = dir | left | flip ///// Z-Level stuff - if(PIPE_TYPE_UP) - base_state = "pipe-u" - dpdir = dir - if(PIPE_TYPE_DOWN) - base_state = "pipe-d" - dpdir = dir + if(PIPE_TYPE_UP) + base_state = "pipe-u" + pipe_dir = dir + if(PIPE_TYPE_DOWN) + base_state = "pipe-d" + pipe_dir = dir ///// Z-Level stuff - if(PIPE_TYPE_TAGGER) - base_state = "pipe-tagger" - dpdir = dir | flip - if(PIPE_TYPE_TAGGER_PART) - base_state = "pipe-tagger-partial" - dpdir = dir | flip + if(PIPE_TYPE_TAGGER) + base_state = "pipe-tagger" + pipe_dir = dir | flip + if(PIPE_TYPE_TAGGER_PART) + base_state = "pipe-tagger-partial" + pipe_dir = dir | flip ///// Z-Level stuff - if(!(pipe_type in list(PIPE_TYPE_BIN, PIPE_TYPE_OUTLET, PIPE_TYPE_INTAKE, PIPE_TYPE_UP, PIPE_TYPE_DOWN, PIPE_TYPE_TAGGER, PIPE_TYPE_TAGGER_PART))) + if(!(pipe_type in list(PIPE_TYPE_BIN, PIPE_TYPE_OUTLET, PIPE_TYPE_INTAKE, PIPE_TYPE_UP, PIPE_TYPE_DOWN, PIPE_TYPE_TAGGER, PIPE_TYPE_TAGGER_PART))) ///// Z-Level stuff - icon_state = "con[base_state]" - else - icon_state = base_state + icon_state = "con[base_state]" + else + icon_state = base_state - if(invisibility) // if invisible, fade icon - alpha = 128 - else - alpha = 255 + if(invisibility) // if invisible, fade icon + alpha = 128 + else + alpha = 255 //otherwise burying half-finished pipes under floors causes them to half-fade // hide called by levelupdate if turf intact status changes // change visibility status and force update of icon /obj/structure/disposalconstruct/hide(var/intact) - invisibility = (intact && level==1) ? 101: 0 // hide if floor is intact + invisibility = (intact && level == 1) ? 101 : 0 // hide if floor is intact update() @@ -188,38 +188,38 @@ // weldingtool: convert to real pipe /obj/structure/disposalconstruct/attackby(var/obj/item/I, var/mob/user) - var/nicetype = "pipe" - var/ispipe = 0 // Indicates if we should change the level of this pipe + var/nice_type = "pipe" + var/is_pipe = FALSE // Indicates if we should change the level of this pipe src.add_fingerprint(user) switch(pipe_type) if(PIPE_TYPE_BIN) - nicetype = "disposal bin" + nice_type = "disposal bin" if(PIPE_TYPE_OUTLET) - nicetype = "disposal outlet" + nice_type = "disposal outlet" if(PIPE_TYPE_INTAKE) - nicetype = "delivery chute" + nice_type = "delivery chute" if(PIPE_TYPE_JUNC_SORT, PIPE_TYPE_JUNC_SORT_FLIP) switch(sort_type) if(SORT_TYPE_NORMAL) - nicetype = "sorting pipe" + nice_type = "sorting pipe" if(SORT_TYPE_WILDCARD) - nicetype = "wildcard sorting pipe" + nice_type = "wildcard sorting pipe" if(SORT_TYPE_UNTAGGED) - nicetype = "untagged sorting pipe" - ispipe = 1 + nice_type = "untagged sorting pipe" + is_pipe = TRUE if(PIPE_TYPE_TAGGER) - nicetype = "tagging pipe" - ispipe = 1 + nice_type = "tagging pipe" + is_pipe = TRUE if(PIPE_TYPE_TAGGER_PART) - nicetype = "partial tagging pipe" - ispipe = 1 + nice_type = "partial tagging pipe" + is_pipe = TRUE else - nicetype = "pipe" - ispipe = 1 + nice_type = "pipe" + is_pipe = TRUE var/turf/T = src.loc if(!T.is_plating()) - user << "You can only attach the [nicetype] if the floor plating is removed." + user << "You can only attach the [nice_type] if the floor plating is removed." return var/obj/structure/disposalpipe/CP = locate() in T @@ -227,38 +227,38 @@ if(istype(I, /obj/item/weapon/wrench)) if(anchored) anchored = 0 - if(ispipe) + if(is_pipe) level = 2 density = 0 else density = 1 - user << "You detach the [nicetype] from the underfloor." + user << "You detach the [nice_type] from the underfloor." else if(pipe_type in list(PIPE_TYPE_BIN, PIPE_TYPE_OUTLET, PIPE_TYPE_INTAKE)) if(CP) // There's something there if(!istype(CP,/obj/structure/disposalpipe/trunk)) - user << "The [nicetype] requires a trunk underneath it in order to work." + user << "The [nice_type] requires a trunk underneath it in order to work." return else // Nothing under, fuck. - user << "The [nicetype] requires a trunk underneath it in order to work." + user << "The [nice_type] requires a trunk underneath it in order to work." return else if(CP) update() - var/pdir = CP.dpdir + var/pdir = CP.pipe_dir if(istype(CP, /obj/structure/disposalpipe/broken)) pdir = CP.dir - if(pdir & dpdir) - user << "There is already a [nicetype] at that location." + if(pdir & pipe_dir) + user << "There is already a [nice_type] at that location." return anchored = 1 - if(ispipe) + if(is_pipe) level = 1 // We don't want disposal bins to disappear under the floors density = 0 else density = 1 // We don't want disposal bins or outlets to go density 0 - user << "You attach the [nicetype] to the underfloor." + user << "You attach the [nice_type] to the underfloor." playsound(src.loc, 'sound/items/Ratchet.ogg', 100, 1) update() @@ -267,19 +267,19 @@ var/obj/item/weapon/weldingtool/W = I if(W.remove_fuel(0,user)) playsound(src.loc, 'sound/items/Welder2.ogg', 100, 1) - user << "Welding the [nicetype] in place." + user << "Welding the [nice_type] in place." if(do_after(user, 20, src)) - if(!src || !W.isOn()) return - user << "The [nicetype] has been welded in place!" + if(!src || !W.isOn()) + return + user << "The [nice_type] has been welded in place!" update() // TODO: Make this neat - if(ispipe) // Pipe - + if(is_pipe) // Pipe var/pipetype = dpipetype() var/obj/structure/disposalpipe/P = new pipetype(src.loc) src.transfer_fingerprints_to(P) P.base_icon_state = base_state P.set_dir(dir) - P.dpdir = dpdir + P.pipe_dir = pipe_dir P.updateicon() //Needs some special treatment ;) diff --git a/code/modules/recycling/disposal.dm b/code/modules/recycling/disposal.dm index c80554f0d76..a5723732391 100644 --- a/code/modules/recycling/disposal.dm +++ b/code/modules/recycling/disposal.dm @@ -492,7 +492,7 @@ var/count = 2048 //*** can travel 2048 steps before going inactive (in case of loops) var/destinationTag = "" // changes if contains a delivery container var/tomail = 0 //changes if contains wrapped package - var/hasmob = 0 //If it contains a mob + var/has_mob = FALSE //If it contains a mob var/partialTag = "" //set by a partial tagger the first time round, then put in destinationTag if it goes through again. @@ -505,7 +505,7 @@ //hasmob effects whether the package goes to cargo or its tagged destination. for(var/mob/living/M in D) if(M && M.stat != 2 && !istype(M,/mob/living/silicon/robot/drone)) - hasmob = 1 + has_mob = TRUE //Checks 1 contents level deep. This means that players can be sent through disposals... //...but it should require a second person to open the package. (i.e. person inside a wrapped locker) @@ -513,16 +513,16 @@ if(O.contents) for(var/mob/living/M in O.contents) if(M && M.stat != 2 && !istype(M,/mob/living/silicon/robot/drone)) - hasmob = 1 + has_mob = TRUE // now everything inside the disposal gets put into the holder // note AM since can contain mobs or objs for(var/atom/movable/AM in D) AM.forceMove(src) - if(istype(AM, /obj/structure/bigDelivery) && !hasmob) + if(istype(AM, /obj/structure/bigDelivery) && !has_mob) var/obj/structure/bigDelivery/T = AM src.destinationTag = T.sortTag - if(istype(AM, /obj/item/smallDelivery) && !hasmob) + if(istype(AM, /obj/item/smallDelivery) && !has_mob) var/obj/item/smallDelivery/T = AM src.destinationTag = T.sortTag //Drones can mail themselves through maint. @@ -551,20 +551,22 @@ var/obj/structure/disposalpipe/last while(active) sleep(1) // was 1 - if(!loc) return // check if we got GC'd + if(!loc) + return // check if we got GC'd - if(hasmob && prob(3)) + if(has_mob && prob(3)) for(var/mob/living/H in src) if(!istype(H,/mob/living/silicon/robot/drone)) //Drones use the mailing code to move through the disposal system, H.take_overall_damage(20, 0, "Blunt Trauma")//horribly maim any living creature jumping down disposals. c'est la vie - var/obj/structure/disposalpipe/curr = loc - last = curr - curr = curr.transfer(src) + var/obj/structure/disposalpipe/current = loc + last = current + current = current.transfer(src) - if(!loc) return //side effects + if(!loc) + return //side effects - if(!curr) + if(!current) last.expel(src, loc, dir) // @@ -586,7 +588,7 @@ var/fdir = turn(dir, 180) // flip the movement direction for(var/obj/structure/disposalpipe/P in T) - if(fdir & P.dpdir) // find pipe direction mask that matches flipped dir + if(fdir & P.pipe_dir) // find pipe direction mask that matches flipped dir return P // if no matching pipe, return null return null @@ -654,7 +656,7 @@ density = 0 level = 1 // underfloor only - var/dpdir = 0 // bitmask of pipe directions + var/pipe_dir = 0 // bitmask of pipe directions dir = 0 // dir will contain dominant direction for junction pipes var/health = 10 // health points 0-10 layer = 2.3 // slightly lower than wires and other pipes @@ -695,7 +697,7 @@ // returns the direction of the next pipe object, given the entrance dir // by default, returns the bitmask of remaining directions /obj/structure/disposalpipe/proc/nextdir(var/fromdir) - return dpdir & (~turn(fromdir, 180)) + return pipe_dir & (~turn(fromdir, 180)) // transfer the holder through this pipe segment // overriden for special behaviour @@ -805,7 +807,7 @@ /obj/structure/disposalpipe/proc/broken(var/remains = 0) if(remains) for(var/D in cardinal) - if(D & dpdir) + if(D & pipe_dir) var/obj/structure/disposalpipe/broken/P = new(src.loc) P.set_dir(D) @@ -854,7 +856,7 @@ /obj/structure/disposalpipe/proc/healthcheck() if(health < -2) broken(0) - else if(health<1) + else if(health < 1) broken(1) return @@ -877,7 +879,8 @@ var/atom/wloc = W.loc user << "Slicing the disposal pipe." sleep(30) - if(!W.isOn()) return + if(!W.isOn()) + return if(user.loc == uloc && wloc == W.loc) welded() else @@ -967,9 +970,9 @@ New() ..() if(icon_state == "pipe-s") - dpdir = dir | turn(dir, 180) + pipe_dir = dir | turn(dir, 180) else - dpdir = dir | turn(dir, -90) + pipe_dir = dir | turn(dir, -90) update() return @@ -980,7 +983,7 @@ /obj/structure/disposalpipe/up/New() ..() - dpdir = dir + pipe_dir = dir update() return @@ -1029,7 +1032,7 @@ /obj/structure/disposalpipe/down/New() ..() - dpdir = dir + pipe_dir = dir update() return @@ -1085,11 +1088,11 @@ /obj/structure/disposalpipe/junction/New() ..() if(icon_state == "pipe-j1") - dpdir = dir | turn(dir, -90) | turn(dir,180) + pipe_dir = dir | turn(dir, -90) | turn(dir,180) else if(icon_state == "pipe-j2") - dpdir = dir | turn(dir, 90) | turn(dir,180) + pipe_dir = dir | turn(dir, 90) | turn(dir,180) else // pipe-y - dpdir = dir | turn(dir,90) | turn(dir, -90) + pipe_dir = dir | turn(dir,90) | turn(dir, -90) update() return @@ -1142,8 +1145,9 @@ /obj/structure/disposalpipe/tagger/New() . = ..() - dpdir = dir | turn(dir, 180) - if(sort_tag) tagger_locations |= sort_tag + pipe_dir = dir | turn(dir, 180) + if(sort_tag) + tagger_locations |= sort_tag updatename() updatedesc() update() @@ -1158,7 +1162,7 @@ if(O.currTag)// Tag set sort_tag = O.currTag playsound(src.loc, 'sound/machines/twobeep.ogg', 100, 1) - user << "\blue Changed tag to '[sort_tag]'." + user << "Changed tag to '[sort_tag]'." updatename() updatedesc() @@ -1205,7 +1209,7 @@ else if(icon_state == "pipe-j2s") sortdir = turn(posdir, 90) - dpdir = sortdir | posdir | negdir + pipe_dir = sortdir | posdir | negdir /obj/structure/disposalpipe/sortjunction/New() . = ..() @@ -1305,7 +1309,7 @@ /obj/structure/disposalpipe/trunk/New() ..() - dpdir = dir + pipe_dir = dir spawn(1) getlinked() @@ -1404,7 +1408,7 @@ // a broken pipe /obj/structure/disposalpipe/broken icon_state = "pipe-b" - dpdir = 0 // broken pipes have dpdir=0 so they're not found as 'real' pipes + pipe_dir = 0 // broken pipes have pipe_dir=0 so they're not found as 'real' pipes // i.e. will be treated as an empty turf desc = "A broken piece of disposal pipe." @@ -1471,22 +1475,22 @@ return src.add_fingerprint(user) if(istype(I, /obj/item/weapon/screwdriver)) - if(mode==0) - mode=1 + if(mode == 0) + mode = 1 playsound(src.loc, 'sound/items/Screwdriver.ogg', 50, 1) user << "You remove the screws around the power connection." return - else if(mode==1) - mode=0 + else if(mode == 1) + mode = 0 playsound(src.loc, 'sound/items/Screwdriver.ogg', 50, 1) user << "You attach the screws around the power connection." return - else if(istype(I,/obj/item/weapon/weldingtool) && mode==1) + else if(istype(I,/obj/item/weapon/weldingtool) && mode == 1) var/obj/item/weapon/weldingtool/W = I - if(W.remove_fuel(0,user)) + if(W.remove_fuel(0, user)) playsound(src.loc, 'sound/items/Welder2.ogg', 100, 1) user << "You start slicing the floorweld off the disposal outlet." - if(do_after(user,20, src)) + if(do_after(user, 20, src)) if(!src || !W.isOn()) return user << "You sliced the floorweld off the disposal outlet." var/obj/structure/disposalconstruct/C = new (src.loc) From 0edf317881cf4e2b5e691858c063cd3f3db815de Mon Sep 17 00:00:00 2001 From: Camper12345 Date: Thu, 6 Apr 2017 20:39:42 +0400 Subject: [PATCH 5/6] More refactoring --- code/game/machinery/pipe/pipe_dispenser.dm | 6 ++-- .../recycling/disposal-construction.dm | 8 ++--- code/modules/recycling/disposal.dm | 34 ++++++++----------- 3 files changed, 21 insertions(+), 27 deletions(-) diff --git a/code/game/machinery/pipe/pipe_dispenser.dm b/code/game/machinery/pipe/pipe_dispenser.dm index c6c4371cacc..27852d0ca9a 100644 --- a/code/game/machinery/pipe/pipe_dispenser.dm +++ b/code/game/machinery/pipe/pipe_dispenser.dm @@ -227,13 +227,13 @@ Nah C.density = 1 if(8) C.pipe_type = PIPE_TYPE_JUNC_SORT - C.sort_type = SORT_TYPE_NORMAL + C.sort_mode = SORT_TYPE_NORMAL if(9) C.pipe_type = PIPE_TYPE_JUNC_SORT - C.sort_type = SORT_TYPE_WILDCARD + C.sort_mode = SORT_TYPE_WILDCARD if(10) C.pipe_type = PIPE_TYPE_JUNC_SORT - C.sort_type = SORT_TYPE_UNTAGGED + C.sort_mode = SORT_TYPE_UNTAGGED if(11) C.pipe_type = PIPE_TYPE_TAGGER if(12) diff --git a/code/modules/recycling/disposal-construction.dm b/code/modules/recycling/disposal-construction.dm index 7d234275176..83f881ad3b5 100644 --- a/code/modules/recycling/disposal-construction.dm +++ b/code/modules/recycling/disposal-construction.dm @@ -13,7 +13,7 @@ level = 2 var/sortType = list() var/pipe_type = 0 - var/sort_type = 0 + var/sort_mode = 0 var/pipe_dir = 0 // directions as disposalpipe var/base_state = "pipe-s" @@ -154,7 +154,7 @@ if(PIPE_TYPE_INTAKE) return /obj/machinery/disposal/deliveryChute if(PIPE_TYPE_JUNC_SORT) - switch(sort_type) + switch(sort_mode) if(SORT_TYPE_NORMAL) return /obj/structure/disposalpipe/sortjunction if(SORT_TYPE_WILDCARD) @@ -162,7 +162,7 @@ if(SORT_TYPE_UNTAGGED) return /obj/structure/disposalpipe/sortjunction/untagged if(PIPE_TYPE_JUNC_SORT_FLIP) - switch(sort_type) + switch(sort_mode) if(SORT_TYPE_NORMAL) return /obj/structure/disposalpipe/sortjunction/flipped if(SORT_TYPE_WILDCARD) @@ -199,7 +199,7 @@ if(PIPE_TYPE_INTAKE) nice_type = "delivery chute" if(PIPE_TYPE_JUNC_SORT, PIPE_TYPE_JUNC_SORT_FLIP) - switch(sort_type) + switch(sort_mode) if(SORT_TYPE_NORMAL) nice_type = "sorting pipe" if(SORT_TYPE_WILDCARD) diff --git a/code/modules/recycling/disposal.dm b/code/modules/recycling/disposal.dm index a5723732391..6821716fd1d 100644 --- a/code/modules/recycling/disposal.dm +++ b/code/modules/recycling/disposal.dm @@ -504,7 +504,7 @@ //Check for any living mobs trigger hasmob. //hasmob effects whether the package goes to cargo or its tagged destination. for(var/mob/living/M in D) - if(M && M.stat != 2 && !istype(M,/mob/living/silicon/robot/drone)) + if(M && M.stat != DEAD && !istype(M,/mob/living/silicon/robot/drone)) has_mob = TRUE //Checks 1 contents level deep. This means that players can be sent through disposals... @@ -512,7 +512,7 @@ for(var/obj/O in D) if(O.contents) for(var/mob/living/M in O.contents) - if(M && M.stat != 2 && !istype(M,/mob/living/silicon/robot/drone)) + if(M && M.stat != DEAD && !istype(M,/mob/living/silicon/robot/drone)) has_mob = TRUE // now everything inside the disposal gets put into the holder @@ -539,7 +539,7 @@ return forceMove(D.trunk) - active = 1 + active = TRUE set_dir(DOWN) spawn(1) move() // spawn off the movement process @@ -571,7 +571,7 @@ // if(!(count--)) - active = 0 + active = FALSE return @@ -676,7 +676,7 @@ var/obj/structure/disposalholder/H = locate() in src if(H) // holder was present - H.active = 0 + H.active = FALSE var/turf/T = src.loc if(T.density) // deleting pipe is inside a dense turf (wall) @@ -874,14 +874,10 @@ if(W.remove_fuel(0,user)) playsound(src.loc, 'sound/items/Welder2.ogg', 100, 1) - // check if anything changed over 2 seconds - var/turf/uloc = user.loc - var/atom/wloc = W.loc user << "Slicing the disposal pipe." - sleep(30) - if(!W.isOn()) - return - if(user.loc == uloc && wloc == W.loc) + if(do_after(user, 30, src)) + if(!W.isOn()) + return welded() else user << "You must stay still while welding the pipe." @@ -922,11 +918,11 @@ C.pipe_type = PIPE_TYPE_TAGGER if("pipe-tagger-partial") C.pipe_type = PIPE_TYPE_TAGGER_PART - C.sort_type = src.subtype + C.sort_mode = src.subtype src.transfer_fingerprints_to(C) C.set_dir(dir) - C.density = 0 - C.anchored = 1 + C.density = FALSE + C.anchored = TRUE C.update() qdel(src) @@ -937,7 +933,7 @@ var/obj/structure/disposalholder/H = locate() in src if(H) // holder was present - H.active = 0 + H.active = FALSE var/turf/T = src.loc if(T.density) // deleting pipe is inside a dense turf (wall) @@ -956,7 +952,7 @@ ..() /obj/structure/disposalpipe/hides_under_flooring() - return 1 + return TRUE // *** TEST verb //client/verb/dispstop() @@ -1236,9 +1232,7 @@ /obj/structure/disposalpipe/sortjunction/proc/divert_check(var/checkTag) if(islist(sortType)) - for(var/tag in sortType) - if(tag == checkTag) - return TRUE + return checkTag in sortType else return checkTag == sortType return FALSE From 6c967ee110d57f7ff11ededdccb5181c83840547 Mon Sep 17 00:00:00 2001 From: Camper12345 Date: Thu, 6 Apr 2017 21:23:24 +0400 Subject: [PATCH 6/6] Magic directions fix --- code/modules/recycling/disposal.dm | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/code/modules/recycling/disposal.dm b/code/modules/recycling/disposal.dm index 6821716fd1d..d350437b717 100644 --- a/code/modules/recycling/disposal.dm +++ b/code/modules/recycling/disposal.dm @@ -985,10 +985,10 @@ /obj/structure/disposalpipe/up/nextdir(var/fromdir) var/nextdir - if(fromdir == 11) + if(fromdir == DOWN) nextdir = dir else - nextdir = 12 + nextdir = UP return nextdir /obj/structure/disposalpipe/up/transfer(var/obj/structure/disposalholder/H) @@ -997,7 +997,7 @@ var/turf/T var/obj/structure/disposalpipe/P - if(nextdir == 12) + if(nextdir == UP) T = GetAbove(src) if(!T) H.forceMove(loc) @@ -1034,10 +1034,10 @@ /obj/structure/disposalpipe/down/nextdir(var/fromdir) var/nextdir - if(fromdir == 12) + if(fromdir == UP) nextdir = dir else - nextdir = 11 + nextdir = DOWN return nextdir /obj/structure/disposalpipe/down/transfer(var/obj/structure/disposalholder/H) @@ -1047,7 +1047,7 @@ var/turf/T var/obj/structure/disposalpipe/P - if(nextdir == 11) + if(nextdir == DOWN) T = GetBelow(src) if(!T) H.forceMove(src.loc)