From 9de7b3c2cea505c451a515fe02afb3e657cc6dce Mon Sep 17 00:00:00 2001 From: Vi3trice <80771500+Vi3trice@users.noreply.github.com> Date: Sat, 7 Jan 2023 11:11:29 -0500 Subject: [PATCH] Add fail-safes to disposal sort junctions, fix looping (#20099) * Remove the weird hacky stuff and default to disposals * Update disposal.dm * That's superfluous with the other checks * Update lavaland_biodome_clown_planet.dmm * Update cyberiad.dmm * Added stack traces, split into mapload proc * Update code/modules/recycling/disposal.dm Co-authored-by: Farie82 Co-authored-by: Farie82 --- .../lavaland_biodome_clown_planet.dmm | 2 +- _maps/map_files/cyberiad/cyberiad.dmm | 23 +++++--- .../modules/mob/living/silicon/robot/robot.dm | 2 +- code/modules/recycling/disposal.dm | 54 ++++++++++++++----- code/modules/recycling/sortingmachinery.dm | 12 ++--- 5 files changed, 63 insertions(+), 30 deletions(-) diff --git a/_maps/map_files/RandomRuins/LavaRuins/lavaland_biodome_clown_planet.dmm b/_maps/map_files/RandomRuins/LavaRuins/lavaland_biodome_clown_planet.dmm index 6bf8bd85d37..6aa238fe416 100644 --- a/_maps/map_files/RandomRuins/LavaRuins/lavaland_biodome_clown_planet.dmm +++ b/_maps/map_files/RandomRuins/LavaRuins/lavaland_biodome_clown_planet.dmm @@ -82,7 +82,7 @@ /turf/simulated/floor/lubed, /area/ruin/powered/clownplanet) "ai" = ( -/obj/structure/disposalpipe/sortjunction{ +/obj/structure/disposalpipe/junction{ dir = 1 }, /turf/simulated/wall/r_wall, diff --git a/_maps/map_files/cyberiad/cyberiad.dmm b/_maps/map_files/cyberiad/cyberiad.dmm index 2d96f93e55f..0e3c730f199 100644 --- a/_maps/map_files/cyberiad/cyberiad.dmm +++ b/_maps/map_files/cyberiad/cyberiad.dmm @@ -31076,7 +31076,7 @@ pixel_x = -3; pixel_y = 7 }, -/obj/structure/disposalpipe/junction{ +/obj/structure/disposalpipe/segment{ dir = 4 }, /turf/simulated/floor/plasteel{ @@ -75511,11 +75511,7 @@ }, /area/toxins/hallway) "kCk" = ( -/obj/structure/disposalpipe/sortjunction{ - dir = 1; - icon_state = "pipe-j2s"; - name = "Cargo Disposals" - }, +/obj/structure/disposalpipe/segment/corner, /turf/simulated/floor/plasteel, /area/quartermaster/office) "kDl" = ( @@ -80651,6 +80647,19 @@ icon_state = "whitepurple" }, /area/toxins/misc_lab) +"oFy" = ( +/obj/machinery/door/airlock/maintenance{ + req_access_txt = "12" + }, +/obj/structure/cable{ + d1 = 1; + d2 = 2; + icon_state = "1-2" + }, +/obj/machinery/atmospherics/pipe/simple/hidden/cyan, +/obj/structure/disposalpipe/segment, +/turf/simulated/floor/plating, +/area/maintenance/asmaint) "oFK" = ( /obj/machinery/light{ dir = 8 @@ -143015,7 +143024,7 @@ ciY ciY eaT kmA -hyf +oFy ldn ldn dIQ diff --git a/code/modules/mob/living/silicon/robot/robot.dm b/code/modules/mob/living/silicon/robot/robot.dm index 31baf65f7dc..1d7be7c8539 100644 --- a/code/modules/mob/living/silicon/robot/robot.dm +++ b/code/modules/mob/living/silicon/robot/robot.dm @@ -114,7 +114,7 @@ GLOBAL_LIST_INIT(robot_verbs_default, list( var/see_reagents = FALSE // Determines if the cyborg can see reagents /// Integer used to determine self-mailing location, used only by drones and saboteur borgs - var/mail_destination = 0 + var/mail_destination = 1 /mob/living/silicon/robot/get_cell() return cell diff --git a/code/modules/recycling/disposal.dm b/code/modules/recycling/disposal.dm index f5391739177..abac0d2f31c 100644 --- a/code/modules/recycling/disposal.dm +++ b/code/modules/recycling/disposal.dm @@ -526,7 +526,8 @@ dir = 0 var/count = 1000 //*** can travel 1000 steps before going inactive (in case of loops) var/has_fat_guy = 0 // true if contains a fat person - var/destinationTag = 0 // changes if contains a delivery container + /// Destination the holder is set to, defaulting to disposals and changes if the contents have a mail/sort tag. + var/destinationTag = 1 var/tomail = 0 //changes if contains wrapped package var/hasmob = 0 //If it contains a mob @@ -1016,7 +1017,7 @@ /obj/structure/disposalpipe/sortjunction name = "disposal sort junction" icon_state = "pipe-j1s" - var/sort_type = list() + var/list/sort_type = list(1) var/sort_type_txt //Look at the list called TAGGERLOCATIONS in /code/_globalvars/lists/flavor_misc.dm and cry var/posdir = 0 var/negdir = 0 @@ -1040,16 +1041,37 @@ /obj/structure/disposalpipe/sortjunction/Initialize(mapload) . = ..() updatedir() - if(sort_type_txt) - var/list/sort_type_str = splittext(sort_type_txt, ";") - for(var/x in sort_type_str) - var/n = text2num(x) - if(n) - sort_type += n + if(mapload) + parse_sort_destinations() update_appearance(UPDATE_DESC) update() return +/obj/structure/disposalpipe/sortjunction/proc/parse_sort_destinations() + if(sort_type_txt == "1") + return + + var/list/sort_type_str = splittext(sort_type_txt, ";") + var/mapping_fail + + if(length(sort_type_str)) // Default to disposals if mapped with it along other destinations + if("1" in sort_type_str) + mapping_fail = "Mutually exclusive sort types in sort_type_txt" + else + var/new_sort_type = list() + for(var/x in sort_type_str) + var/n = text2num(x) + if(n) + new_sort_type |= n + if(length(new_sort_type)) + sort_type = new_sort_type + else + mapping_fail = "No sort types after parsing sort_type_txt" + else + mapping_fail = "Sort_type_txt is empty" + if(mapping_fail) + stack_trace("[src] mapped incorrectly at [x],[y],[z] - [mapping_fail]") + /obj/structure/disposalpipe/sortjunction/attackby(obj/item/I, mob/user, params) if(..()) return @@ -1058,19 +1080,25 @@ var/obj/item/destTagger/O = I var/tag = uppertext(GLOB.TAGGERLOCATIONS[O.currTag]) playsound(loc, 'sound/machines/twobeep.ogg', 100, 1) - if(O.currTag in sort_type) - sort_type -= O.currTag + if(O.currTag == 1) + sort_type = list(1) + to_chat(user, "Filter set to [tag] only.") + else if(O.currTag in sort_type) + sort_type.Remove(O.currTag) to_chat(user, "Removed [tag] from filter.") + if(!length(sort_type)) + sort_type.Add(1) // Default to Disposals if everything is removed. + to_chat(user, "Filter defaulting to [uppertext(GLOB.TAGGERLOCATIONS[1])].") else - sort_type |= O.currTag + if(1 in sort_type) // Remove Disposals if a destination is added. + sort_type.Remove(1) + sort_type.Add(O.currTag) to_chat(user, "Added [tag] to filter.") update_appearance(UPDATE_NAME|UPDATE_DESC) /obj/structure/disposalpipe/sortjunction/update_name() . = ..() name = initial(name) - if(!length(sort_type)) - return if(length(sort_type) == 1) name += " - [GLOB.TAGGERLOCATIONS[sort_type[1]]]" return diff --git a/code/modules/recycling/sortingmachinery.dm b/code/modules/recycling/sortingmachinery.dm index 6116f7f2e2c..5038cc1309f 100644 --- a/code/modules/recycling/sortingmachinery.dm +++ b/code/modules/recycling/sortingmachinery.dm @@ -8,7 +8,7 @@ var/obj/wrapped = null var/init_welded = FALSE var/giftwrapped = FALSE - var/sortTag = 0 + var/sortTag = 1 /obj/structure/bigDelivery/Destroy() var/turf/T = get_turf(src) @@ -81,7 +81,7 @@ icon_state = "deliverycrate2" var/obj/item/wrapped = null var/giftwrapped = FALSE - var/sortTag = 0 + var/sortTag = 1 /obj/item/smallDelivery/ex_act(severity) for(var/atom/movable/AM in contents) @@ -307,15 +307,11 @@ // travels through the pipes. for(var/obj/structure/bigDelivery/O in src) deliveryCheck = 1 - if(O.sortTag == 0) - O.sortTag = 1 for(var/obj/item/smallDelivery/O in src) deliveryCheck = 1 - if(O.sortTag == 0) - O.sortTag = 1 for(var/obj/item/shippingPackage/O in src) deliveryCheck = 1 - if(!O.sealed || O.sortTag == 0) //unsealed or untagged shipping packages will default to disposals + if(!O.sealed) //unsealed shipping packages will default to disposals O.sortTag = 1 if(deliveryCheck == 0) H.destinationTag = 1 @@ -367,7 +363,7 @@ icon = 'icons/obj/storage.dmi' icon_state = "shippack" var/obj/item/wrapped = null - var/sortTag = 0 + var/sortTag = 1 var/sealed = 0 /obj/item/shippingPackage/attackby(obj/item/O, mob/user, params)