From 94fbb46dc4bf480b9e4a7966e7caeebca60eaf32 Mon Sep 17 00:00:00 2001 From: GDN <96800819+GDNgit@users.noreply.github.com> Date: Fri, 24 Nov 2023 09:39:59 -0600 Subject: [PATCH] reduces a massive amount of endround lag (#23306) * reduces a massive amount of endround lag * more improvements --- code/controllers/subsystem/SSticker.dm | 67 ++++++++++--------- code/game/gamemodes/changeling/changeling.dm | 7 +- code/game/gamemodes/cult/cult_mode.dm | 4 +- code/game/gamemodes/game_mode.dm | 13 ++++ .../miniantags/abduction/abduction.dm | 8 +-- code/game/gamemodes/nuclear/nuclear.dm | 7 +- code/game/gamemodes/revolution/revolution.dm | 7 +- code/game/gamemodes/traitor/traitor.dm | 5 +- .../gamemodes/vampire/vampire_gamemode.dm | 10 ++- code/game/gamemodes/wizard/wizard.dm | 7 +- 10 files changed, 71 insertions(+), 64 deletions(-) diff --git a/code/controllers/subsystem/SSticker.dm b/code/controllers/subsystem/SSticker.dm index 2aaa50f2815..c4cef1e2390 100644 --- a/code/controllers/subsystem/SSticker.dm +++ b/code/controllers/subsystem/SSticker.dm @@ -530,26 +530,31 @@ SUBSYSTEM_DEF(ticker) ending_station_state.count() var/station_integrity = min(round( 100.0 * GLOB.start_state.score(ending_station_state), 0.1), 100.0) - to_chat(world, "
[TAB]Shift Duration: [round(ROUND_TIME / 36000)]:[add_zero("[ROUND_TIME / 600 % 60]", 2)]:[ROUND_TIME / 100 % 6][ROUND_TIME / 100 % 10]") - to_chat(world, "
[TAB]Station Integrity: [mode.station_was_nuked ? "Destroyed" : "[station_integrity]%"]") - to_chat(world, "
") + var/list/end_of_round_info = list() + end_of_round_info += "
[TAB]Shift Duration: [round(ROUND_TIME / 36000)]:[add_zero("[ROUND_TIME / 600 % 60]", 2)]:[ROUND_TIME / 100 % 6][ROUND_TIME / 100 % 10]" + end_of_round_info += "
[TAB]Station Integrity: [mode.station_was_nuked ? "Destroyed" : "[station_integrity]%"]" + end_of_round_info += "
" //Silicon laws report for(var/mob/living/silicon/ai/aiPlayer in GLOB.mob_list) var/ai_ckey = safe_get_ckey(aiPlayer) - if(aiPlayer.stat != 2) - to_chat(world, "[aiPlayer.name] (Played by: [ai_ckey])'s laws at the end of the game were:") + if(aiPlayer.stat != DEAD) + end_of_round_info += "[aiPlayer.name] (Played by: [ai_ckey])'s laws at the end of the game were:" else - to_chat(world, "[aiPlayer.name] (Played by: [ai_ckey])'s laws when it was deactivated were:") - aiPlayer.show_laws(TRUE) + end_of_round_info += "[aiPlayer.name] (Played by: [ai_ckey])'s laws when it was deactivated were:" + aiPlayer.laws_sanity_check() + for(var/datum/ai_law/law as anything in aiPlayer.laws.sorted_laws) + if(law == aiPlayer.laws.zeroth_law) + end_of_round_info += "[law.get_index()]. [law.law]" + else + end_of_round_info += "[law.get_index()]. [law.law]" - if(aiPlayer.connected_robots.len) - var/robolist = "The AI's loyal minions were: " + if(length(aiPlayer.connected_robots)) + end_of_round_info += "The AI's loyal minions were: " for(var/mob/living/silicon/robot/robo in aiPlayer.connected_robots) var/robo_ckey = safe_get_ckey(robo) - robolist += "[robo.name][robo.stat ? " (Deactivated)" : ""] (Played by: [robo_ckey])" - to_chat(world, "[robolist]") + end_of_round_info += "[robo.name][robo.stat ? " (Deactivated)" : ""] (Played by: [robo_ckey])" var/dronecount = 0 @@ -562,37 +567,38 @@ SUBSYSTEM_DEF(ticker) var/robo_ckey = safe_get_ckey(robo) if(!robo.connected_ai) - if(robo.stat != 2) - to_chat(world, "[robo.name] (Played by: [robo_ckey]) survived as an AI-less borg! Its laws were:") + if(robo.stat != DEAD) + end_of_round_info += "[robo.name] (Played by: [robo_ckey]) survived as an AI-less borg! Its laws were:" else - to_chat(world, "[robo.name] (Played by: [robo_ckey]) was unable to survive the rigors of being a cyborg without an AI. Its laws were:") + end_of_round_info += "[robo.name] (Played by: [robo_ckey]) was unable to survive the rigors of being a cyborg without an AI. Its laws were:" - if(robo) //How the hell do we lose robo between here and the world messages directly above this? - robo.laws.show_laws(world) + robo.laws_sanity_check() + for(var/datum/ai_law/law as anything in robo.laws.sorted_laws) + if(law == robo.laws.zeroth_law) + end_of_round_info += "[law.get_index()]. [law.law]" + else + end_of_round_info += "[law.get_index()]. [law.law]" if(dronecount) - to_chat(world, "There [dronecount>1 ? "were" : "was"] [dronecount] industrious maintenance [dronecount>1 ? "drones" : "drone"] this round.") + end_of_round_info += "There [dronecount > 1 ? "were" : "was"] [dronecount] industrious maintenance [dronecount > 1 ? "drones" : "drone"] this round." - if(mode.eventmiscs.len) - var/emobtext = "" + if(length(mode.eventmiscs)) for(var/datum/mind/eventmind in mode.eventmiscs) - emobtext += printeventplayer(eventmind) - emobtext += "
" - emobtext += printobjectives(eventmind) - emobtext += "
" - emobtext += "
" - to_chat(world, emobtext) + end_of_round_info += printeventplayer(eventmind) + end_of_round_info += printobjectives(eventmind) + end_of_round_info += "
" mode.declare_completion()//To declare normal completion. - //calls auto_declare_completion_* for all modes - for(var/handler in typesof(/datum/game_mode/proc)) - if(findtext("[handler]","auto_declare_completion_")) - call(mode, handler)() + end_of_round_info += mode.get_end_of_round_antagonist_statistics() for(var/datum/team/team in GLOB.antagonist_teams) team.on_round_end() + // Save the data before end of the round griefing + SSpersistent_data.save() + to_chat(world, end_of_round_info.Join("
")) + // Display the scoreboard window score.scoreboard() @@ -602,9 +608,6 @@ SUBSYSTEM_DEF(ticker) //Ask the event manager to print round end information SSevents.RoundEnd() - // Save the data before end of the round griefing - SSpersistent_data.save() - //make big obvious note in game logs that round ended log_game("///////////////////////////////////////////////////////") log_game("///////////////////// ROUND ENDED /////////////////////") diff --git a/code/game/gamemodes/changeling/changeling.dm b/code/game/gamemodes/changeling/changeling.dm index a8498c62664..f26761ea92a 100644 --- a/code/game/gamemodes/changeling/changeling.dm +++ b/code/game/gamemodes/changeling/changeling.dm @@ -57,7 +57,7 @@ GLOBAL_LIST_INIT(possible_changeling_IDs, list("Alpha","Beta","Gamma","Delta","E /datum/game_mode/proc/auto_declare_completion_changeling() if(length(changelings)) - var/text = "The changelings were:" + var/list/text = list("The changelings were:") for(var/datum/mind/changeling in changelings) var/changelingwin = TRUE @@ -107,7 +107,4 @@ GLOBAL_LIST_INIT(possible_changeling_IDs, list("Alpha","Beta","Gamma","Delta","E else text += "
The changeling has failed." SSblackbox.record_feedback("tally", "changeling_success", 1, "FAIL") - - to_chat(world, text) - - return TRUE + return text.Join("") diff --git a/code/game/gamemodes/cult/cult_mode.dm b/code/game/gamemodes/cult/cult_mode.dm index 947a7d783a5..045f0887955 100644 --- a/code/game/gamemodes/cult/cult_mode.dm +++ b/code/game/gamemodes/cult/cult_mode.dm @@ -376,7 +376,7 @@ GLOBAL_LIST_EMPTY(all_cults) SSticker.mode_result = "cult loss - staff stopped the cult" to_chat(world, " The staff managed to stop the cult!") - var/endtext + var/list/endtext = list() endtext += "
The cultists' objectives were:" for(var/datum/objective/obj in cult_objs.presummon_objs) endtext += "
[obj.explanation_text] - " @@ -391,5 +391,5 @@ GLOBAL_LIST_EMPTY(all_cults) else endtext += "Success!" - to_chat(world, endtext) + to_chat(world, endtext.Join("")) ..() diff --git a/code/game/gamemodes/game_mode.dm b/code/game/gamemodes/game_mode.dm index 3d8274eed18..48d89f2eaba 100644 --- a/code/game/gamemodes/game_mode.dm +++ b/code/game/gamemodes/game_mode.dm @@ -505,3 +505,16 @@ var/datum/atom_hud/antag/antaghud = GLOB.huds[ANTAG_HUD_EVENTMISC] antaghud.leave_hud(mob_mind.current) set_antag_hud(mob_mind.current, null) + +/// Gets the value of all end of round stats through auto_declare and returns them +/datum/game_mode/proc/get_end_of_round_antagonist_statistics() + . = list() + . += auto_declare_completion_traitor() + . += auto_declare_completion_vampire() + . += auto_declare_completion_enthralled() + . += auto_declare_completion_changeling() + . += auto_declare_completion_nuclear() + . += auto_declare_completion_wizard() + . += auto_declare_completion_revolution() + . += auto_declare_completion_abduction() + listclearnulls(.) diff --git a/code/game/gamemodes/miniantags/abduction/abduction.dm b/code/game/gamemodes/miniantags/abduction/abduction.dm index c80570de0da..92ef8002b7f 100644 --- a/code/game/gamemodes/miniantags/abduction/abduction.dm +++ b/code/game/gamemodes/miniantags/abduction/abduction.dm @@ -211,22 +211,22 @@ return 1 /datum/game_mode/proc/auto_declare_completion_abduction() - var/text = "" - if(abductors.len) + var/list/text = list() + if(length(abductors)) text += "
The abductors were:
" for(var/datum/mind/abductor_mind in abductors) text += printplayer(abductor_mind) text += "
" text += printobjectives(abductor_mind) text += "
" - if(abductees.len) + if(length(abductees)) text += "
The abductees were:
" for(var/datum/mind/abductee_mind in abductees) text += printplayer(abductee_mind) text += "
" text += printobjectives(abductee_mind) text += "
" - to_chat(world, text) + return text.Join("") //Landmarks // TODO: Split into seperate landmarks for prettier ships diff --git a/code/game/gamemodes/nuclear/nuclear.dm b/code/game/gamemodes/nuclear/nuclear.dm index 928ed4b7c17..a6331a76827 100644 --- a/code/game/gamemodes/nuclear/nuclear.dm +++ b/code/game/gamemodes/nuclear/nuclear.dm @@ -389,8 +389,8 @@ /datum/game_mode/proc/auto_declare_completion_nuclear() - if(syndicates.len || GAMEMODE_IS_NUCLEAR) - var/text = "
The syndicate operatives were:" + if(length(syndicates) || GAMEMODE_IS_NUCLEAR) + var/list/text = list("
The syndicate operatives were:") var/purchases = "" var/TC_uses = 0 @@ -420,8 +420,7 @@ if(TC_uses==0 && station_was_nuked && !is_operatives_are_dead()) text += "" - to_chat(world, text) - return 1 + return text.Join("") /proc/nukelastname(mob/M as mob) //--All praise goes to NEO|Phyte, all blame goes to DH, and it was Cindi-Kate's idea. Also praise Urist for copypasta ho. var/randomname = pick(GLOB.last_names) diff --git a/code/game/gamemodes/revolution/revolution.dm b/code/game/gamemodes/revolution/revolution.dm index 3d95e5a5839..549f17c82a3 100644 --- a/code/game/gamemodes/revolution/revolution.dm +++ b/code/game/gamemodes/revolution/revolution.dm @@ -182,15 +182,14 @@ num_revs++ if(num_survivors) to_chat(world, "[TAB]Command's Approval Rating: [100 - round((num_revs/num_survivors)*100, 0.1)]%") // % of loyal crew - var/text = "
The head revolutionaries were:" + var/list/text = list("
The head revolutionaries were:") for(var/datum/mind/headrev in head_revolutionaries) text += printplayer(headrev, 1) text += "
" - to_chat(world, text) // we dont show the revolutionaries because there are a LOT of them - text = "
The heads of staff were:" + text = list("
The heads of staff were:") var/list/heads = get_all_heads() for(var/datum/mind/head in heads) var/target = (head in targets) @@ -198,7 +197,7 @@ text += "Target" text += printplayer(head, 1) text += "
" - to_chat(world, text) + return text.Join("") /datum/game_mode/revolution/set_scoreboard_vars() // this proc is never called, someone remove it var/datum/scoreboard/scoreboard = SSticker.score diff --git a/code/game/gamemodes/traitor/traitor.dm b/code/game/gamemodes/traitor/traitor.dm index 55a17cd945b..fe0fb08a784 100644 --- a/code/game/gamemodes/traitor/traitor.dm +++ b/code/game/gamemodes/traitor/traitor.dm @@ -72,7 +72,7 @@ /datum/game_mode/proc/auto_declare_completion_traitor() if(length(traitors)) - var/text = "The traitors were:
" + var/list/text = list("The traitors were:
") for(var/datum/mind/traitor in traitors) var/traitorwin = TRUE text += printplayer(traitor) @@ -159,5 +159,4 @@ text += "

The code phrases were: [phrases]
\ The code responses were: [responses]

" - to_chat(world, text) - return TRUE + return text.Join("") diff --git a/code/game/gamemodes/vampire/vampire_gamemode.dm b/code/game/gamemodes/vampire/vampire_gamemode.dm index 688d8c7da8b..306ef74cb9a 100644 --- a/code/game/gamemodes/vampire/vampire_gamemode.dm +++ b/code/game/gamemodes/vampire/vampire_gamemode.dm @@ -51,7 +51,7 @@ if(!length(vampires)) return - var/text = "The vampires were:" + var/list/text = list("The vampires were:") for(var/datum/mind/vampire in vampires) var/traitorwin = TRUE var/datum/antagonist/vampire/V = vampire.has_antag_datum(/datum/antagonist/vampire) @@ -101,14 +101,13 @@ else text += "
The [special_role_text] has failed!" SSblackbox.record_feedback("tally", "vampire_success", 1, "FAIL") - to_chat(world, text) - return TRUE + return text.Join("") /datum/game_mode/proc/auto_declare_completion_enthralled() if(!length(vampire_enthralled)) return - var/text = "The Enthralled were:" + var/list/text = list("The Enthralled were:") for(var/datum/mind/mind in vampire_enthralled) text += "
[mind.get_display_key()] was [mind.name] (" if(mind.current) @@ -121,6 +120,5 @@ else text += "body destroyed" text += ")" - to_chat(world, text) - return TRUE + return text.Join("") diff --git a/code/game/gamemodes/wizard/wizard.dm b/code/game/gamemodes/wizard/wizard.dm index 49ee1dea3f0..91ef380ebc6 100644 --- a/code/game/gamemodes/wizard/wizard.dm +++ b/code/game/gamemodes/wizard/wizard.dm @@ -191,8 +191,8 @@ return 1 /datum/game_mode/proc/auto_declare_completion_wizard() - if(wizards.len) - var/text = "
the wizards/witches were:" + if(length(wizards)) + var/list/text = list("
the wizards/witches were:") for(var/datum/mind/wizard in wizards) @@ -236,8 +236,7 @@ i++ text += "
" - to_chat(world, text) - return 1 + return text.Join("") //OTHER PROCS