]> git.deb.at Git - rhonda/impostor.git/commitdiff
Reorder GameFull and GameStarted join errors
authorminiduikboot <mini@duikbo.at>
Tue, 7 Mar 2023 23:09:41 +0000 (00:09 +0100)
committerminiduikboot <mini@duikbo.at>
Wed, 8 Mar 2023 19:46:29 +0000 (20:46 +0100)
If a game is in progress, a player can't join it anyway and spam-joining
to see if a spot becomes available is useless. So the GameFull error is
more important than the GameStarted error, therefore reorder them.

Closes: #518
src/Impostor.Server/Net/State/Game.Incoming.cs

index 4c9e7b8804e645e4776e098b71c9ff3825295d9e..fb0751f460d1c6202d6d432ab4e572321a886a1f 100644 (file)
@@ -166,14 +166,6 @@ namespace Impostor.Server.Net.State
                 }
             }
 
-            // Check if;
-            // - The player is already in this game.
-            // - The game is full.
-            if (player?.Game != this && _players.Count >= Options.MaxPlayers)
-            {
-                return GameJoinResult.FromError(GameJoinError.GameFull);
-            }
-
             if (GameState == GameStates.Starting || GameState == GameStates.Started)
             {
                 return GameJoinResult.FromError(GameJoinError.GameStarted);
@@ -184,6 +176,14 @@ namespace Impostor.Server.Net.State
                 return GameJoinResult.FromError(GameJoinError.GameDestroyed);
             }
 
+            // Check if;
+            // - The player is already in this game.
+            // - The game is full.
+            if (player?.Game != this && _players.Count >= Options.MaxPlayers)
+            {
+                return GameJoinResult.FromError(GameJoinError.GameFull);
+            }
+
             var isNew = false;
 
             if (player == null || player.Game != this)