]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Readyall and Toggleready commands to LEC. Fix an issue with ready button desync....
authorKyle Tyo <36606155+VerinSenpai@users.noreply.github.com>
Tue, 16 Sep 2025 21:25:17 +0000 (17:25 -0400)
committerGitHub <noreply@github.com>
Tue, 16 Sep 2025 21:25:17 +0000 (23:25 +0200)
* commit

* commit

* change lobby shell string.

Content.Client/Lobby/LobbyState.cs
Content.Server/Administration/Commands/ReadyAll.cs [deleted file]
Content.Server/Administration/Commands/ReadyAllCommand.cs [new file with mode: 0644]
Content.Server/GameTicking/Commands/ToggleReadyCommand.cs
Content.Server/GameTicking/GameTicker.Lobby.cs
Resources/Locale/en-US/commands/readyall-command.ftl [new file with mode: 0644]
Resources/Locale/en-US/commands/toggleready-command.ftl [new file with mode: 0644]

index 867a7bb8a5931f1965d2612b8c4dab6b8344bcda..538266e1a2f4ea2d26c3b4750a7efc447cda5d11 100644 (file)
@@ -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 (file)
index 530ba0e..0000000
+++ /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} <ready>";
-        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<GameTicker>();
-
-
-            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 (file)
index 0000000..a3fc499
--- /dev/null
@@ -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);
+    }
+}
index 34b504acbc9d143e8813e22c642a0dc83094ae8f..3debf37778444f109c303b3d1094767a819632f6 100644 (file)
@@ -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<GameTicker>();
-            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);
     }
 }
index 66c39ab469cf97264c438a033206999be4d4222f..6be7e3abcac91c715749f1ea36451a0b800e92a7 100644 (file)
@@ -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 (file)
index 0000000..e5642f5
--- /dev/null
@@ -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 (file)
index 0000000..0dfd3a9
--- /dev/null
@@ -0,0 +1,2 @@
+cmd-toggleready-desc = Toggle the players ready status.
+cmd-toggleready-help = Usage: toggleready <ready>