Merge pull request #10692 from Citadel-Station-13/TESTING

faster get_hearers_in_view/getallcontents i guess
This commit is contained in:
Ghom
2020-01-27 21:06:52 +01:00
committed by GitHub
2 changed files with 30 additions and 50 deletions
+15 -34
View File
@@ -145,20 +145,6 @@
turfs += T
return turfs
//This is the new version of recursive_mob_check, used for say().
//The other proc was left intact because morgue trays use it.
//Sped this up again for real this time
/proc/recursive_hear_check(O)
var/list/processing_list = list(O)
. = list()
while(processing_list.len)
var/atom/A = processing_list[1]
if(A.flags_1 & HEAR_1)
. += A
processing_list.Cut(1, 2)
processing_list += A.contents
/** recursive_organ_check
* inputs: O (object to start with)
* outputs:
@@ -238,35 +224,30 @@
return found_mobs
/proc/get_hearers_in_view(R, atom/source)
// Returns a list of hearers in view(R) from source (ignoring luminosity). Used in saycode.
var/turf/T = get_turf(source)
. = list()
if(!T)
return
var/list/processing_list = list()
if (R == 0) // if the range is zero, we know exactly where to look for, we can skip view
processing_list += T.contents // We can shave off one iteration by assuming turfs cannot hear
else // A variation of get_hear inlined here to take advantage of the compiler's fastpath for obj/mob in view
var/list/processing = list()
if(R == 0)
processing += T.contents
else
var/lum = T.luminosity
T.luminosity = 6 // This is the maximum luminosity
var/list/cachedview = view(R, T)
for(var/mob/M in cachedview)
processing_list += M
for(var/obj/O in cachedview)
processing_list += O
T.luminosity = 6
var/list/cached_view = view(R, T)
for(var/mob/M in cached_view)
processing += M
for(var/obj/O in cached_view)
processing += O
T.luminosity = lum
while(processing_list.len) // recursive_hear_check inlined here
var/atom/A = processing_list[1]
var/i = 0
while(i < length(processing))
var/atom/A = processing[++i]
if(A.flags_1 & HEAR_1)
. += A
SEND_SIGNAL(A, COMSIG_ATOM_HEARER_IN_VIEW, processing_list, .)
processing_list.Cut(1, 2)
processing_list += A.contents
SEND_SIGNAL(A, COMSIG_ATOM_HEARER_IN_VIEW, processing, .)
processing += A.contents
/proc/get_mobs_in_radio_ranges(list/obj/item/radio/radios)
. = list()
+15 -16
View File
@@ -457,36 +457,35 @@ Turf and target are separate in case you want to teleport some distance from a t
/atom/proc/GetAllContents(var/T)
var/list/processing_list = list(src)
var/list/assembled = list()
if(T)
while(processing_list.len)
var/atom/A = processing_list[1]
processing_list.Cut(1, 2)
. = 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
processing_list += A.contents
if(istype(A,T))
assembled += A
. += A
else
while(processing_list.len)
var/atom/A = processing_list[1]
processing_list.Cut(1, 2)
var/i = 0
while(i < length(processing_list))
var/atom/A = processing_list[++i]
processing_list += A.contents
assembled += A
return assembled
return processing_list
/atom/proc/GetAllContentsIgnoring(list/ignore_typecache)
if(!length(ignore_typecache))
return GetAllContents()
var/list/processing = list(src)
var/list/assembled = list()
while(processing.len)
var/atom/A = processing[1]
processing.Cut(1,2)
. = list()
var/i = 0
while(i < length(processing))
var/atom/A = processing[++i]
if(!ignore_typecache[A.type])
processing += A.contents
assembled += A
return assembled
. += A
//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.