]> git.deb.at Git - rhonda/impostor.git/commitdiff
Don't dequeue a color when none are available
authorminiduikboot <mini@duikbo.at>
Sat, 16 Mar 2024 19:31:17 +0000 (20:31 +0100)
committerminiduikboot <mini@duikbo.at>
Thu, 4 Apr 2024 18:10:23 +0000 (20:10 +0200)
src/Impostor.Server/Net/Inner/Objects/InnerPlayerControl.cs

index cd9af281fbc5cbea005abcb5617148deccabe3f1..5a7fbac34218c6ce18ae368d5921605ef61c86f6 100644 (file)
@@ -713,26 +713,28 @@ namespace Impostor.Server.Net.Inner.Objects
             }
             else
             {
-                if (!RequestedColorId.Any())
+                if (RequestedColorId.Any())
                 {
-                    if (await sender.Client.ReportCheatAsync(RpcCalls.SetColor, CheatCategory.GameFlow, "Client sent SetColor for a player that didn't request it"))
+                    var expected = RequestedColorId.Dequeue();
+
+                    while (Game.Players.Any(x => x.Character != null && x.Character != this && x.Character.PlayerInfo.CurrentOutfit.Color == expected))
                     {
-                        return false;
+                        expected = (ColorType)(((byte)expected + 1) % ColorsCount);
                     }
-                }
 
-                var expected = RequestedColorId.Dequeue();
-
-                while (Game.Players.Any(x => x.Character != null && x.Character != this && x.Character.PlayerInfo.CurrentOutfit.Color == expected))
-                {
-                    expected = (ColorType)(((byte)expected + 1) % ColorsCount);
+                    if (color != expected)
+                    {
+                        if (await sender.Client.ReportCheatAsync(RpcCalls.SetColor, CheatCategory.GameFlow, "Client sent SetColor with incorrect color"))
+                        {
+                            await SetColorAsync(expected);
+                            return false;
+                        }
+                    }
                 }
-
-                if (color != expected)
+                else
                 {
-                    if (await sender.Client.ReportCheatAsync(RpcCalls.SetColor, CheatCategory.GameFlow, "Client sent SetColor with incorrect color"))
+                    if (await sender.Client.ReportCheatAsync(RpcCalls.SetColor, CheatCategory.GameFlow, "Client sent SetColor for a player that didn't request it"))
                     {
-                        await SetColorAsync(expected);
                         return false;
                     }
                 }