From: Kyle Tyo <36606155+VerinSenpai@users.noreply.github.com> Date: Tue, 16 Sep 2025 21:25:17 +0000 (-0400) Subject: Readyall and Toggleready commands to LEC. Fix an issue with ready button desync.... X-Git-Url: https://git.smokeofanarchy.ru/gitweb.cgi?a=commitdiff_plain;h=7ff98dd94fc0388fe6267bda0d68b7724d6e6268;p=space-station-14.git Readyall and Toggleready commands to LEC. Fix an issue with ready button desync. (#38706) * commit * commit * change lobby shell string. --- diff --git a/Content.Client/Lobby/LobbyState.cs b/Content.Client/Lobby/LobbyState.cs index 867a7bb8a5..538266e1a2 100644 --- a/Content.Client/Lobby/LobbyState.cs +++ b/Content.Client/Lobby/LobbyState.cs @@ -186,10 +186,10 @@ namespace Content.Client.Lobby else { Lobby!.StartTime.Text = string.Empty; + Lobby!.ReadyButton.Pressed = _gameTicker.AreWeReady; Lobby!.ReadyButton.Text = Loc.GetString(Lobby!.ReadyButton.Pressed ? "lobby-state-player-status-ready": "lobby-state-player-status-not-ready"); Lobby!.ReadyButton.ToggleMode = true; Lobby!.ReadyButton.Disabled = false; - Lobby!.ReadyButton.Pressed = _gameTicker.AreWeReady; Lobby!.ObserveButton.Disabled = true; } diff --git a/Content.Server/Administration/Commands/ReadyAll.cs b/Content.Server/Administration/Commands/ReadyAll.cs deleted file mode 100644 index 530ba0e89c..0000000000 --- a/Content.Server/Administration/Commands/ReadyAll.cs +++ /dev/null @@ -1,37 +0,0 @@ -using Content.Server.GameTicking; -using Content.Shared.Administration; -using Content.Shared.GameTicking; -using Robust.Shared.Console; - -namespace Content.Server.Administration.Commands -{ - [AdminCommand(AdminFlags.Round)] - public sealed class ReadyAll : IConsoleCommand - { - [Dependency] private readonly IEntityManager _e = default!; - - public string Command => "readyall"; - public string Description => "Readies up all players in the lobby, except for observers."; - public string Help => $"{Command} | ̣{Command} "; - public void Execute(IConsoleShell shell, string argStr, string[] args) - { - var ready = true; - - if (args.Length > 0) - { - ready = bool.Parse(args[0]); - } - - var gameTicker = _e.System(); - - - if (gameTicker.RunLevel != GameRunLevel.PreRoundLobby) - { - shell.WriteLine("This command can only be ran while in the lobby!"); - return; - } - - gameTicker.ToggleReadyAll(ready); - } - } -} diff --git a/Content.Server/Administration/Commands/ReadyAllCommand.cs b/Content.Server/Administration/Commands/ReadyAllCommand.cs new file mode 100644 index 0000000000..a3fc49934e --- /dev/null +++ b/Content.Server/Administration/Commands/ReadyAllCommand.cs @@ -0,0 +1,32 @@ +using Content.Server.GameTicking; +using Content.Shared.Administration; +using Robust.Shared.Console; + +namespace Content.Server.Administration.Commands; + +[AdminCommand(AdminFlags.Round)] +public sealed class ReadyAllCommand : LocalizedEntityCommands +{ + [Dependency] private readonly GameTicker _gameTicker = default!; + + public override string Command => "readyall"; + + public override void Execute(IConsoleShell shell, string argStr, string[] args) + { + var ready = true; + + if (_gameTicker.RunLevel != GameRunLevel.PreRoundLobby) + { + shell.WriteError(Loc.GetString("shell-can-only-run-from-pre-round-lobby")); + return; + } + + if (args.Length > 0 && !bool.TryParse(args[0], out ready)) + { + shell.WriteError(Loc.GetString("shell-argument-must-be-boolean")); + return; + } + + _gameTicker.ToggleReadyAll(ready); + } +} diff --git a/Content.Server/GameTicking/Commands/ToggleReadyCommand.cs b/Content.Server/GameTicking/Commands/ToggleReadyCommand.cs index 34b504acbc..3debf37778 100644 --- a/Content.Server/GameTicking/Commands/ToggleReadyCommand.cs +++ b/Content.Server/GameTicking/Commands/ToggleReadyCommand.cs @@ -1,32 +1,41 @@ using Content.Shared.Administration; using Robust.Shared.Console; -namespace Content.Server.GameTicking.Commands +namespace Content.Server.GameTicking.Commands; + +[AnyCommand] +public sealed class ToggleReadyCommand : LocalizedEntityCommands { - [AnyCommand] - sealed class ToggleReadyCommand : IConsoleCommand + [Dependency] private readonly GameTicker _gameTicker = default!; + + public override string Command => "toggleready"; + + public override void Execute(IConsoleShell shell, string argStr, string[] args) { - [Dependency] private readonly IEntityManager _e = default!; + if (args.Length != 1) + { + shell.WriteError(Loc.GetString("shell-need-exactly-one-argument")); + return; + } - public string Command => "toggleready"; - public string Description => ""; - public string Help => ""; + if (shell.Player is not { } player) + { + shell.WriteError(Loc.GetString("shell-only-players-can-run-this-command")); + return; + } - public void Execute(IConsoleShell shell, string argStr, string[] args) + if (_gameTicker.RunLevel != GameRunLevel.PreRoundLobby) { - var player = shell.Player; - if (args.Length != 1) - { - shell.WriteError(Loc.GetString("shell-wrong-arguments-number")); - return; - } - if (player == null) - { - return; - } - - var ticker = _e.System(); - ticker.ToggleReady(player, bool.Parse(args[0])); + shell.WriteError(Loc.GetString("shell-can-only-run-from-pre-round-lobby")); + return; } + + if (!bool.TryParse(args[0], out var ready)) + { + shell.WriteError(Loc.GetString("shell-argument-must-be-boolean")); + return; + } + + _gameTicker.ToggleReady(player, ready); } } diff --git a/Content.Server/GameTicking/GameTicker.Lobby.cs b/Content.Server/GameTicking/GameTicker.Lobby.cs index 66c39ab469..6be7e3abca 100644 --- a/Content.Server/GameTicking/GameTicker.Lobby.cs +++ b/Content.Server/GameTicking/GameTicker.Lobby.cs @@ -173,7 +173,6 @@ namespace Content.Server.GameTicking return; } - var status = ready ? PlayerGameStatus.ReadyToPlay : PlayerGameStatus.NotReadyToPlay; _playerGameStatuses[player.UserId] = ready ? PlayerGameStatus.ReadyToPlay : PlayerGameStatus.NotReadyToPlay; RaiseNetworkEvent(GetStatusMsg(player), player.Channel); // update server info to reflect new ready count diff --git a/Resources/Locale/en-US/commands/readyall-command.ftl b/Resources/Locale/en-US/commands/readyall-command.ftl new file mode 100644 index 0000000000..e5642f5536 --- /dev/null +++ b/Resources/Locale/en-US/commands/readyall-command.ftl @@ -0,0 +1,2 @@ +cmd-readyall-desc = Readies up all players in the lobby, except for observers. +cmd-readyall-help = Usage: readyall [bool] diff --git a/Resources/Locale/en-US/commands/toggleready-command.ftl b/Resources/Locale/en-US/commands/toggleready-command.ftl new file mode 100644 index 0000000000..0dfd3a9b9d --- /dev/null +++ b/Resources/Locale/en-US/commands/toggleready-command.ftl @@ -0,0 +1,2 @@ +cmd-toggleready-desc = Toggle the players ready status. +cmd-toggleready-help = Usage: toggleready