From 39edac96b05daa0521bcf62b79fbb3c218e186f6 Mon Sep 17 00:00:00 2001 From: Deathmax Date: Sun, 5 Jun 2011 14:16:58 +0800 Subject: [PATCH] Kill tile abuse now reverts the tiles. Water acts glitchy (as if there was no tiles) Things like trees and doors are not reverted --- TShockAPI/TSPlayer.cs | 1 + TShockAPI/TShock.cs | 24 ++++++++++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/TShockAPI/TSPlayer.cs b/TShockAPI/TSPlayer.cs index 60103e5b..7980fe16 100644 --- a/TShockAPI/TSPlayer.cs +++ b/TShockAPI/TSPlayer.cs @@ -8,6 +8,7 @@ namespace TShockAPI public class TSPlayer { public uint tileThreshold; + public Dictionary tilesDestroyed = new Dictionary(); public bool syncHP = false; public bool syncMP = false; diff --git a/TShockAPI/TShock.cs b/TShockAPI/TShock.cs index 7d3769c4..046a4ee0 100644 --- a/TShockAPI/TShock.cs +++ b/TShockAPI/TShock.cs @@ -200,7 +200,10 @@ namespace TShockAPI } if (type == 0 && BlacklistTiles[Main.tile[x, y].type] && Main.player[e.Msg.whoAmI].active) + { players[e.Msg.whoAmI].tileThreshold++; + players[e.Msg.whoAmI].tilesDestroyed.Add(new Position((float)x, (float)y), Main.tile[x, y]); + } } return; } @@ -510,6 +513,7 @@ namespace TShockAPI FileTools.WriteGrief((int)i); Tools.Kick((int)i, "Kill tile abuse detected."); Tools.Broadcast(Main.player[i].name + " was " + (ConfigurationManager.banTnt ? "banned" : "kicked") + " for kill tile abuse."); + RevertKillTile((int)i); } } players[i].tileThreshold = 0; @@ -733,5 +737,25 @@ namespace TShockAPI else return true; } + + public class Position + { + public float X; + public float Y; + public Position(float x, float y) { X = x; Y = y; } + } + + public static void RevertKillTile(int ply) + { + Tile[] tiles = new Tile[players[ply].tilesDestroyed.Count]; + players[ply].tilesDestroyed.Values.CopyTo(tiles, 0); + Position[] positions = new Position[players[ply].tilesDestroyed.Count]; + players[ply].tilesDestroyed.Keys.CopyTo(positions, 0); + for (int i = (players[ply].tilesDestroyed.Count - 1); i >= 0; i--) + { + Main.tile[(int)positions[i].X, (int)positions[i].Y] = tiles[i]; + NetMessage.SendData(17, -1, -1, "", 1, positions[i].X, positions[i].Y, (float)0); + } + } } } \ No newline at end of file