Consistently use TilePlacementValid and SendTileSquare in Bouncer.
There are 3 different ways Bouncer uses these: - Not checking `TilePlacementValid` at all. - Checking `TilePlacementValid`, rejecting, but then doing a `SendTileSquare` to that player. - Checking `TilePlacementValid`, rejecting. _(this is what we should always be doing)_ Not checking `TilePlacementValid` can allow for placement outside of the world (unknown results), and checking `TilePlacementValid` and sending a `SendTileSquare` on rejection causes the server to try to frame that square. In the case of invalid coordinates (negative), framing takes much longer than expected.
This commit is contained in:
parent
c5421460ae
commit
ef603f61a8
2 changed files with 36 additions and 16 deletions
|
|
@ -260,6 +260,13 @@ namespace TShockAPI
|
|||
|
||||
try
|
||||
{
|
||||
if (!TShock.Utils.TilePlacementValid(tileX, tileY))
|
||||
{
|
||||
TShock.Log.ConsoleDebug("Bouncer / OnTileEdit rejected from (tile placement valid) {0} {1} {2}", args.Player.Name, action, editData);
|
||||
args.Handled = true;
|
||||
return;
|
||||
}
|
||||
|
||||
if (editData < 0 ||
|
||||
((action == EditAction.PlaceTile || action == EditAction.ReplaceTile) && editData >= Main.maxTileSets) ||
|
||||
((action == EditAction.PlaceWall || action == EditAction.ReplaceWall) && editData >= Main.maxWallTypes))
|
||||
|
|
@ -270,14 +277,6 @@ namespace TShockAPI
|
|||
return;
|
||||
}
|
||||
|
||||
if (!TShock.Utils.TilePlacementValid(tileX, tileY))
|
||||
{
|
||||
TShock.Log.ConsoleDebug("Bouncer / OnTileEdit rejected from (tile placement valid) {0} {1} {2}", args.Player.Name, action, editData);
|
||||
args.Player.SendTileSquare(tileX, tileY, 1);
|
||||
args.Handled = true;
|
||||
return;
|
||||
}
|
||||
|
||||
if (action == EditAction.KillTile && Main.tile[tileX, tileY].type == TileID.MagicalIceBlock)
|
||||
{
|
||||
TShock.Log.ConsoleDebug("Bouncer / OnTileEdit super accepted from (ice block) {0} {1} {2}", args.Player.Name, action, editData);
|
||||
|
|
@ -1654,6 +1653,13 @@ namespace TShockAPI
|
|||
short type = args.Type;
|
||||
short style = args.Style;
|
||||
|
||||
if (!TShock.Utils.TilePlacementValid(x, y))
|
||||
{
|
||||
TShock.Log.ConsoleDebug("Bouncer / OnPlaceObject rejected valid placements from {0}", args.Player.Name);
|
||||
args.Handled = true;
|
||||
return;
|
||||
}
|
||||
|
||||
if (type < 0 || type >= Main.maxTileSets)
|
||||
{
|
||||
TShock.Log.ConsoleDebug("Bouncer / OnPlaceObject rejected out of bounds tile from {0}", args.Player.Name);
|
||||
|
|
@ -1702,14 +1708,6 @@ namespace TShockAPI
|
|||
return;
|
||||
}
|
||||
|
||||
if (!TShock.Utils.TilePlacementValid(x, y))
|
||||
{
|
||||
TShock.Log.ConsoleDebug("Bouncer / OnPlaceObject rejected valid placements from {0}", args.Player.Name);
|
||||
args.Player.SendTileSquare(x, y, 1);
|
||||
args.Handled = true;
|
||||
return;
|
||||
}
|
||||
|
||||
if (args.Player.Dead && TShock.Config.Settings.PreventDeadModification)
|
||||
{
|
||||
TShock.Log.ConsoleDebug("Bouncer / OnPlaceObject rejected dead people don't do things from {0}", args.Player.Name);
|
||||
|
|
@ -1801,6 +1799,13 @@ namespace TShockAPI
|
|||
/// <param name="args">The packet arguments that the event has.</param>
|
||||
internal void OnPlaceTileEntity(object sender, GetDataHandlers.PlaceTileEntityEventArgs args)
|
||||
{
|
||||
if (!TShock.Utils.TilePlacementValid(args.X, args.Y))
|
||||
{
|
||||
TShock.Log.ConsoleDebug("Bouncer / OnPlaceTileEntity rejected tile placement valid from {0}", args.Player.Name);
|
||||
args.Handled = true;
|
||||
return;
|
||||
}
|
||||
|
||||
if (args.Player.IsBeingDisabled())
|
||||
{
|
||||
TShock.Log.ConsoleDebug("Bouncer / OnPlaceTileEntity rejected disabled from {0}", args.Player.Name);
|
||||
|
|
@ -1828,6 +1833,13 @@ namespace TShockAPI
|
|||
/// <param name="args">The packet arguments that the event has.</param>
|
||||
internal void OnPlaceItemFrame(object sender, GetDataHandlers.PlaceItemFrameEventArgs args)
|
||||
{
|
||||
if (!TShock.Utils.TilePlacementValid(args.X, args.Y))
|
||||
{
|
||||
TShock.Log.ConsoleDebug("Bouncer / OnPlaceItemFrame rejected tile placement valid from {0}", args.Player.Name);
|
||||
args.Handled = true;
|
||||
return;
|
||||
}
|
||||
|
||||
if (args.Player.IsBeingDisabled())
|
||||
{
|
||||
TShock.Log.ConsoleDebug("Bouncer / OnPlaceItemFrame rejected disabled from {0}", args.Player.Name);
|
||||
|
|
@ -2129,6 +2141,13 @@ namespace TShockAPI
|
|||
/// <param name="args"></param>
|
||||
internal void OnFoodPlatterTryPlacing(object sender, GetDataHandlers.FoodPlatterTryPlacingEventArgs args)
|
||||
{
|
||||
if (!TShock.Utils.TilePlacementValid(args.TileX, args.TileY))
|
||||
{
|
||||
TShock.Log.ConsoleDebug("Bouncer / OnFoodPlatterTryPlacing rejected tile placement valid from {0}", args.Player.Name);
|
||||
args.Handled = true;
|
||||
return;
|
||||
}
|
||||
|
||||
if ((args.Player.SelectedItem.type != args.ItemID && args.Player.ItemInHand.type != args.ItemID))
|
||||
{
|
||||
TShock.Log.ConsoleDebug("Bouncer / OnFoodPlatterTryPlacing rejected item not placed by hand from {0}", args.Player.Name);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue