From 6c22cfd57c1d3aac6348f84f5d63017b244b335d Mon Sep 17 00:00:00 2001 From: Patrikkk Date: Tue, 9 Jun 2020 00:39:04 +0200 Subject: [PATCH] Bouncer OnTileData - Add more checks on ReplaceTile/ReplaceWall --- CHANGELOG.md | 6 +++++- TShockAPI/Bouncer.cs | 8 ++++---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c73fa5b3..947c640c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,11 @@ This is the rolling changelog for TShock for Terraria. Use past tense when addin ## Upcoming changes * Installed new sprinklers! -* Fix issue where players could replace tiles with banned tiles without permission. (@Patrikkk) +* Fix multiple holes in Bouncer OnTileData. (@Patrikkk, @hakusaro) + * Issue where players could replace tiles with banned tiles without permission. + * Including replace action in TilePlace threshold incrementation, so players cannot bypass the threshold while replacing tiles/walls. + * Including check for maxTileSets when player is replacing tiles, so players cannot send invalid tile data through the replace tile action. + * Including a check for ReplaceWall when the tile is a Breakable/CutTile. ## TShock 4.4.0 (Pre-release 11) * New permission `tshock.tp.pylon` to enable teleporting via Teleportation Pylons (@QuiCM) diff --git a/TShockAPI/Bouncer.cs b/TShockAPI/Bouncer.cs index 934793e9..2de3b614 100644 --- a/TShockAPI/Bouncer.cs +++ b/TShockAPI/Bouncer.cs @@ -330,7 +330,7 @@ namespace TShockAPI return; } } - else if (action == EditAction.PlaceTile || action == EditAction.PlaceWall) + else if (action == EditAction.PlaceTile || action == EditAction.ReplaceTile || action == EditAction.PlaceWall || action == EditAction.ReplaceWall) { if ((action == EditAction.PlaceTile && TShock.Config.PreventInvalidPlaceStyle) && (MaxPlaceStyles.ContainsKey(editData) && style > MaxPlaceStyles[editData]) && @@ -437,7 +437,7 @@ namespace TShockAPI } if (TShock.Config.AllowCutTilesAndBreakables && Main.tileCut[tile.type]) { - if (action == EditAction.KillWall) + if (action == EditAction.KillWall || action == EditAction.ReplaceWall) { TShock.Log.ConsoleDebug("Bouncer / OnTileEdit rejected from sts allow cut from {0} {1} {2}", args.Player.Name, action, editData); args.Player.SendTileSquare(tileX, tileY, 1); @@ -536,7 +536,7 @@ namespace TShockAPI return; } - if ((action == EditAction.PlaceTile || action == EditAction.ReplaceTile || action == EditAction.PlaceWall) && !args.Player.HasPermission(Permissions.ignoreplacetiledetection)) + if ((action == EditAction.PlaceTile || action == EditAction.ReplaceTile || action == EditAction.PlaceWall || action == EditAction.ReplaceWall) && !args.Player.HasPermission(Permissions.ignoreplacetiledetection)) { args.Player.TilePlaceThreshold++; var coords = new Vector2(tileX, tileY); @@ -545,7 +545,7 @@ namespace TShockAPI args.Player.TilesCreated.Add(coords, Main.tile[tileX, tileY]); } - if ((action == EditAction.KillTile || action == EditAction.KillTileNoItem || action == EditAction.KillWall) && Main.tileSolid[Main.tile[tileX, tileY].type] && + if ((action == EditAction.KillTile || action == EditAction.KillTileNoItem || action == EditAction.ReplaceTile || action == EditAction.KillWall || action == EditAction.ReplaceWall) && Main.tileSolid[Main.tile[tileX, tileY].type] && !args.Player.HasPermission(Permissions.ignorekilltiledetection)) { args.Player.TileKillThreshold++;