Move TShock.CheckRangePermission to TSPlayer
TShock.CheckRangePermission is now TSPlayer.IsInRange, but the most important thing is that this method returns the opposite of what the original did, so all of the calls that would go to it are now inverted.
This commit is contained in:
parent
d4cb07379b
commit
09121368e4
5 changed files with 35 additions and 38 deletions
|
|
@ -60,6 +60,7 @@ This is the rolling changelog for TShock for Terraria. Use past tense when addin
|
|||
* Added `TSPlayer.CheckIgnores()` and removed `TShock.CheckIgnores(TSPlayer)`. (@hakusaro)
|
||||
* Hooks inside TShock can now be registered with their `Register` method and can be prioritized according to the TShock HandlerList system. (@hakusaro)
|
||||
* Fix message requiring login not using the command specifier set in the config file. (@hakusaro)
|
||||
* Move `TShock.CheckRangePermission()` to `TSPlayer.IsInRange` which **returns the opposite** of what the previous method did (see updated docs). (@hakusaro)
|
||||
|
||||
## TShock 4.3.25
|
||||
* Fixed a critical exploit in the Terraria protocol that could cause massive unpreventable world corruption as well as a number of other problems. Thanks to @bartico6 for reporting. Fixed by the efforts of @QuiCM, @hakusaro, and tips in the right directioon from @bartico6.
|
||||
|
|
|
|||
|
|
@ -83,7 +83,7 @@ namespace TShockAPI
|
|||
return;
|
||||
}
|
||||
|
||||
if (TShock.CheckRangePermission(args.Player, args.X, args.Y))
|
||||
if (!args.Player.IsInRange(args.X, args.Y))
|
||||
{
|
||||
NetMessage.SendData((int)PacketTypes.UpdateTileEntity, -1, -1, NetworkText.Empty, args.ItemFrame.ID, 0, 1);
|
||||
args.Handled = true;
|
||||
|
|
@ -138,7 +138,7 @@ namespace TShockAPI
|
|||
return;
|
||||
}
|
||||
|
||||
if (TShock.CheckRangePermission(args.Player, args.X, args.Y))
|
||||
if (!args.Player.IsInRange(args.X, args.Y))
|
||||
{
|
||||
args.Handled = true;
|
||||
return;
|
||||
|
|
@ -253,7 +253,7 @@ namespace TShockAPI
|
|||
}
|
||||
|
||||
if (TShock.Config.RangeChecks &&
|
||||
TShock.CheckRangePermission(args.Player, (int)(Main.npc[id].position.X / 16f), (int)(Main.npc[id].position.Y / 16f), 128))
|
||||
!args.Player.IsInRange((int)(Main.npc[id].position.X / 16f), (int)(Main.npc[id].position.Y / 16f), 128))
|
||||
{
|
||||
args.Player.SendData(PacketTypes.NpcUpdate, "", id);
|
||||
args.Handled = true;
|
||||
|
|
@ -319,7 +319,7 @@ namespace TShockAPI
|
|||
return;
|
||||
}
|
||||
|
||||
if (TShock.CheckRangePermission(args.Player, TShock.Players[id].TileX, TShock.Players[id].TileY, 100))
|
||||
if (!args.Player.IsInRange(TShock.Players[id].TileX, TShock.Players[id].TileY, 100))
|
||||
{
|
||||
args.Player.SendData(PacketTypes.PlayerHp, "", id);
|
||||
args.Player.SendData(PacketTypes.PlayerUpdate, "", id);
|
||||
|
|
@ -373,7 +373,7 @@ namespace TShockAPI
|
|||
// client side (but only if it passed the range check) (i.e., return false)
|
||||
if (type == 0)
|
||||
{
|
||||
if (TShock.CheckRangePermission(args.Player, (int)(Main.item[id].position.X / 16f), (int)(Main.item[id].position.Y / 16f)))
|
||||
if (!args.Player.IsInRange((int)(Main.item[id].position.X / 16f), (int)(Main.item[id].position.Y / 16f)))
|
||||
{
|
||||
// Causes item duplications. Will be re added if necessary
|
||||
//args.Player.SendData(PacketTypes.ItemDrop, "", id);
|
||||
|
|
@ -385,7 +385,7 @@ namespace TShockAPI
|
|||
return;
|
||||
}
|
||||
|
||||
if (TShock.CheckRangePermission(args.Player, (int)(pos.X / 16f), (int)(pos.Y / 16f)))
|
||||
if (!args.Player.IsInRange((int)(pos.X / 16f), (int)(pos.Y / 16f)))
|
||||
{
|
||||
args.Player.SendData(PacketTypes.ItemDrop, "", id);
|
||||
args.Handled = true;
|
||||
|
|
@ -465,7 +465,7 @@ namespace TShockAPI
|
|||
return;
|
||||
}
|
||||
|
||||
if (TShock.CheckRangePermission(args.Player, TShock.Players[id].TileX, TShock.Players[id].TileY, 50))
|
||||
if (!args.Player.IsInRange(TShock.Players[id].TileX, TShock.Players[id].TileY, 50))
|
||||
{
|
||||
args.Player.SendData(PacketTypes.PlayerAddBuff, "", id);
|
||||
args.Handled = true;
|
||||
|
|
@ -516,7 +516,7 @@ namespace TShockAPI
|
|||
return;
|
||||
}
|
||||
|
||||
if (TShock.CheckRangePermission(args.Player, Main.chest[id].x, Main.chest[id].y))
|
||||
if (!args.Player.IsInRange(Main.chest[id].x, Main.chest[id].y))
|
||||
{
|
||||
args.Handled = true;
|
||||
return;
|
||||
|
|
@ -544,7 +544,7 @@ namespace TShockAPI
|
|||
return;
|
||||
}
|
||||
|
||||
if (TShock.CheckRangePermission(args.Player, x, y))
|
||||
if (!args.Player.IsInRange(x, y))
|
||||
{
|
||||
args.Player.SendData(PacketTypes.UpdateNPCHome, "", id, Main.npc[id].homeTileX, Main.npc[id].homeTileY,
|
||||
Convert.ToByte(Main.npc[id].homeless));
|
||||
|
|
@ -564,7 +564,7 @@ namespace TShockAPI
|
|||
return;
|
||||
}
|
||||
|
||||
if (TShock.CheckRangePermission(args.Player, args.X, args.Y))
|
||||
if (!args.Player.IsInRange(args.X, args.Y))
|
||||
{
|
||||
args.Handled = true;
|
||||
return;
|
||||
|
|
@ -632,7 +632,7 @@ namespace TShockAPI
|
|||
return;
|
||||
}
|
||||
|
||||
if (TShock.CheckRangePermission(args.Player, tileX, tileY))
|
||||
if (!args.Player.IsInRange(tileX, tileY))
|
||||
{
|
||||
args.Player.SendTileSquare(tileX, tileY, 3);
|
||||
args.Handled = true;
|
||||
|
|
@ -765,7 +765,7 @@ namespace TShockAPI
|
|||
return;
|
||||
}
|
||||
|
||||
if (TShock.CheckRangePermission(args.Player, tileX, tileY, 16))
|
||||
if (!args.Player.IsInRange(tileX, tileY, 16))
|
||||
{
|
||||
args.Player.SendTileSquare(tileX, tileY, 1);
|
||||
args.Handled = true;
|
||||
|
|
@ -1160,7 +1160,7 @@ namespace TShockAPI
|
|||
|| type != TileID.SilkRope
|
||||
|| type != TileID.VineRope
|
||||
|| type != TileID.WebRope)
|
||||
&& TShock.CheckRangePermission(args.Player, x, y))
|
||||
&& !args.Player.IsInRange(x, y))
|
||||
{
|
||||
args.Player.SendTileSquare(x, y, 4);
|
||||
args.Handled = true;
|
||||
|
|
@ -1484,7 +1484,7 @@ namespace TShockAPI
|
|||
return;
|
||||
}
|
||||
|
||||
if (TShock.CheckRangePermission(args.Player, tileX, tileY))
|
||||
if (!args.Player.IsInRange(tileX, tileY))
|
||||
{
|
||||
if (action == EditAction.PlaceTile && (editData == TileID.Rope || editData == TileID.SilkRope || editData == TileID.VineRope || editData == TileID.WebRope))
|
||||
{
|
||||
|
|
@ -1661,7 +1661,7 @@ namespace TShockAPI
|
|||
var tile = Main.tile[realx, realy];
|
||||
var newtile = tiles[x, y];
|
||||
if (TShock.CheckTilePermission(args.Player, realx, realy) ||
|
||||
TShock.CheckRangePermission(args.Player, realx, realy))
|
||||
!args.Player.IsInRange(realx, realy))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2578,7 +2578,7 @@ namespace TShockAPI
|
|||
return true;
|
||||
}
|
||||
|
||||
if (TShock.CheckRangePermission(args.Player, x, y))
|
||||
if (!args.Player.IsInRange(x, y))
|
||||
{
|
||||
args.Player.SendData(PacketTypes.SignNew, "", id);
|
||||
return true;
|
||||
|
|
@ -2898,7 +2898,7 @@ namespace TShockAPI
|
|||
|
||||
if (args.Player.IsBouncerThrottled() ||
|
||||
TShock.CheckTilePermission(args.Player, x, y, true) ||
|
||||
TShock.CheckRangePermission(args.Player, x, y))
|
||||
!args.Player.IsInRange(x, y))
|
||||
{
|
||||
args.Player.SendData(PacketTypes.PaintTile, "", x, y, Main.tile[x, y].color());
|
||||
return true;
|
||||
|
|
@ -2942,7 +2942,7 @@ namespace TShockAPI
|
|||
|
||||
if (args.Player.IsBouncerThrottled() ||
|
||||
TShock.CheckTilePermission(args.Player, x, y, true) ||
|
||||
TShock.CheckRangePermission(args.Player, x, y))
|
||||
!args.Player.IsInRange(x, y))
|
||||
{
|
||||
args.Player.SendData(PacketTypes.PaintWall, "", x, y, Main.tile[x, y].wallColor());
|
||||
return true;
|
||||
|
|
@ -3293,7 +3293,7 @@ namespace TShockAPI
|
|||
return true;
|
||||
}
|
||||
|
||||
if (TShock.CheckRangePermission(args.Player, (int)position.X, (int)position.Y))
|
||||
if (!args.Player.IsInRange((int)position.X, (int)position.Y))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -321,6 +321,20 @@ namespace TShockAPI
|
|||
|
||||
public bool SilentJoinInProgress;
|
||||
|
||||
/// <summary>Checks if a player has permission to modify a tile dependent on range checks.</summary>
|
||||
/// <param name="x"> The x coordinate of the tile.</param>
|
||||
/// <param name="y">The y coordinate of the tile.</param>
|
||||
/// <param name="range">The range to check for.</param>
|
||||
/// <returns>True if the player is in range of a tile or if range checks are off. False if not.</returns>
|
||||
public bool IsInRange(int x, int y, int range = 32)
|
||||
{
|
||||
if (TShock.Config.RangeChecks && ((Math.Abs(TileX - x) > range) || (Math.Abs(TileY - y) > range)))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A list of points where ice tiles have been placed.
|
||||
/// </summary>
|
||||
|
|
|
|||
|
|
@ -585,7 +585,7 @@ namespace TShockAPI
|
|||
return;
|
||||
}
|
||||
|
||||
if (CheckRangePermission(tsplr, args.Chest.x, args.Chest.y))
|
||||
if (!tsplr.IsInRange(args.Chest.x, args.Chest.y))
|
||||
{
|
||||
args.Handled = true;
|
||||
return;
|
||||
|
|
@ -1757,24 +1757,6 @@ namespace TShockAPI
|
|||
e.Handled = true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/// <summary>CheckRangePermission - Checks if a player has permission to modify a tile dependent on range checks.</summary>
|
||||
/// <param name="player">player - The TSPlayer object.</param>
|
||||
/// <param name="x">x - The x coordinate of the tile.</param>
|
||||
/// <param name="y">y - The y coordinate of the tile.</param>
|
||||
/// <param name="range">range - The range to check for.</param>
|
||||
/// <returns>bool - True if the player should not be able to place the tile. False if they can, or if range checks are off.</returns>
|
||||
public static bool CheckRangePermission(TSPlayer player, int x, int y, int range = 32)
|
||||
{
|
||||
if (Config.RangeChecks && ((Math.Abs(player.TileX - x) > range) || (Math.Abs(player.TileY - y) > range)))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>CheckTilePermission - Checks to see if a player has permission to modify a tile in general.</summary>
|
||||
/// <param name="player">player - The TSPlayer object.</param>
|
||||
/// <param name="tileX">tileX - The x coordinate of the tile.</param>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue