Send DisconnectReason.Hacking to other players when disconnecting for cheating

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.
This commit is contained in:
js6pak committed 2024-08-24 16:51:51 +02:00
1 parent 6c91280125
commit a0f0a65cbf
1 file changed
+7 -2
+7 -2
View 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 =