From 9a16b0386c8bc44d66b63edbb9065fa8f9525aff Mon Sep 17 00:00:00 2001 From: Ccomp5950 Date: Tue, 18 Feb 2014 06:51:45 -0600 Subject: [PATCH] Further optimizations, no need to loop through items with multiple istype checks --- code/__HELPERS/game.dm | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) diff --git a/code/__HELPERS/game.dm b/code/__HELPERS/game.dm index b9679e9c685..88426863788 100644 --- a/code/__HELPERS/game.dm +++ b/code/__HELPERS/game.dm @@ -180,20 +180,7 @@ var/list/objects = list() - var/list/obj_to_check = list() //IF SOMEONE DOESN'T HEAR SOMETHING AND ARE IN INSIDE A CONTAINER ADD IT TO THIS LIST. - obj_to_check += typesof(/obj/item/device/paicard) - obj_to_check += typesof(/obj/item/device/aicard) - obj_to_check += typesof(/obj/machinery/computer/aifixer) - for(var/obj/O in range) //Get a list of objects in hearing range. We'll check to see if any clients have their "eye" set to the object - if(istype(O, /obj/item/device/radio)) //This avoids all that bullshit with recursion. FUCK RECURSION ~Ccomp - hear += O - if(O.type in obj_to_check) - for(var/mob/living/M in O.contents) - if(!(M in hear)) - hear += M - - objects += O for(var/client/C in clients) @@ -207,9 +194,11 @@ hear += C.mob else if(!(C.mob in hear)) - if(C.mob.loc in (hear|objects)) + if(C.mob.loc && C.mob.loc in (hear|objects)) hear += C.mob - else if(C.mob.loc.loc in (hear|objects)) + else if(C.mob.loc.loc && C.mob.loc.loc in (hear|objects)) + hear += C.mob + else if(C.mob.loc.loc.loc && C.mob.loc.loc.loc in (hear|objects)) //Going a little deeper hear += C.mob