From d75744f040bfee6058fa25f63acc9cb2541d4e9e Mon Sep 17 00:00:00 2001 From: ninjanomnom Date: Thu, 19 Oct 2017 17:44:35 -0400 Subject: [PATCH] Safeguards GetAllContents and makes it throw a warning --- code/__HELPERS/unsorted.dm | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/code/__HELPERS/unsorted.dm b/code/__HELPERS/unsorted.dm index c1c7390fd5a..47306ca720b 100644 --- a/code/__HELPERS/unsorted.dm +++ b/code/__HELPERS/unsorted.dm @@ -508,14 +508,16 @@ Recursively gets all contents of contents and returns them all in a list. recursive_depth is useful if you only want a turf and everything on it (recursive_depth=1) */ -/atom/proc/GetAllContents(list/output=list(), recursive_depth=INFINITY) +/atom/proc/GetAllContents(list/output=list(), recursive_depth=199, _current_depth=0) // 200 proc calls in and we break shit . = output output += src - if(!recursive_depth) + if(_current_depth == recursive_depth) + if(_current_depth == 199) + WARNING("Get all contents reached the max recursive depth of 199. One more and we would break shit. Offending atom: [src]") return for(var/i in 1 to contents.len) var/atom/thing = contents[i] - thing.GetAllContents(output, recursive_depth-1) + thing.GetAllContents(output, recursive_depth, ++_current_depth) //Step-towards method of determining whether one atom can see another. Similar to viewers() /proc/can_see(atom/source, atom/target, length=5) // I couldnt be arsed to do actual raycasting :I This is horribly inaccurate.