From e8389a85b1654acdaee2fb9bbd78e57ae36fa863 Mon Sep 17 00:00:00 2001 From: SkyratBot <59378654+SkyratBot@users.noreply.github.com> Date: Thu, 15 Feb 2024 23:40:32 +0100 Subject: [PATCH] [MIRROR] Reduces chat/audio spam when multiple ghost polls are being called (#26503) * Reduces chat/audio spam when multiple ghost polls are being called (#81441) ## About The Pull Request This slightly modifies the polling subsystem. The sound/chat popup for a new role is now only given on the first "stack" of a role signup. Let's say 3 loneops roll at once (ty admins), you'll still get the toast popup for 3x loneop rolls, but you'll only get one text highlight in the chat, and only one audio stinger. Even if the first 2 loneops don't have anyone sign up for it, using the text or toast signup options will still sign you up for the last roll as it completes. This shouldn't make signing up any harder, just quieter. ## Why It's Good For The Game Less spam in chat. Less headset-blasting audio bleeps. Cool! Closes #80998. ## Changelog :cl: Rhials fix: Ghost role polls should spam you less when multiple of the same roll occur in succession. /:cl: * Reduces chat/audio spam when multiple ghost polls are being called --------- Co-authored-by: Rhials <28870487+Rhials@users.noreply.github.com> --- code/controllers/subsystem/polling.dm | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/code/controllers/subsystem/polling.dm b/code/controllers/subsystem/polling.dm index 168140fb2c8..9c6de878a06 100644 --- a/code/controllers/subsystem/polling.dm +++ b/code/controllers/subsystem/polling.dm @@ -49,7 +49,6 @@ SUBSYSTEM_DEF(polling) if(role && !is_eligible(candidate_mob, role, check_jobban, ignore_category)) continue - SEND_SOUND(candidate_mob, 'sound/misc/notice2.ogg') if(flash_window) window_flash(candidate_mob.client) @@ -116,7 +115,10 @@ SUBSYSTEM_DEF(polling) var/act_never = "" if(ignore_category) act_never = "\[Never For This Round]" - to_chat(candidate_mob, span_boldnotice(examine_block("Now looking for candidates [role_name_text ? "to play as \an [role_name_text]." : "\"[question]\""] [act_jump] [act_signup] [act_never]"))) + + if(!duplicate_message_check(alert_poll)) //Only notify people once. They'll notice if there are multiple and we don't want to spam people. + SEND_SOUND(candidate_mob, 'sound/misc/notice2.ogg') + to_chat(candidate_mob, span_boldnotice(examine_block("Now looking for candidates [role_name_text ? "to play as \an [role_name_text]." : "\"[question]\""] [act_jump] [act_signup] [act_never]"))) // Start processing it so it updates visually the timer START_PROCESSING(SSprocessing, poll_alert_button) @@ -198,13 +200,8 @@ SUBSYSTEM_DEF(polling) // Take care of updating the remaining screen alerts if a similar poll is found, or deleting them. if(length(finishing_poll.alert_buttons)) - var/polls_of_same_type_left = FALSE - for(var/datum/candidate_poll/running_poll as anything in currently_polling) - if(running_poll.poll_key == finishing_poll.poll_key && running_poll.time_left() > 0) - polls_of_same_type_left = TRUE - break for(var/atom/movable/screen/alert/poll_alert/alert as anything in finishing_poll.alert_buttons) - if(polls_of_same_type_left) + if(duplicate_message_check(finishing_poll)) alert.update_stacks_overlay() else alert.owner.clear_alert("[finishing_poll.poll_key]_poll_alert") @@ -219,6 +216,13 @@ SUBSYSTEM_DEF(polling) msg += " | Next: [DisplayTimeText(soonest_to_complete.time_left())] ([length(soonest_to_complete.signed_up)] candidates)" return ..() +///Is there a multiple of the given event type running right now? +/datum/controller/subsystem/polling/proc/duplicate_message_check(datum/candidate_poll/poll_to_check) + for(var/datum/candidate_poll/running_poll as anything in currently_polling) + if((running_poll.poll_key == poll_to_check.poll_key && running_poll != poll_to_check) && running_poll.time_left() > 0) + return TRUE + return FALSE + /datum/controller/subsystem/polling/proc/get_next_poll_to_finish() var/lowest_time_left = INFINITY var/next_poll_to_finish