From 013ef4ce98767d8a18964c37ba9f8c042e2a9a3b Mon Sep 17 00:00:00 2001 From: Rustly Date: Mon, 15 Jun 2020 12:37:49 -0500 Subject: [PATCH 1/6] fix snake rope thingy --- TShockAPI/Bouncer.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/TShockAPI/Bouncer.cs b/TShockAPI/Bouncer.cs index dc62f221..c7b28a9c 100644 --- a/TShockAPI/Bouncer.cs +++ b/TShockAPI/Bouncer.cs @@ -467,7 +467,7 @@ namespace TShockAPI if (!args.Player.IsInRange(tileX, tileY)) { - if (action == EditAction.PlaceTile && (editData == TileID.Rope || editData == TileID.SilkRope || editData == TileID.VineRope || editData == TileID.WebRope)) + if (action == EditAction.PlaceTile && (editData == TileID.Rope || editData == TileID.SilkRope || editData == TileID.VineRope || editData == TileID.WebRope || editData == TileID.MysticSnakeRope)) { args.Handled = false; return; @@ -1644,7 +1644,8 @@ namespace TShockAPI if ((type != TileID.Rope || type != TileID.SilkRope || type != TileID.VineRope - || type != TileID.WebRope) + || type != TileID.WebRope + || type != TileID.MysticSnakeRope) && !args.Player.IsInRange(x, y)) { TShock.Log.ConsoleDebug("Bouncer / OnPlaceObject rejected range checks from {0}", args.Player.Name); From 01bae0475d9c063866341cd38561363e8e0089d3 Mon Sep 17 00:00:00 2001 From: Rustly Date: Mon, 15 Jun 2020 13:32:42 -0500 Subject: [PATCH 2/6] apply the rest of fixes for snake flute, prevent players from seeing the npc perm error on join --- TShockAPI/Bouncer.cs | 40 +++++++++++-------- .../NetModules/CreativePowerHandler.cs | 7 ++++ TShockAPI/TSPlayer.cs | 5 +++ 3 files changed, 35 insertions(+), 17 deletions(-) diff --git a/TShockAPI/Bouncer.cs b/TShockAPI/Bouncer.cs index c7b28a9c..4debdd4d 100644 --- a/TShockAPI/Bouncer.cs +++ b/TShockAPI/Bouncer.cs @@ -295,7 +295,8 @@ namespace TShockAPI } // If the tile is a pickaxe tile and they aren't selecting a pickaxe, they're hacking. // Item frames can be modified without pickaxe tile. - else if (tile.type != TileID.ItemFrame + //also add an exception for snake coils, they can be removed when the player places a new one or after x amount of time + else if (tile.type != TileID.ItemFrame && tile.type != TileID.MysticSnakeRope && !Main.tileAxe[tile.type] && !Main.tileHammer[tile.type] && tile.wall == 0 && args.Player.TPlayer.mount.Type != 8 && selectedItem.pick == 0 && !ItemID.Sets.Explosives[selectedItem.netID] && args.Player.RecentFuse == 0) { TShock.Log.ConsoleDebug("Bouncer / OnTileEdit rejected from (pick) {0} {1} {2}", args.Player.Name, action, editData); @@ -465,7 +466,8 @@ namespace TShockAPI return; } - if (!args.Player.IsInRange(tileX, tileY)) + //make sure it isnt a snake coil related edit so it doesnt spam debug logs with range check failures + if ((action == EditAction.PlaceTile && editData != TileID.MysticSnakeRope) || (action == EditAction.KillTile && tile.type != TileID.MysticSnakeRope) && !args.Player.IsInRange(tileX, tileY)) { if (action == EditAction.PlaceTile && (editData == TileID.Rope || editData == TileID.SilkRope || editData == TileID.VineRope || editData == TileID.WebRope || editData == TileID.MysticSnakeRope)) { @@ -536,23 +538,27 @@ namespace TShockAPI return; } - if ((action == EditAction.PlaceTile || action == EditAction.ReplaceTile || action == EditAction.PlaceWall || action == EditAction.ReplaceWall) && !args.Player.HasPermission(Permissions.ignoreplacetiledetection)) + //snake coil can allow massive amounts of tile edits so it gets an exception + if (!((action == EditAction.PlaceTile && editData == TileID.MysticSnakeRope) || (action == EditAction.KillTile && tile.type == TileID.MysticSnakeRope))) { - args.Player.TilePlaceThreshold++; - var coords = new Vector2(tileX, tileY); - lock (args.Player.TilesCreated) - if (!args.Player.TilesCreated.ContainsKey(coords)) - args.Player.TilesCreated.Add(coords, Main.tile[tileX, tileY]); - } + 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); + lock (args.Player.TilesCreated) + if (!args.Player.TilesCreated.ContainsKey(coords)) + args.Player.TilesCreated.Add(coords, Main.tile[tileX, tileY]); + } - 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++; - var coords = new Vector2(tileX, tileY); - lock (args.Player.TilesDestroyed) - if (!args.Player.TilesDestroyed.ContainsKey(coords)) - args.Player.TilesDestroyed.Add(coords, Main.tile[tileX, tileY]); + 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++; + var coords = new Vector2(tileX, tileY); + lock (args.Player.TilesDestroyed) + if (!args.Player.TilesDestroyed.ContainsKey(coords)) + args.Player.TilesDestroyed.Add(coords, Main.tile[tileX, tileY]); + } } args.Handled = false; return; diff --git a/TShockAPI/Handlers/NetModules/CreativePowerHandler.cs b/TShockAPI/Handlers/NetModules/CreativePowerHandler.cs index ac9c7c34..edd50bdb 100644 --- a/TShockAPI/Handlers/NetModules/CreativePowerHandler.cs +++ b/TShockAPI/Handlers/NetModules/CreativePowerHandler.cs @@ -56,6 +56,13 @@ namespace TShockAPI.Handlers.NetModules string permission = PowerToPermissionMap[powerType]; + //prevent being told about the spawnrate permission on join until relogic fixes + if (!player.HasReceivedNPCPermissionError && powerType == CreativePowerTypes.SetSpawnRate) + { + player.HasReceivedNPCPermissionError = true; + return false; + } + if (!player.HasPermission(permission)) { player.SendErrorMessage("You do not have permission to {0}.", PermissionToDescriptionMap[permission]); diff --git a/TShockAPI/TSPlayer.cs b/TShockAPI/TSPlayer.cs index ade16234..d5db832f 100644 --- a/TShockAPI/TSPlayer.cs +++ b/TShockAPI/TSPlayer.cs @@ -111,6 +111,11 @@ namespace TShockAPI return found; } + /// + /// Used in preventing players from seeing the npc spawnrate permission error on join. + /// + internal bool HasReceivedNPCPermissionError { get; set; } + /// /// The amount of tiles that the player has killed in the last second. /// From 2f22271dbed9e34a761ab94d76b5f5e6f0146099 Mon Sep 17 00:00:00 2001 From: Rustly Date: Mon, 15 Jun 2020 13:33:56 -0500 Subject: [PATCH 3/6] Update CHANGELOG.md --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 593e7c05..206d868f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,8 @@ This is the rolling changelog for TShock for Terraria. Use past tense when adding new entries; sign your name off when you add or change something. This should primarily be things like user changes, not necessarily codebase changes unless it's really relevant or large. ## Upcoming changes +* Snake charmer's flute should function normally now. +* Prevented players from seeing the npc spawnrate change permission error on join. * Installed new sprinklers! * Organized parameters by category and relevance in the `config.json` file. (@kubedzero) * Fix multiple holes in Bouncer OnTileData. (@Patrikkk, @hakusaro) From b454d3fcb7bc9ef1047e90b983fbf4f77a3b7903 Mon Sep 17 00:00:00 2001 From: Rustly Date: Thu, 18 Jun 2020 16:46:20 -0500 Subject: [PATCH 4/6] Update CHANGELOG.md --- CHANGELOG.md | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 206d868f..08568ad1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,8 +3,11 @@ This is the rolling changelog for TShock for Terraria. Use past tense when adding new entries; sign your name off when you add or change something. This should primarily be things like user changes, not necessarily codebase changes unless it's really relevant or large. ## Upcoming changes -* Snake charmer's flute should function normally now. -* Prevented players from seeing the npc spawnrate change permission error on join. +* Fixed various bugs related to Snake Charmer's Flute. (@rustly) + The entirety of the snake now places. + The old snake now removes when placing a new snake. + Players are no longer disabled for breaking TilePlace/TileKill thresholds when modifying snakes. +* Prevented players from seeing the npc spawnrate change permission error on join. (@rustly) * Installed new sprinklers! * Organized parameters by category and relevance in the `config.json` file. (@kubedzero) * Fix multiple holes in Bouncer OnTileData. (@Patrikkk, @hakusaro) From ce953c6eaa5f3c404bf726879e7c6226a625c933 Mon Sep 17 00:00:00 2001 From: Rustly <43079937+Rustly@users.noreply.github.com> Date: Thu, 18 Jun 2020 16:48:56 -0500 Subject: [PATCH 5/6] forgot github is funny with line breaks --- CHANGELOG.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 08568ad1..dbd04331 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,10 +3,10 @@ This is the rolling changelog for TShock for Terraria. Use past tense when adding new entries; sign your name off when you add or change something. This should primarily be things like user changes, not necessarily codebase changes unless it's really relevant or large. ## Upcoming changes -* Fixed various bugs related to Snake Charmer's Flute. (@rustly) - The entirety of the snake now places. - The old snake now removes when placing a new snake. - Players are no longer disabled for breaking TilePlace/TileKill thresholds when modifying snakes. +* Fixed various bugs related to Snake Charmer's Flute. (@rustly) + The entirety of the snake now places. + The old snake now removes when placing a new snake. + Players are no longer disabled for breaking TilePlace/TileKill thresholds when modifying snakes. * Prevented players from seeing the npc spawnrate change permission error on join. (@rustly) * Installed new sprinklers! * Organized parameters by category and relevance in the `config.json` file. (@kubedzero) From c51f8abcbfeed7c3cb421258fe09a46f3b448948 Mon Sep 17 00:00:00 2001 From: Rustly <43079937+Rustly@users.noreply.github.com> Date: Thu, 18 Jun 2020 16:51:18 -0500 Subject: [PATCH 6/6] totally didnt update changelog again --- CHANGELOG.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index dbd04331..27171d4c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,9 +4,9 @@ This is the rolling changelog for TShock for Terraria. Use past tense when addin ## Upcoming changes * Fixed various bugs related to Snake Charmer's Flute. (@rustly) - The entirety of the snake now places. - The old snake now removes when placing a new snake. - Players are no longer disabled for breaking TilePlace/TileKill thresholds when modifying snakes. + * The entirety of the snake now places. + * The old snake now removes when placing a new snake. + * Players are no longer disabled for breaking TilePlace/TileKill thresholds when modifying snakes. * Prevented players from seeing the npc spawnrate change permission error on join. (@rustly) * Installed new sprinklers! * Organized parameters by category and relevance in the `config.json` file. (@kubedzero)