Fix for HealOtherPlayer exploit, also fix #1309
This commit is contained in:
parent
5be85b9864
commit
1460a7ad91
4 changed files with 59 additions and 3 deletions
|
|
@ -295,6 +295,10 @@ namespace TShockAPI
|
||||||
[Description("Disable a player if this number of projectiles is created within 1 second.")]
|
[Description("Disable a player if this number of projectiles is created within 1 second.")]
|
||||||
public int ProjectileThreshold = 50;
|
public int ProjectileThreshold = 50;
|
||||||
|
|
||||||
|
/// <summary>ProjectileThreshold - Disables a player if this number of projectiles is created within 1 second.</summary>
|
||||||
|
[Description("Disable a player if this number of projectiles is created within 1 second.")]
|
||||||
|
public int HealOtherThreshold = 50;
|
||||||
|
|
||||||
/// <summary>ProjIgnoreShrapnel - Whether or not to ignore shrapnel from crystal bullets for the projectile threshold count.</summary>
|
/// <summary>ProjIgnoreShrapnel - Whether or not to ignore shrapnel from crystal bullets for the projectile threshold count.</summary>
|
||||||
[Description("Ignore shrapnel from crystal bullets for projectile threshold.")]
|
[Description("Ignore shrapnel from crystal bullets for projectile threshold.")]
|
||||||
public bool ProjIgnoreShrapnel = true;
|
public bool ProjIgnoreShrapnel = true;
|
||||||
|
|
|
||||||
|
|
@ -1261,7 +1261,8 @@ namespace TShockAPI
|
||||||
{ PacketTypes.PlaceItemFrame, HandlePlaceItemFrame },
|
{ PacketTypes.PlaceItemFrame, HandlePlaceItemFrame },
|
||||||
{ PacketTypes.SyncExtraValue, HandleSyncExtraValue },
|
{ PacketTypes.SyncExtraValue, HandleSyncExtraValue },
|
||||||
{ PacketTypes.LoadNetModule, HandleLoadNetModule },
|
{ PacketTypes.LoadNetModule, HandleLoadNetModule },
|
||||||
{ PacketTypes.ToggleParty, HandleToggleParty }
|
{ PacketTypes.ToggleParty, HandleToggleParty },
|
||||||
|
{ PacketTypes.PlayerHealOther, HandleHealOther }
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1283,6 +1284,43 @@ namespace TShockAPI
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static bool HandleHealOther(GetDataHandlerArgs args)
|
||||||
|
{
|
||||||
|
byte plr = args.Data.ReadInt8();
|
||||||
|
short amount = args.Data.ReadInt16();
|
||||||
|
|
||||||
|
if (amount <= 0 || Main.player[plr] == null || !Main.player[plr].active)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (amount > TShock.Config.MaxDamage * 0.2)
|
||||||
|
{
|
||||||
|
args.Player.Disable("HealOtherPlayer max amount cheat attempt!", DisableFlags.WriteToLogAndConsole);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (args.TPlayer.whoAmI != plr && (args.TPlayer.team == 0 || args.TPlayer.team != Main.player[plr].team))
|
||||||
|
{
|
||||||
|
args.Player.Disable("HealOtherPlayer cheat attempt!", DisableFlags.WriteToLogAndConsole);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (args.Player.HealOtherThreshold > TShock.Config.HealOtherThreshold)
|
||||||
|
{
|
||||||
|
args.Player.Disable("Reached HealOtherPlayer threshold.", DisableFlags.WriteToLogAndConsole);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (TShock.CheckIgnores(args.Player) || (DateTime.UtcNow - args.Player.LastThreat).TotalMilliseconds < 5000)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
args.Player.HealOtherThreshold++;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
private static bool HandlePlayerSlot(GetDataHandlerArgs args)
|
private static bool HandlePlayerSlot(GetDataHandlerArgs args)
|
||||||
{
|
{
|
||||||
byte plr = args.Data.ReadInt8();
|
byte plr = args.Data.ReadInt8();
|
||||||
|
|
|
||||||
|
|
@ -94,6 +94,11 @@ namespace TShockAPI
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public int ProjectileThreshold { get; set; }
|
public int ProjectileThreshold { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The number of HealOtherPlayer packets sent by the player in the last second.
|
||||||
|
/// </summary>
|
||||||
|
public int HealOtherThreshold { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// A timer to keep track of whether or not the player has recently thrown an explosive
|
/// A timer to keep track of whether or not the player has recently thrown an explosive
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
||||||
|
|
@ -1030,6 +1030,15 @@ namespace TShockAPI
|
||||||
player.PaintThreshold = 0;
|
player.PaintThreshold = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (player.HealOtherThreshold > TShock.Config.HealOtherThreshold)
|
||||||
|
{
|
||||||
|
player.Disable("Reached HealOtherPlayer threshold", flags);
|
||||||
|
}
|
||||||
|
if (player.HealOtherThreshold > 0)
|
||||||
|
{
|
||||||
|
player.HealOtherThreshold = 0;
|
||||||
|
}
|
||||||
|
|
||||||
if (player.RespawnTimer > 0 && --player.RespawnTimer == 0 && player.Difficulty != 2)
|
if (player.RespawnTimer > 0 && --player.RespawnTimer == 0 && player.Difficulty != 2)
|
||||||
{
|
{
|
||||||
player.Spawn();
|
player.Spawn();
|
||||||
|
|
@ -1458,7 +1467,7 @@ namespace TShockAPI
|
||||||
/// <param name="args">The CommandEventArgs object</param>
|
/// <param name="args">The CommandEventArgs object</param>
|
||||||
private void ServerHooks_OnCommand(CommandEventArgs args)
|
private void ServerHooks_OnCommand(CommandEventArgs args)
|
||||||
{
|
{
|
||||||
if (args.Handled)
|
if (args.Handled || string.IsNullOrWhiteSpace(args.Command))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Damn you ThreadStatic and Redigit
|
// Damn you ThreadStatic and Redigit
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue