From e160accf1a5549e0b5fdebcec5a059a2b8b7b64f Mon Sep 17 00:00:00 2001 From: "Robin C. Ladiges" Date: Fri, 21 Jun 2024 22:10:52 +0200 Subject: [PATCH] fix: `tag seeking` command send new state to all players --- Server/Program.cs | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/Server/Program.cs b/Server/Program.cs index d9bf846..0ee539e 100644 --- a/Server/Program.cs +++ b/Server/Program.cs @@ -476,12 +476,17 @@ await c.Send(new ChangeStagePacket { if (!bool.TryParse(args[2], out bool seeking)) return $"Usage: tag seeking {args[1]} "; TagPacket tagPacket = new TagPacket { UpdateType = TagPacket.TagUpdate.State, - IsIt = seeking + IsIt = seeking, }; - if (args[1] == "*") - server.Broadcast(tagPacket); - else - client?.Send(tagPacket); + if (args[1] == "*") { + Parallel.ForEachAsync(server.Clients, async (client, _) => { + await server.Broadcast(tagPacket, client); + await client.Send(tagPacket); + }); + } else if (client != null) { + server.Broadcast(tagPacket, client); + client.Send(tagPacket); + } return $"Set {(args[1] == "*" ? "everyone" : args[1])} to {(seeking ? "seeker" : "hider")}"; } case "start" when args.Length > 2: {