From 76c7b3fe8eac0d61841641c8b5860830502c26d0 Mon Sep 17 00:00:00 2001 From: MarioE Date: Wed, 15 Aug 2012 20:17:34 -0400 Subject: [PATCH] Chest + boulder exploit --- TShockAPI/GetDataHandlers.cs | 25 +++++++++++++++++-------- TShockAPI/Utils.cs | 11 +++++++++++ 2 files changed, 28 insertions(+), 8 deletions(-) diff --git a/TShockAPI/GetDataHandlers.cs b/TShockAPI/GetDataHandlers.cs index bd9c4336..f97f911d 100644 --- a/TShockAPI/GetDataHandlers.cs +++ b/TShockAPI/GetDataHandlers.cs @@ -1653,7 +1653,7 @@ namespace TShockAPI var fail = args.Data.ReadBoolean(); if (OnTileEdit(args.Player, tileX, tileY, tiletype, type, fail)) return true; - if (tileX < 0 || tileX >= Main.maxTilesX || tileY < 0 || tileY >= Main.maxTilesY) + if (!TShock.Utils.TileInRange(tileX, tileY)) return false; if (args.Player.Dead && TShock.Config.PreventDeadModification) @@ -1675,7 +1675,7 @@ namespace TShockAPI { return true; } - if ((tiletype == 29 || tiletype == 97) && TShock.Config.ServerSideInventory && TShock.Config.DisablePiggybanksOnSSI) + if (type == 1 && (tiletype == 29 || tiletype == 97) && TShock.Config.ServerSideInventory && TShock.Config.DisablePiggybanksOnSSI) { args.Player.SendMessage("You cannot place this tile, server side inventory is enabled.", Color.Red); args.Player.SendTileSquare(tileX, tileY); @@ -1688,12 +1688,15 @@ namespace TShockAPI args.Player.SendTileSquare(tileX, tileY); return true; } - if (type == 1 && tiletype == 21 && TShock.Utils.MaxChests()) - { - args.Player.SendMessage("Reached the world's max chest limit, unable to place more.", Color.Red); - args.Player.SendTileSquare(tileX, tileY); - return true; - } + if (type == 1 && tiletype == 21) + { + if (TShock.Utils.MaxChests()) + { + args.Player.SendMessage("Reached the world's max chest limit, unable to place more.", Color.Red); + args.Player.SendTileSquare(tileX, tileY); + return true; + } + } if (tiletype == 141 && !args.Player.Group.HasPermission(Permissions.usebanneditem) && TShock.Itembans.ItemIsBanned("Explosives", args.Player)) { @@ -1701,6 +1704,12 @@ namespace TShockAPI args.Player.SendTileSquare(tileX, tileY); return true; } + if ((TShock.Utils.TileInRange(tileX, tileY + 1) && Main.tile[tileX, tileY + 1].type == 138) || + (TShock.Utils.TileInRange(tileX + 1, tileY + 1) && Main.tile[tileX + 1, tileY + 1].type == 138)) + { + args.Player.SendTileSquare(tileX, tileY); + return true; + } } if (TShock.CheckIgnores(args.Player)) diff --git a/TShockAPI/Utils.cs b/TShockAPI/Utils.cs index 1e8a64e5..77d967bc 100644 --- a/TShockAPI/Utils.cs +++ b/TShockAPI/Utils.cs @@ -821,6 +821,17 @@ namespace TShockAPI return HashPassword(Encoding.UTF8.GetBytes(password)); } + /// + /// Checks if the given X and Y are in range for the world's tile array + /// + /// X + /// Y + /// True if the X and Y are in range + public bool TileInRange(int X, int Y) + { + return X >= 0 && Y >= 0 && X < Main.maxTilesX - 1 && Y < Main.maxTilesY - 1; + } + /// /// Checks if the string contains any unprintable characters ///