Safeguards GetAllContents and makes it throw a warning

This commit is contained in:
ninjanomnom
2017-10-19 17:44:35 -04:00
parent 72e56afc90
commit d75744f040
+5 -3
View File
@@ -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.