From 4043b660f5c8713bfddc419d712ca2aa83565b72 Mon Sep 17 00:00:00 2001 From: Deathmax Date: Thu, 23 Jun 2011 20:46:24 +0800 Subject: [PATCH] Prevent tile changes from 1 second after an explosive is thrown. --- TShockAPI/GetDataHandlers.cs | 10 ++++++++-- TShockAPI/TSPlayer.cs | 1 + 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/TShockAPI/GetDataHandlers.cs b/TShockAPI/GetDataHandlers.cs index c03fbeaa..ba0b120b 100755 --- a/TShockAPI/GetDataHandlers.cs +++ b/TShockAPI/GetDataHandlers.cs @@ -251,6 +251,13 @@ namespace TShockAPI if (!args.Player.TilesDestroyed.ContainsKey(coords)) args.Player.TilesDestroyed.Add(coords, Main.tile[x, y]); } + if (args.Player.LastExplosive != null) + if ((DateTime.UtcNow - args.Player.LastExplosive).TotalMilliseconds < 1000) + { + args.Player.SendMessage("Please wait another " + (1000 - (DateTime.UtcNow - args.Player.LastExplosive).TotalMilliseconds).ToString() + " milliseconds before placing/destroying tiles", Color.Red); + args.Player.SendTileSquare(x, y); + return true; + } return false; } @@ -320,11 +327,10 @@ namespace TShockAPI Log.Debug(string.Format("Explosive(PlyXY:{0}_{1}, Type:{2})", args.Player.TileX, args.Player.TileY, type)); if (ConfigurationManager.DisableBoom && (!args.Player.Group.HasPermission("useexplosives") || !args.Player.Group.HasPermission("ignoregriefdetection"))) { - //Lag will still allow the projectile to detonate. - //TODO: Stop KillTile for x period of time after projectile packet is received. Main.projectile[ident].type = 0; NetMessage.SendData((int)PacketTypes.ProjectileNew, args.Player.Index, -1, "", ident); args.Player.SendMessage("Explosives are disabled!", Color.Red); + args.Player.LastExplosive = DateTime.UtcNow; //return true; } else diff --git a/TShockAPI/TSPlayer.cs b/TShockAPI/TSPlayer.cs index 697589f3..a43a084c 100644 --- a/TShockAPI/TSPlayer.cs +++ b/TShockAPI/TSPlayer.cs @@ -36,6 +36,7 @@ namespace TShockAPI public int Index { get; protected set; } public DateTime LastPvpChange { get; protected set; } public Rectangle TempArea = new Rectangle(); + public DateTime LastExplosive { get; set; } public bool RealPlayer {