Merge pull request #3544 from Citadel-Station-13/upstream-merge-31927
[MIRROR] Safeguards GetAllContents and makes it throw a warning
This commit is contained in:
@@ -469,3 +469,5 @@ GLOBAL_LIST_INIT(ghost_others_options, list(GHOST_OTHERS_SIMPLE, GHOST_OTHERS_DE
|
|||||||
|
|
||||||
#define PR_ANNOUNCEMENTS_PER_ROUND 5 //The number of unique PR announcements allowed per round
|
#define PR_ANNOUNCEMENTS_PER_ROUND 5 //The number of unique PR announcements allowed per round
|
||||||
//This makes sure that a single person can only spam 3 reopens and 3 closes before being ignored
|
//This makes sure that a single person can only spam 3 reopens and 3 closes before being ignored
|
||||||
|
|
||||||
|
#define MAX_PROC_DEPTH 195 // 200 proc calls deep and shit breaks, this is a bit lower to give some safety room
|
||||||
@@ -503,12 +503,22 @@ Turf and target are separate in case you want to teleport some distance from a t
|
|||||||
var/y=arcsin(x/sqrt(1+x*x))
|
var/y=arcsin(x/sqrt(1+x*x))
|
||||||
return y
|
return y
|
||||||
|
|
||||||
/atom/proc/GetAllContents(list/output=list())
|
/*
|
||||||
|
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)
|
||||||
|
Do not set recursive depth higher than MAX_PROC_DEPTH as byond breaks when that limit is reached.
|
||||||
|
*/
|
||||||
|
/atom/proc/GetAllContents(list/output=list(), recursive_depth=MAX_PROC_DEPTH, _current_depth=0)
|
||||||
. = output
|
. = output
|
||||||
output += src
|
output += src
|
||||||
|
if(_current_depth == recursive_depth)
|
||||||
|
if(_current_depth == MAX_PROC_DEPTH)
|
||||||
|
WARNING("Get all contents reached the max recursive depth of [MAX_PROC_DEPTH]. More and we would break shit. Offending atom: [src]")
|
||||||
|
return
|
||||||
for(var/i in 1 to contents.len)
|
for(var/i in 1 to contents.len)
|
||||||
var/atom/thing = contents[i]
|
var/atom/thing = contents[i]
|
||||||
thing.GetAllContents(output)
|
thing.GetAllContents(output, recursive_depth, ++_current_depth)
|
||||||
|
|
||||||
//Step-towards method of determining whether one atom can see another. Similar to viewers()
|
//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.
|
/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