]> git.deb.at Git - rhonda/impostor.git/commitdiff
Debounce CheckMurder calls
authorminiduikboot <mini@duikbo.at>
Thu, 16 Nov 2023 16:55:50 +0000 (17:55 +0100)
committerminiduikboot <mini@duikbo.at>
Thu, 16 Nov 2023 16:55:50 +0000 (17:55 +0100)
In games where players have a high ping, they can get disconnected if
they try and murder a player twice. If a player tries to kill a player
again while they are still under a cooldown from their previous kill,
cancel their request if the game is server authoritive and don't process
it anymore if the game is host authoritive

src/Impostor.Server/Net/Inner/Objects/InnerPlayerControl.cs

index 21344cfc208edc73ef0d6f94d823c0a8bcadbc57..1cae0012fc84104834a9065f8adcc2da750aac10 100644 (file)
@@ -677,7 +677,12 @@ namespace Impostor.Server.Net.Inner.Objects
         {
             if (!PlayerInfo.CanMurder(Game, _dateTimeProvider))
             {
-                if (await sender.Client.ReportCheatAsync(RpcCalls.CheckMurder, "Client tried to murder too fast"))
+                if (IsMurdering == target)
+                {
+                    // This request was made too quickly by spamming the kill button, cancel it if we're in server authoritive mode
+                    return _game.IsHostAuthoritive;
+                }
+                else if (await sender.Client.ReportCheatAsync(RpcCalls.CheckMurder, "Client tried to murder too fast"))
                 {
                     return false;
                 }