diff --git a/code/__HELPERS/unsorted.dm b/code/__HELPERS/unsorted.dm index 8618c721acb..487c28851ac 100644 --- a/code/__HELPERS/unsorted.dm +++ b/code/__HELPERS/unsorted.dm @@ -414,30 +414,25 @@ Turf and target are separate in case you want to teleport some distance from a t var/y = min(world.maxy, max(1, A.y + dy)) return locate(x,y,A.z) -/* - Gets all contents of contents and returns them all in a list. -*/ -/atom/proc/GetAllContents(T, ignore_flag_1) +///Returns the src and all recursive contents as a list. +/atom/proc/GetAllContents() + . = list(src) + var/i = 0 + while(i < length(.)) + var/atom/A = .[++i] + . += A.contents + +///identical to getallcontents but returns a list of atoms of the type passed in the argument. +/atom/proc/get_all_contents_type(type) var/list/processing_list = list(src) - if(T) - . = list() - var/i = 0 - while(i < length(processing_list)) - var/atom/A = processing_list[++i] - //Byond does not allow things to be in multiple contents, or double parent-child hierarchies, so only += is needed - //This is also why we don't need to check against assembled as we go along - if (!(A.flags_1 & ignore_flag_1)) - processing_list += A.contents - if(istype(A,T)) - . += A - else - var/i = 0 - while(i < length(processing_list)) - var/atom/A = processing_list[++i] - if (!(A.flags_1 & ignore_flag_1)) - processing_list += A.contents - return processing_list + . = list() + while(length(processing_list)) + var/atom/A = processing_list[1] + processing_list.Cut(1, 2) + processing_list += A.contents + if(istype(A, type)) + . += A /atom/proc/GetAllContentsIgnoring(list/ignore_typecache) if(!length(ignore_typecache)) diff --git a/code/game/objects/structures/morgue.dm b/code/game/objects/structures/morgue.dm index e34da134664..8d91a807d85 100644 --- a/code/game/objects/structures/morgue.dm +++ b/code/game/objects/structures/morgue.dm @@ -181,7 +181,7 @@ GLOBAL_LIST_EMPTY(bodycontainers) //Let them act as spawnpoints for revenants an icon_state = "morgue1" else icon_state = "morgue2" // Dead, brainded mob. - var/list/compiled = GetAllContents(/mob/living) // Search for mobs in all contents. + var/list/compiled = get_all_contents_type(/mob/living) // Search for mobs in all contents. if(!length(compiled)) // No mobs? icon_state = "morgue3" return @@ -295,7 +295,7 @@ GLOBAL_LIST_EMPTY(crematoriums) /obj/structure/bodycontainer/crematorium/creamatorium/cremate(mob/user) var/list/icecreams = new() - for(var/i_scream in GetAllContents(/mob/living)) + for(var/i_scream in get_all_contents_type(/mob/living)) var/obj/item/food/icecream/IC = new() IC.set_cone_type("waffle") IC.add_mob_flavor(i_scream) diff --git a/code/modules/ruins/spaceruin_code/hilbertshotel.dm b/code/modules/ruins/spaceruin_code/hilbertshotel.dm index 44d79c6bf74..d70f2151fc6 100644 --- a/code/modules/ruins/spaceruin_code/hilbertshotel.dm +++ b/code/modules/ruins/spaceruin_code/hilbertshotel.dm @@ -360,7 +360,7 @@ GLOBAL_VAR_INIT(hhMysteryRoomNumber, rand(1, 999999)) . = ..() if(istype(AM, /obj/item/hilbertshotel)) relocate(AM) - var/list/obj/item/hilbertshotel/hotels = AM.GetAllContents(/obj/item/hilbertshotel) + var/list/obj/item/hilbertshotel/hotels = AM.get_all_contents_type(/obj/item/hilbertshotel) for(var/obj/item/hilbertshotel/H in hotels) if(parentSphere == H) relocate(H) @@ -399,7 +399,7 @@ GLOBAL_VAR_INIT(hhMysteryRoomNumber, rand(1, 999999)) var/mob/M = AM if(M.mind) var/stillPopulated = FALSE - var/list/currentLivingMobs = GetAllContents(/mob/living) //Got to catch anyone hiding in anything + var/list/currentLivingMobs = get_all_contents_type(/mob/living) //Got to catch anyone hiding in anything for(var/mob/living/L in currentLivingMobs) //Check to see if theres any sentient mobs left. if(L.mind) stillPopulated = TRUE