From a26e7989ff2ae99aa6be02433fd0439b141e7ab9 Mon Sep 17 00:00:00 2001 From: Phantastic-Swan Date: Sun, 9 Aug 2026 22:35:03 +0200 Subject: [PATCH] Cleaning up some ticker code (#6072) I was looking into changing how the round start ping is being generated so that it isn't dependant on the QOTR message (on which I eventually just gave up). While doing so I stumbled upon 3 separate overrides for the same proc of the ticker, in 3 different files. This induced a headache of immense proportions and I had to fix it because jesus christ what the fuck is that? While I was at it, I grabbed some other ticker procs strewn around `modular_zubbers` and `modular_skyrat` and threw them into a single file responsible for handling the ticker. Do you understand how cancer inducing it is to try and figure out how code is executed when there are 3 separate overrides for a single proc? I am of the opinion that any codebase should override any proc AT MOST once. Multiple overrides for a proc make for worse stack traces, less clarity in the order of code execution, and more difficulty in finding original declarations of procs. They also make it harder to keep procs up to date with upstreams if say, the arguments change (I know BYOND doesn't enforce proc overrides to have the same arguments as the original proc; however I consider that a load of bullshit and a major flaw in the language) I did compile the code, and the round ends normally, and the debugger tells me that code executes normally. Though, given that this does mess with subsystem code, maybe TM'ing is in order? No player facing changes --- .../modules/opposing_force/code/roundend.dm | 12 --- .../code/controllers/subsystem/ticker.dm | 74 +++++++++++++++++++ .../code/modules/quote_of_the_round/ticker.dm | 39 ---------- .../modules/zantag_tickets/preferences.dm | 12 --- tgstation.dme | 2 - 5 files changed, 74 insertions(+), 65 deletions(-) delete mode 100644 modular_skyrat/modules/opposing_force/code/roundend.dm delete mode 100644 modular_zubbers/code/modules/quote_of_the_round/ticker.dm diff --git a/modular_skyrat/modules/opposing_force/code/roundend.dm b/modular_skyrat/modules/opposing_force/code/roundend.dm deleted file mode 100644 index 1725eeaf363..00000000000 --- a/modular_skyrat/modules/opposing_force/code/roundend.dm +++ /dev/null @@ -1,12 +0,0 @@ -/datum/controller/subsystem/ticker/proc/opfor_report() - var/list/result = list() - - result += "Opposing Force Report:
" - - if(!SSopposing_force.approved_applications.len) - result += span_red("No applications were approved.") - else - for(var/datum/opposing_force/opfor in SSopposing_force.approved_applications) - result += opfor.roundend_report() - - return "
[result.Join()]
" diff --git a/modular_zubbers/code/controllers/subsystem/ticker.dm b/modular_zubbers/code/controllers/subsystem/ticker.dm index 7a2548b213e..a6f21ef8bf3 100644 --- a/modular_zubbers/code/controllers/subsystem/ticker.dm +++ b/modular_zubbers/code/controllers/subsystem/ticker.dm @@ -1,6 +1,27 @@ /datum/controller/subsystem/ticker var/list/job_estimation_list = list() + // QOTR stuff + var/quote_of_the_round_record_start + var/quote_of_the_round_text + var/quote_of_the_round_attribution + var/quote_of_the_round_ckey + +/datum/controller/subsystem/ticker/Initialize() + . = ..() + quote_of_the_round_record_start = rand(CONFIG_GET(number/quote_of_the_round_time_random_start), CONFIG_GET(number/quote_of_the_round_time_random_end)) + message_admins( + span_notice("Notice: The quote of the round will be chosen in [DisplayTimeText(quote_of_the_round_record_start,1)].") + ) + log_runtime("The quote of the round will be chosen in [DisplayTimeText(quote_of_the_round_record_start,1)].") + +/datum/controller/subsystem/ticker/declare_completion(was_forced = END_ROUND_AS_NORMAL) + handle_antag_tickets() + handle_quote_of_the_round() + handle_credits() + + . = ..() + /datum/controller/subsystem/ticker/proc/get_job_estimation(list/players) var/list/player_ready_data = list() sortTim(players, GLOBAL_PROC_REF(cmp_text_asc)) @@ -39,3 +60,56 @@ player_ready_data.Insert(1, "Job Estimation:") player_ready_data.Insert(1, "") return player_ready_data + +/datum/controller/subsystem/ticker/proc/handle_antag_tickets() + set waitfor = FALSE + + for(var/ckey in GLOB.preferences_datums) + var/datum/preferences/prefs = GLOB.preferences_datums[ckey] + if(prefs.antag_tickets == prefs.antag_tickets_old) + continue //Only save if there has been a change. + prefs.save_preferences() + +/datum/controller/subsystem/ticker/proc/handle_credits() + if(!GLOB.end_titles) + GLOB.end_titles = generate_titles() + + for(var/client/C) + if(!C?.credits) + C?.RollCredits() + +/datum/controller/subsystem/ticker/proc/handle_quote_of_the_round() + if(quote_of_the_round_text) + for(var/channel_tag in CONFIG_GET(str_list/channel_announce_new_game)) + send2chat( + new /datum/tgs_message_content(generate_quote_of_the_round()), + channel_tag + ) + to_chat(world, span_notice("A quote of the round was found, and should have been sent to discord.")) + log_runtime("A quote of the round was found, and should have been sent to discord.") + + else + if(world.time <= quote_of_the_round_record_start) + to_chat(world, span_notice("A quote of the round could not be found due to the round being too short.")) + log_runtime("A quote of the round could not be found. The round ended too early.") + else + to_chat(world, span_notice("A quote of the round could not be found. Perhaps the crew should be more memorable.")) + log_runtime("A quote of the round could not be found. Perhaps the filters are too strict?") + +/datum/controller/subsystem/ticker/proc/generate_quote_of_the_round() + return "The shift has ended. Get ready, a new round on **[SSmap_vote.next_map_config.map_name]** starts soon! <@&[CONFIG_GET(string/game_alert_role_id)]>\n\ + [pick(strings("quote_of_the_round.json", "workers"))] [pick(strings("quote_of_the_round.json", "action"))] [pick(strings("quote_of_the_round.json", "message"))] that occured during said shift:\n\ + > *[quote_of_the_round_text]*\n \\- *[quote_of_the_round_attribution]*" + +/datum/controller/subsystem/ticker/proc/opfor_report() + var/list/result = list() + + result += "Opposing Force Report:
" + + if(!SSopposing_force.approved_applications.len) + result += span_red("No applications were approved.") + else + for(var/datum/opposing_force/opfor in SSopposing_force.approved_applications) + result += opfor.roundend_report() + + return "
[result.Join()]
" diff --git a/modular_zubbers/code/modules/quote_of_the_round/ticker.dm b/modular_zubbers/code/modules/quote_of_the_round/ticker.dm deleted file mode 100644 index e9ebc365b7f..00000000000 --- a/modular_zubbers/code/modules/quote_of_the_round/ticker.dm +++ /dev/null @@ -1,39 +0,0 @@ -/datum/controller/subsystem/ticker - var/quote_of_the_round_record_start - var/quote_of_the_round_text - var/quote_of_the_round_attribution - var/quote_of_the_round_ckey - -/datum/controller/subsystem/ticker/Initialize() - . = ..() - quote_of_the_round_record_start = rand(CONFIG_GET(number/quote_of_the_round_time_random_start), CONFIG_GET(number/quote_of_the_round_time_random_end)) - message_admins( - span_notice("Notice: The quote of the round will be chosen in [DisplayTimeText(quote_of_the_round_record_start,1)].") - ) - log_runtime("The quote of the round will be chosen in [DisplayTimeText(quote_of_the_round_record_start,1)].") - -/datum/controller/subsystem/ticker/declare_completion(force_ending) - - if(quote_of_the_round_text) - for(var/channel_tag in CONFIG_GET(str_list/channel_announce_new_game)) - send2chat( - new /datum/tgs_message_content(generate_quote_of_the_round()), - channel_tag - ) - to_chat(world, span_notice("A quote of the round was found, and should have been sent to discord.")) - log_runtime("A quote of the round was found, and should have been sent to discord.") - - else - if(world.time <= quote_of_the_round_record_start) - to_chat(world, span_notice("A quote of the round could not be found due to the round being too short.")) - log_runtime("A quote of the round could not be found. The round ended too early.") - else - to_chat(world, span_notice("A quote of the round could not be found. Perhaps the crew should be more memorable.")) - log_runtime("A quote of the round could not be found. Perhaps the filters are too strict?") - - . = ..() - -/datum/controller/subsystem/ticker/proc/generate_quote_of_the_round() - return "The shift has ended. Get ready, a new round on **[SSmap_vote.next_map_config.map_name]** starts soon! <@&[CONFIG_GET(string/game_alert_role_id)]>\n\ - [pick(strings("quote_of_the_round.json", "workers"))] [pick(strings("quote_of_the_round.json", "action"))] [pick(strings("quote_of_the_round.json", "message"))] that occured during said shift:\n\ - > *[quote_of_the_round_text]*\n \\- *[quote_of_the_round_attribution]*" diff --git a/modular_zubbers/code/modules/zantag_tickets/preferences.dm b/modular_zubbers/code/modules/zantag_tickets/preferences.dm index 097cfc9ffce..4b83d14729c 100644 --- a/modular_zubbers/code/modules/zantag_tickets/preferences.dm +++ b/modular_zubbers/code/modules/zantag_tickets/preferences.dm @@ -25,15 +25,3 @@ savefile.set_entry("antag_tickets", antag_tickets) antag_tickets_old = antag_tickets . = ..() - -/datum/controller/subsystem/ticker/declare_completion(was_forced = END_ROUND_AS_NORMAL) - - set waitfor = FALSE - - for(var/ckey in GLOB.preferences_datums) - var/datum/preferences/prefs = GLOB.preferences_datums[ckey] - if(prefs.antag_tickets == prefs.antag_tickets_old) - continue //Only save if there has been a change. - prefs.save_preferences() - - . = ..() diff --git a/tgstation.dme b/tgstation.dme index ce57c1feff2..7442c083215 100644 --- a/tgstation.dme +++ b/tgstation.dme @@ -8789,7 +8789,6 @@ #include "modular_skyrat\modules\opposing_force\code\mind.dm" #include "modular_skyrat\modules\opposing_force\code\opposing_force_datum.dm" #include "modular_skyrat\modules\opposing_force\code\opposing_force_subsystem.dm" -#include "modular_skyrat\modules\opposing_force\code\roundend.dm" #include "modular_skyrat\modules\opposing_force\code\equipment\ammo.dm" #include "modular_skyrat\modules\opposing_force\code\equipment\biology.dm" #include "modular_skyrat\modules\opposing_force\code\equipment\bombs.dm" @@ -10181,7 +10180,6 @@ #include "modular_zubbers\code\modules\quote_of_the_round\config.dm" #include "modular_zubbers\code\modules\quote_of_the_round\debug_verbs.dm" #include "modular_zubbers\code\modules\quote_of_the_round\telecomms.dm" -#include "modular_zubbers\code\modules\quote_of_the_round\ticker.dm" #include "modular_zubbers\code\modules\ratqueen\regalrat.dm" #include "modular_zubbers\code\modules\reagents\drink_reagents.dm" #include "modular_zubbers\code\modules\reagents\reagent_dispenser.dm"