]> git.deb.at Git - rhonda/impostor.git/commitdiff
Send DisconnectReason.Hacking to other players when disconnecting for cheating
authorjs6pak <me@6pak.dev>
Fri, 23 Aug 2024 18:28:56 +0000 (20:28 +0200)
committerjs6pak <me@6pak.dev>
Sat, 24 Aug 2024 14:51:51 +0000 (16:51 +0200)
Base game doesn't have a specific message for it so it results in a generic "left the game due to error" but it's still better than the default "left the game".
This also allows client side mods to fix the message.

src/Impostor.Server/Net/Client.cs

index dfbc990656a844a95123f79ac55536c79267a6db..c5c4d161064eb7bf06b85037e8b334c315b39903 100644 (file)
@@ -86,9 +86,14 @@ namespace Impostor.Server.Net
 
             _logger.LogWarning("Client {Name} ({Id}) was caught cheating: [{SupportCode}] [{Context}-{Category}] {Message}", Name, Id, supportCode, context.Name, category, message);
 
-            if (_antiCheatConfig.BanIpFromGame)
+            if (Player is { } player)
             {
-                Player?.Game.BanIp(Connection.EndPoint.Address);
+                if (_antiCheatConfig.BanIpFromGame)
+                {
+                    player.Game.BanIp(Connection.EndPoint.Address);
+                }
+
+                await player.Game.HandleRemovePlayer(Id, DisconnectReason.Hacking);
             }
 
             var disconnectMessage =