Fixes communication being nearly impossible (except over radio) when there's a null client in the global player list (#70404)

This commit is contained in:
GoldenAlpharex
2022-10-13 21:31:48 -07:00
committed by GitHub
parent 989922f5cf
commit c7408b32f2
4 changed files with 24 additions and 8 deletions
@@ -181,7 +181,11 @@
// Add observers who have ghost radio enabled.
for(var/mob/dead/observer/ghost in GLOB.player_list)
if(ghost.client.prefs?.chat_toggles & CHAT_GHOSTRADIO)
if(ghost.client && !ghost.client.prefs)
stack_trace("[ghost] ([ghost.ckey]) had null prefs, which shouldn't be possible!")
continue
if(ghost.client?.prefs.chat_toggles & CHAT_GHOSTRADIO)
receive |= ghost
// Render the message and have everybody hear it.
+4
View File
@@ -344,6 +344,10 @@ GLOBAL_LIST_INIT(message_modes_stat_limits, list(
if(player_mob.stat != DEAD) //not dead, not important
continue
if(player_mob.z != z || get_dist(player_mob, src) > 7) //they're out of range of normal hearing
if(player_mob.client && !player_mob.client?.prefs)
stack_trace("[player_mob] ([player_mob.ckey]) had null prefs, which shouldn't be possible!")
continue
if(eavesdrop_range)
if(!(player_mob.client?.prefs.chat_toggles & CHAT_GHOSTWHISPER)) //they're whispering and we have hearing whispers at any range off
continue
+8 -4
View File
@@ -148,11 +148,15 @@
// If there is no single listener, broadcast to everyone in the same z level
if(!only_listener)
// Play voice for all mobs in the z level
for(var/mob/M in GLOB.player_list)
if(M.can_hear() && (M.client?.prefs.toggles & SOUND_ANNOUNCEMENTS))
var/turf/T = get_turf(M)
for(var/mob/player_mob in GLOB.player_list)
if(player_mob.client && !player_mob.client?.prefs)
stack_trace("[player_mob] ([player_mob.ckey]) has null prefs, which shouldn't be possible!")
continue
if(player_mob.can_hear() && (player_mob.client?.prefs.toggles & SOUND_ANNOUNCEMENTS))
var/turf/T = get_turf(player_mob)
if(T.z == z_level)
SEND_SOUND(M, voice)
SEND_SOUND(player_mob, voice)
else
SEND_SOUND(only_listener, voice)
return TRUE
@@ -333,9 +333,13 @@
// Show it to ghosts
var/ghost_message = span_name("[message_data["name"]] </span><span class='game say'>[rigged ? "Rigged" : ""] PDA Message</span> --> [span_name("[signal.format_target()]")]: <span class='message'>[signal.format_message()]")
for(var/mob/M in GLOB.player_list)
if(isobserver(M) && (M.client?.prefs.chat_toggles & CHAT_GHOSTPDA))
to_chat(M, "[FOLLOW_LINK(M, user)] [ghost_message]")
for(var/mob/player_mob in GLOB.player_list)
if(player_mob.client && !player_mob.client?.prefs)
stack_trace("[player_mob] ([player_mob.ckey]) had null prefs, which shouldn't be possible!")
continue
if(isobserver(player_mob) && (player_mob.client?.prefs.chat_toggles & CHAT_GHOSTPDA))
to_chat(player_mob, "[FOLLOW_LINK(player_mob, user)] [ghost_message]")
// Log in the talk log
user.log_talk(message, LOG_PDA, tag="[rigged ? "Rigged" : ""] PDA: [message_data["name"]] to [signal.format_target()]")