Optimized radio code broadcasting code.

Rather than calling a function on every single radio object which expensively collects hearers(in closets etc.), the proc will now instead build a list of radios. This list is then passed to another proc, which iterates through all clients in the world, and checks if the client's mob can hear the message.

Note that I did shallow testing, but deeper issues may still be present with stuff like pAIs which I wasn't able to test on my single player server. If any other problems are found, please notify me.


git-svn-id: http://tgstation13.googlecode.com/svn/trunk@4019 316c924e-a436-60f5-8080-3fe189b3f50e
This commit is contained in:
CIB123@gmail.com
2012-07-09 15:16:00 +00:00
parent ae23259f3e
commit b687b75bca
7 changed files with 80 additions and 59 deletions

View File

@@ -219,6 +219,31 @@
return hear
/proc/get_mobs_in_radio_ranges(var/list/obj/item/device/radio/radios)
// Returns a list of mobs who can hear any of the radios given in @radios
var/list/hearers = list()
// Try to find all the players who can hear the message
for(var/key in client_list)
var/client/C = client_list[key]
var/mob/M = C.mob
if(!M) continue
var/atom/ear = M.get_ear()
if(!ear) continue
// Now see if they're near any broadcasting radio
for(var/obj/item/device/radio/R in radios)
var/turf/radio_loc = get_turf(R)
if(ear in view(R.canhear_range,radio_loc))
hearers += M
break
return hearers
#define SIGN(X) ((X<0)?-1:1)
proc