From 15d5272ee04017cbaed7adf3796533982896e56f Mon Sep 17 00:00:00 2001 From: SkyratBot <59378654+SkyratBot@users.noreply.github.com> Date: Fri, 14 Oct 2022 21:42:46 +0200 Subject: [PATCH] [MIRROR] Fixes communication being nearly impossible (except over radio) when there's a null client in the global player list [MDB IGNORE] (#16851) * Fixes communication being nearly impossible (except over radio) when there's a null client in the global player list (#70404) * Fixes communication being nearly impossible (except over radio) when there's a null client in the global player list * Updates our modular play_vox_word() proc Co-authored-by: GoldenAlpharex <58045821+GoldenAlpharex@users.noreply.github.com> Co-authored-by: GoldenAlpharex --- code/game/machinery/telecomms/broadcasting.dm | 6 +++++- code/modules/mob/living/living_say.dm | 4 ++++ code/modules/mob/living/silicon/ai/ai_say.dm | 12 ++++++++---- .../file_system/programs/ntmessenger.dm | 10 +++++++--- modular_skyrat/modules/alt_vox/code/vox_procs.dm | 16 +++++++++++----- 5 files changed, 35 insertions(+), 13 deletions(-) diff --git a/code/game/machinery/telecomms/broadcasting.dm b/code/game/machinery/telecomms/broadcasting.dm index f15b0de5a80..45e296aa8da 100644 --- a/code/game/machinery/telecomms/broadcasting.dm +++ b/code/game/machinery/telecomms/broadcasting.dm @@ -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. diff --git a/code/modules/mob/living/living_say.dm b/code/modules/mob/living/living_say.dm index 5bdb880f3c5..ac0ff07d6fa 100644 --- a/code/modules/mob/living/living_say.dm +++ b/code/modules/mob/living/living_say.dm @@ -349,6 +349,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 diff --git a/code/modules/mob/living/silicon/ai/ai_say.dm b/code/modules/mob/living/silicon/ai/ai_say.dm index 685addfbd11..12846ac1621 100644 --- a/code/modules/mob/living/silicon/ai/ai_say.dm +++ b/code/modules/mob/living/silicon/ai/ai_say.dm @@ -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 diff --git a/code/modules/modular_computers/file_system/programs/ntmessenger.dm b/code/modules/modular_computers/file_system/programs/ntmessenger.dm index 2588fe21edc..2e76c321b86 100644 --- a/code/modules/modular_computers/file_system/programs/ntmessenger.dm +++ b/code/modules/modular_computers/file_system/programs/ntmessenger.dm @@ -333,9 +333,13 @@ // Show it to ghosts var/ghost_message = span_name("[message_data["name"]] [rigged ? "Rigged" : ""] PDA Message --> [span_name("[signal.format_target()]")]: [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()]") diff --git a/modular_skyrat/modules/alt_vox/code/vox_procs.dm b/modular_skyrat/modules/alt_vox/code/vox_procs.dm index cc5b9c4c02e..c72b7f3fb93 100644 --- a/modular_skyrat/modules/alt_vox/code/vox_procs.dm +++ b/modular_skyrat/modules/alt_vox/code/vox_procs.dm @@ -167,13 +167,19 @@ // 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) - if(T.z == z_level) - SEND_SOUND(M, voice) + 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/player_turf = get_turf(player_mob) + if(player_turf.z == z_level) + SEND_SOUND(player_mob, voice) + else SEND_SOUND(only_listener, voice) + return TRUE