mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-08-30 16:47:13 +01:00
Safeguards GetAllContents and makes it throw a warning
This commit is contained in:
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user