From 98a93693dad0315dddf471bc7e9aa52165d88e26 Mon Sep 17 00:00:00 2001 From: stacey <57187883+moisterrific@users.noreply.github.com> Date: Thu, 27 May 2021 13:00:33 -0400 Subject: [PATCH 1/6] Fix Torch God biome torch swap issue Can confirm this fixes the issue but not sure if it opens any new exploits --- TShockAPI/Bouncer.cs | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/TShockAPI/Bouncer.cs b/TShockAPI/Bouncer.cs index ed4c031ad..78872b1e9 100644 --- a/TShockAPI/Bouncer.cs +++ b/TShockAPI/Bouncer.cs @@ -303,8 +303,20 @@ internal void OnTileEdit(object sender, GetDataHandlers.TileEditEventArgs args) args.Handled = true; return; } - - if (selectedItem.placeStyle != style) + + if (args.Player.TPlayer.unlockedBiomeTorches && args.Player.TPlayer.UsingBiomeTorches && + selectedItem.type == ItemID.Torch && editData == TileID.Torches) + { + if (style == TorchID.Demon || style == TorchID.Ice || + style == TorchID.Bone || style == TorchID.Desert || + style == TorchID.Corrupt || style == TorchID.Crimson || + style == TorchID.Hallowed || style == TorchID.Jungle) + { + args.Handled = false; + return; + } + } + else if (selectedItem.placeStyle != style) { TShock.Log.ConsoleError(string.Format("Bouncer / OnTileEdit rejected from (placestyle) {0} {1} {2} placeStyle: {3} expectedStyle: {4}", args.Player.Name, action, editData, style, selectedItem.placeStyle)); From 6592a880bcdf64e27c4ec535234342286f46796c Mon Sep 17 00:00:00 2001 From: stacey <57187883+moisterrific@users.noreply.github.com> Date: Thu, 27 May 2021 18:08:53 -0400 Subject: [PATCH 2/6] Improve on prev code Thanks to everyone who helped on discord --- TShockAPI/Bouncer.cs | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/TShockAPI/Bouncer.cs b/TShockAPI/Bouncer.cs index 78872b1e9..56aee30ef 100644 --- a/TShockAPI/Bouncer.cs +++ b/TShockAPI/Bouncer.cs @@ -304,26 +304,26 @@ internal void OnTileEdit(object sender, GetDataHandlers.TileEditEventArgs args) return; } - if (args.Player.TPlayer.unlockedBiomeTorches && args.Player.TPlayer.UsingBiomeTorches && - selectedItem.type == ItemID.Torch && editData == TileID.Torches) + if (args.Player.TPlayer.unlockedBiomeTorches && args.Player.TPlayer.UsingBiomeTorches + && selectedItem.type == ItemID.Torch && editData == TileID.Torches) { - if (style == TorchID.Demon || style == TorchID.Ice || - style == TorchID.Bone || style == TorchID.Desert || - style == TorchID.Corrupt || style == TorchID.Crimson || - style == TorchID.Hallowed || style == TorchID.Jungle) + if (style != TorchID.Demon + && style != TorchID.Ice + && style != TorchID.Bone + && style != TorchID.Desert + && style != TorchID.Corrupt + && style != TorchID.Crimson + && style != TorchID.Hallowed + && style != TorchID.Jungle + && selectedItem.placeStyle != style) { - args.Handled = false; + TShock.Log.ConsoleError(string.Format("Bouncer / OnTileEdit rejected from (placestyle) {0} {1} {2} placeStyle: {3} expectedStyle: {4}", + args.Player.Name, action, editData, style, selectedItem.placeStyle)); + args.Player.SendTileSquare(tileX, tileY, 1); + args.Handled = true; return; } } - else if (selectedItem.placeStyle != style) - { - TShock.Log.ConsoleError(string.Format("Bouncer / OnTileEdit rejected from (placestyle) {0} {1} {2} placeStyle: {3} expectedStyle: {4}", - args.Player.Name, action, editData, style, selectedItem.placeStyle)); - args.Player.SendTileSquare(tileX, tileY, 1); - args.Handled = true; - return; - } } if (action == EditAction.KillTile && !Main.tileCut[tile.type] && !breakableTiles.Contains(tile.type)) From 8b3e1b68c91e162f12e75b968b09f653e4679d8d Mon Sep 17 00:00:00 2001 From: stacey <57187883+moisterrific@users.noreply.github.com> Date: Thu, 27 May 2021 18:11:45 -0400 Subject: [PATCH 3/6] Update CHANGELOG.md --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 246db4f56..6f3b3fb25 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,7 @@ This is the rolling changelog for TShock for Terraria. Use past tense when addin * Fixed torchgod settings to include whether or not torchgod has been fought by the player before and respect `usingBiomeTorches` setting. (@Quinci135) * Fixed /worldmode not synchronising data to players after updating the world state (@bartico6, @Arthri) * Added `OnSendNetData` hook to TSAPI, which enables developers to intercept traffic being sent from the server to clients. (@Stealownz) +* Fixed Torch God's Favor biome torch placement being rejected by the server. (@moisterrific) ## TShock 4.5.3 * Added permissions for using Teleportation Potions, Magic Conch, and Demon Conch. (@drunderscore) From a5eeb0788a42007dfbf2d27585beccfc5dac6af5 Mon Sep 17 00:00:00 2001 From: stacey <57187883+moisterrific@users.noreply.github.com> Date: Thu, 27 May 2021 18:39:50 -0400 Subject: [PATCH 4/6] Even better solution --- TShockAPI/Bouncer.cs | 25 +++++++------------------ 1 file changed, 7 insertions(+), 18 deletions(-) diff --git a/TShockAPI/Bouncer.cs b/TShockAPI/Bouncer.cs index 56aee30ef..e85da8e96 100644 --- a/TShockAPI/Bouncer.cs +++ b/TShockAPI/Bouncer.cs @@ -304,25 +304,14 @@ internal void OnTileEdit(object sender, GetDataHandlers.TileEditEventArgs args) return; } - if (args.Player.TPlayer.unlockedBiomeTorches && args.Player.TPlayer.UsingBiomeTorches - && selectedItem.type == ItemID.Torch && editData == TileID.Torches) + if ((args.Player.TPlayer.BiomeTorchHoldStyle(style) != args.Player.TPlayer.BiomeTorchPlaceStyle(style)) + && (selectedItem.placeStyle != style)) { - if (style != TorchID.Demon - && style != TorchID.Ice - && style != TorchID.Bone - && style != TorchID.Desert - && style != TorchID.Corrupt - && style != TorchID.Crimson - && style != TorchID.Hallowed - && style != TorchID.Jungle - && selectedItem.placeStyle != style) - { - TShock.Log.ConsoleError(string.Format("Bouncer / OnTileEdit rejected from (placestyle) {0} {1} {2} placeStyle: {3} expectedStyle: {4}", - args.Player.Name, action, editData, style, selectedItem.placeStyle)); - args.Player.SendTileSquare(tileX, tileY, 1); - args.Handled = true; - return; - } + TShock.Log.ConsoleError("Bouncer / OnTileEdit rejected from (placestyle) {0} {1} {2} placeStyle: {3} expectedStyle: {4}", + args.Player.Name, action, editData, style, selectedItem.placeStyle); + args.Player.SendTileSquare(tileX, tileY, 1); + args.Handled = true; + return; } } From d78de5719e4c6afa2f8529d9bd55ae3e048fd09f Mon Sep 17 00:00:00 2001 From: stacey <57187883+moisterrific@users.noreply.github.com> Date: Thu, 27 May 2021 18:51:27 -0400 Subject: [PATCH 5/6] Fix formatting --- TShockAPI/Bouncer.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/TShockAPI/Bouncer.cs b/TShockAPI/Bouncer.cs index e85da8e96..a3680f5cc 100644 --- a/TShockAPI/Bouncer.cs +++ b/TShockAPI/Bouncer.cs @@ -305,7 +305,7 @@ internal void OnTileEdit(object sender, GetDataHandlers.TileEditEventArgs args) } if ((args.Player.TPlayer.BiomeTorchHoldStyle(style) != args.Player.TPlayer.BiomeTorchPlaceStyle(style)) - && (selectedItem.placeStyle != style)) + && (selectedItem.placeStyle != style)) { TShock.Log.ConsoleError("Bouncer / OnTileEdit rejected from (placestyle) {0} {1} {2} placeStyle: {3} expectedStyle: {4}", args.Player.Name, action, editData, style, selectedItem.placeStyle); From a369a25084d6a499b4003d5ae6ea1b162659aef4 Mon Sep 17 00:00:00 2001 From: stacey <57187883+moisterrific@users.noreply.github.com> Date: Fri, 28 May 2021 23:12:39 -0400 Subject: [PATCH 6/6] Update TShockAPI/Bouncer.cs Co-authored-by: Lucas Nicodemus --- TShockAPI/Bouncer.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/TShockAPI/Bouncer.cs b/TShockAPI/Bouncer.cs index a3680f5cc..514583cb0 100644 --- a/TShockAPI/Bouncer.cs +++ b/TShockAPI/Bouncer.cs @@ -308,7 +308,7 @@ internal void OnTileEdit(object sender, GetDataHandlers.TileEditEventArgs args) && (selectedItem.placeStyle != style)) { TShock.Log.ConsoleError("Bouncer / OnTileEdit rejected from (placestyle) {0} {1} {2} placeStyle: {3} expectedStyle: {4}", - args.Player.Name, action, editData, style, selectedItem.placeStyle); + args.Player.Name, action, editData, style, selectedItem.placeStyle); args.Player.SendTileSquare(tileX, tileY, 1); args.Handled = true; return;