Add hack checks to painting tiles & walls

This commit is contained in:
MarioE 2013-10-04 18:37:56 -04:00
parent 1b3f105bbf
commit 149dbdf56d
4 changed files with 38 additions and 18 deletions

View file

@ -277,6 +277,8 @@ namespace TShockAPI
[Description("The number of seconds a player must wait before being respawned.")] public int RespawnSeconds = 3;
[Description("Disables a player if this number of tiles is painted within 1 second.")] public int TilePaintThreshold = 10;
/// <summary>
/// Reads a configuration file from a given path
/// </summary>

View file

@ -3192,11 +3192,14 @@ namespace TShockAPI
if (OnPaintTile(x, y, t))
return true;
if (TShock.CheckTilePermission(args.Player, x, y, true))
if ((DateTime.UtcNow - args.Player.LastThreat).TotalMilliseconds < 5000 ||
TShock.CheckTilePermission(args.Player, x, y, true) ||
TShock.CheckRangePermission(args.Player, x, y))
{
args.Player.SendData(PacketTypes.PaintTile, "", x, y, 0);
return true;
}
args.Player.PaintThreshold++;
return false;
}
@ -3209,11 +3212,14 @@ namespace TShockAPI
if (OnPaintTile(x, y, t))
return true;
if (TShock.CheckTilePermission(args.Player, x, y, true))
if ((DateTime.UtcNow - args.Player.LastThreat).TotalMilliseconds < 5000 ||
TShock.CheckTilePermission(args.Player, x, y, true) ||
TShock.CheckRangePermission(args.Player, x, y))
{
args.Player.SendData(PacketTypes.PaintWall, "", x, y, 0);
return true;
}
args.Player.PaintThreshold++;
return false;
}

View file

@ -49,10 +49,15 @@ namespace TShockAPI
public int TilePlaceThreshold { get; set; }
/// <summary>
/// The amount of liquid( in tiles ) that the player has placed in the last second.
/// The amount of liquid (in tiles) that the player has placed in the last second.
/// </summary>
public int TileLiquidThreshold { get; set; }
/// <summary>
/// The amount of tiles that the player has painted in the last second.
/// </summary>
public int PaintThreshold { get; set; }
/// <summary>
/// The number of projectiles created by the player in the last second.
/// </summary>
@ -60,7 +65,7 @@ namespace TShockAPI
/// <summary>
/// A timer to keep track of whether or not the player has recently thrown an explosive
// </summary>
/// </summary>
public int RecentFuse = 0;
/// <summary>
@ -144,11 +149,6 @@ namespace TShockAPI
/// </summary>
public DateTime LastThreat { get; set; }
/// <summary>
/// Not used, can be removed.
/// </summary>
public DateTime LastTileChangeNotify { get; set; }
public bool InitSpawn;
/// <summary>
@ -159,7 +159,7 @@ namespace TShockAPI
public Vector2 oldSpawn = Vector2.Zero;
/// <summary>
/// The last player that the player whispered with( to or from ).
/// The last player that the player whispered with (to or from).
/// </summary>
public TSPlayer LastWhisper;

View file

@ -668,11 +668,12 @@ namespace TShockAPI
//We don't want to revert the entire map in case of a disable.
player.TilesDestroyed.Clear();
}
if (player.TilesCreated != null)
{
if (player.TilePlaceThreshold >= Config.TilePlaceThreshold)
{
player.Disable("Reached TilePlace threshold.");
player.Disable("Reached TilePlace threshold");
TSPlayer.Server.RevertTiles(player.TilesCreated);
player.TilesCreated.Clear();
}
@ -686,10 +687,10 @@ namespace TShockAPI
player.RecentFuse--;
if ((TShock.Config.ServerSideCharacter) && (player.sX > 0) && (player.sY > 0))
{
player.TPlayer.SpawnX=player.sX;
player.TPlayer.SpawnY=player.sY;
}
{
player.TPlayer.SpawnX = player.sX;
player.TPlayer.SpawnY = player.sY;
}
if (player.RPPending >0)
{
@ -707,20 +708,31 @@ namespace TShockAPI
if (player.TileLiquidThreshold >= Config.TileLiquidThreshold)
{
player.Disable("Reached TileLiquid threshold.");
player.Disable("Reached TileLiquid threshold");
}
if (player.TileLiquidThreshold > 0)
{
player.TileLiquidThreshold = 0;
}
if (player.ProjectileThreshold >= Config.ProjectileThreshold)
{
player.Disable("Reached projectile threshold.");
player.Disable("Reached projectile threshold");
}
if (player.ProjectileThreshold > 0)
{
player.ProjectileThreshold = 0;
}
if (player.PaintThreshold >= Config.TilePaintThreshold)
{
player.Disable("Reached paint threshold");
}
if (player.PaintThreshold > 0)
{
player.PaintThreshold = 0;
}
if (player.Dead && (DateTime.Now - player.LastDeath).Seconds >= Config.RespawnSeconds && player.Difficulty != 2)
{
player.Spawn();