mirror of
https://github.com/ParadiseSS13/Paradise.git
synced 2026-07-20 03:25:49 +01:00
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 <farie82@users.noreply.github.com> Co-authored-by: Farie82 <farie82@users.noreply.github.com>
This commit is contained in:
@@ -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, "<span class='notice'>Filter set to [tag] only.</span>")
|
||||
else if(O.currTag in sort_type)
|
||||
sort_type.Remove(O.currTag)
|
||||
to_chat(user, "<span class='notice'>Removed [tag] from filter.</span>")
|
||||
if(!length(sort_type))
|
||||
sort_type.Add(1) // Default to Disposals if everything is removed.
|
||||
to_chat(user, "<span class='notice'>Filter defaulting to [uppertext(GLOB.TAGGERLOCATIONS[1])].</span>")
|
||||
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, "<span class='notice'>Added [tag] to filter.</span>")
|
||||
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
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user