From: Jakub Staroń Date: Thu, 12 Nov 2020 03:04:05 +0000 (+0100) Subject: Ban kill cooldown bypass (#123) X-Git-Tag: v1.2.2~26 X-Git-Url: https://git.deb.at/?a=commitdiff_plain;h=b4380bc07a72c84efe1973fb5b1934013381ecb5;p=rhonda%2Fimpostor.git Ban kill cooldown bypass (#123) * Ban kill cooldown bypass * Fix typo --- diff --git a/src/Impostor.Server/Net/Inner/Objects/InnerPlayerControl.cs b/src/Impostor.Server/Net/Inner/Objects/InnerPlayerControl.cs index 7762a7e..14b2687 100644 --- a/src/Impostor.Server/Net/Inner/Objects/InnerPlayerControl.cs +++ b/src/Impostor.Server/Net/Inner/Objects/InnerPlayerControl.cs @@ -282,6 +282,13 @@ namespace Impostor.Server.Net.Inner.Objects throw new ImpostorCheatException($"Client sent {nameof(RpcCalls.MurderPlayer)} as crewmate"); } + if (!sender.Character.PlayerInfo.CanMurder(_game)) + { + throw new ImpostorCheatException($"Client sent {nameof(RpcCalls.MurderPlayer)} too fast"); + } + + sender.Character.PlayerInfo.LastMurder = DateTimeOffset.UtcNow; + var player = reader.ReadNetObject(_game); if (!player.PlayerInfo.IsDead) { diff --git a/src/Impostor.Server/Net/Inner/Objects/InnerPlayerInfo.cs b/src/Impostor.Server/Net/Inner/Objects/InnerPlayerInfo.cs index 3982a30..cbd3a9d 100644 --- a/src/Impostor.Server/Net/Inner/Objects/InnerPlayerInfo.cs +++ b/src/Impostor.Server/Net/Inner/Objects/InnerPlayerInfo.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using Impostor.Api.Games; using Impostor.Api.Innersloth; using Impostor.Api.Net.Inner.Objects; using Impostor.Api.Net.Messages; @@ -37,6 +38,13 @@ namespace Impostor.Server.Net.Inner.Objects public List Tasks { get; internal set; } + public DateTimeOffset LastMurder { get; set; } + + public bool CanMurder(IGame game) + { + return DateTimeOffset.UtcNow.Subtract(LastMurder).TotalSeconds >= game.Options.KillCooldown; + } + public void Serialize(IMessageWriter writer) { throw new NotImplementedException(); @@ -62,4 +70,4 @@ namespace Impostor.Server.Net.Inner.Objects } } } -} \ No newline at end of file +}