From ca20cbb5a1a4e03b0e4f14bee105949c023ea235 Mon Sep 17 00:00:00 2001 From: SkyratBot <59378654+SkyratBot@users.noreply.github.com> Date: Sat, 23 Jul 2022 22:26:40 +0200 Subject: [PATCH] [MIRROR] Fixes security level alerts playing the incorrect sounds [MDB IGNORE] (#15116) * Fixes security level alerts playing the incorrect sounds * Fixes the merge conflict * Slightly improves the code on our end, adds the documentation that we were now missing Co-authored-by: MrMelbert <51863163+MrMelbert@users.noreply.github.com> Co-authored-by: GoldenAlpharex --- code/__HELPERS/priority_announce.dm | 32 +++++++++++++------ code/controllers/subsystem/security_level.dm | 6 ++-- .../security_levels/security_level_datums.dm | 4 +++ .../modules/alerts/code/priority_announce.dm | 25 ++++++++++++--- 4 files changed, 49 insertions(+), 18 deletions(-) diff --git a/code/__HELPERS/priority_announce.dm b/code/__HELPERS/priority_announce.dm index 2f1281d72c4..f5eacc3aa8b 100644 --- a/code/__HELPERS/priority_announce.dm +++ b/code/__HELPERS/priority_announce.dm @@ -95,7 +95,19 @@ SScommunications.send_message(M) -/proc/minor_announce(message, title = "Attention:", alert, html_encode = TRUE, list/players) +/** + * Sends a minor annoucement to players. + * Minor announcements are large text, with the title in red and message in white. + * Only mobs that can hear can see the announcements. + * + * message - the message contents of the announcement. + * title - the title of the announcement, which is often "who sent it". + * alert - whether this announcement is an alert, or just a notice. Only changes the sound that is played by default. + * html_encode - if TRUE, we will html encode our title and message before sending it, to prevent player input abuse. + * players - optional, a list mobs to send the announcement to. If unset, sends to all palyers. + * sound_override - optional, use the passed sound file instead of the default notice sounds. + */ +/proc/minor_announce(message, title = "Attention:", alert, html_encode = TRUE, list/players, sound_override) if(!message) return @@ -107,11 +119,13 @@ players = GLOB.player_list for(var/mob/target in players) - if(!isnewplayer(target) && target.can_hear()) - to_chat(target, "[span_minorannounce("[title]
[message]")]
") - if(target.client.prefs.toggles & SOUND_ANNOUNCEMENTS) - if(alert) - SEND_SOUND(target, sound('sound/misc/notice1.ogg')) - else - SEND_SOUND(M, sound('sound/misc/notice2.ogg')) -*/ + if(isnewplayer(target)) + continue + if(!target.can_hear()) + continue + + to_chat(target, "[span_minorannounce("[title]
[message]")]
") + if(target.client?.prefs.toggles & SOUND_ANNOUNCEMENTS) + var/sound_to_play = sound_override || (alert ? 'sound/misc/notice1.ogg' : 'sound/misc/notice2.ogg') + SEND_SOUND(target, sound(sound_to_play)) +*/ // SKYRAT EDIT REMOVAL END diff --git a/code/controllers/subsystem/security_level.dm b/code/controllers/subsystem/security_level.dm index 9f1aac1c5e1..96d0cc5340a 100644 --- a/code/controllers/subsystem/security_level.dm +++ b/code/controllers/subsystem/security_level.dm @@ -68,11 +68,9 @@ SUBSYSTEM_DEF(security_level) */ /datum/controller/subsystem/security_level/proc/announce_security_level(datum/security_level/selected_level) if(selected_level.number_level > current_security_level.number_level) // We are elevating to this level. - minor_announce(selected_level.elevating_to_announcemnt, "Attention! Security level elevated to [selected_level.name]:") + minor_announce(selected_level.elevating_to_announcemnt, "Attention! Security level elevated to [selected_level.name]:", sound_override = selected_level.sound) else // Going down - minor_announce(selected_level.lowering_to_announcement, "Attention! Security level lowered to [selected_level.name]:") - if(selected_level.sound) - sound_to_playing_players(selected_level.sound) + minor_announce(selected_level.lowering_to_announcement, "Attention! Security level lowered to [selected_level.name]:", sound_override = selected_level.sound) /** * Returns the current security level as a number diff --git a/code/modules/security_levels/security_level_datums.dm b/code/modules/security_levels/security_level_datums.dm index c6addd4d4eb..ea78000ab09 100644 --- a/code/modules/security_levels/security_level_datums.dm +++ b/code/modules/security_levels/security_level_datums.dm @@ -42,6 +42,7 @@ */ /datum/security_level/green name = "green" + sound = 'sound/misc/notice2.ogg' // Friendly beep number_level = SEC_LEVEL_GREEN lowering_to_configuration_key = /datum/config_entry/string/alert_green shuttle_call_time_mod = 2 @@ -53,6 +54,7 @@ */ /datum/security_level/blue name = "blue" + sound = 'sound/misc/notice1.ogg' // Angry alarm number_level = SEC_LEVEL_BLUE lowering_to_configuration_key = /datum/config_entry/string/alert_blue_downto elevating_to_configuration_key = /datum/config_entry/string/alert_blue_upto @@ -65,6 +67,7 @@ */ /datum/security_level/red name = "red" + sound = 'sound/misc/notice1.ogg' // The same angry alarm number_level = SEC_LEVEL_RED lowering_to_configuration_key = /datum/config_entry/string/alert_red_downto elevating_to_configuration_key = /datum/config_entry/string/alert_red_upto @@ -77,6 +80,7 @@ */ /datum/security_level/delta name = "delta" + sound = 'sound/misc/notice1.ogg' // The same angry alarm, again number_level = SEC_LEVEL_DELTA elevating_to_configuration_key = /datum/config_entry/string/alert_delta shuttle_call_time_mod = 0.25 diff --git a/modular_skyrat/modules/alerts/code/priority_announce.dm b/modular_skyrat/modules/alerts/code/priority_announce.dm index 0594c5e3329..facd8713dd2 100644 --- a/modular_skyrat/modules/alerts/code/priority_announce.dm +++ b/modular_skyrat/modules/alerts/code/priority_announce.dm @@ -66,8 +66,19 @@ SScommunications.send_message(M) -///This proc sends an announcement to all currently playing mobs. Use alert to send a more ominious BEEP. Generally used for updating people on minor things, such as CME locaiton. Use priority_announce for large announcements. -/proc/minor_announce(message, title = "Attention:", alert, html_encode = TRUE, list/players, sound, override_volume = FALSE) +/** + * Sends a minor annoucement to players. + * Minor announcements are large text, with the title in red and message in white. + * Only mobs that can hear can see the announcements. + * + * message - the message contents of the announcement. + * title - the title of the announcement, which is often "who sent it". + * alert - whether this announcement is an alert, or just a notice. Only changes the sound that is played by default. + * html_encode - if TRUE, we will html encode our title and message before sending it, to prevent player input abuse. + * players - optional, a list mobs to send the announcement to. If unset, sends to all palyers. + * sound_override - optional, use the passed sound file instead of the default notice sounds. We're not currently using those on Skyrat, since we use our own sounds. + */ +/proc/minor_announce(message, title = "Attention:", alert, html_encode = TRUE, list/players, sound_override, sound, override_volume = FALSE) if(!message) return @@ -78,9 +89,13 @@ if(!players) players = GLOB.player_list - for(var/mob/M in players) - if(!isnewplayer(M) && M.can_hear()) - to_chat(M, span_minorannounce("[title]
[message]
")) + for(var/mob/target in players) + if(isnewplayer(target)) + continue + if(!target.can_hear()) + continue + + to_chat(target, "[span_minorannounce("[title]
[message]")]
") if(sound) if(SSstation.announcer.event_sounds[sound])