Implementing SyncTilePickingHandler. Patching tile damage related exploits.
With this packet, players could kick all players by sending invalid world position data.
This commit is contained in:
parent
cffdadbc80
commit
e738d8e794
4 changed files with 42 additions and 1 deletions
36
TShockAPI/Handlers/SyncTilePickingHandler.cs
Normal file
36
TShockAPI/Handlers/SyncTilePickingHandler.cs
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Terraria;
|
||||
using static TShockAPI.GetDataHandlers;
|
||||
|
||||
namespace TShockAPI.Handlers
|
||||
{
|
||||
class SyncTilePickingHandler : IPacketHandler<SyncTilePickingEventArgs>
|
||||
{
|
||||
/// <summary>
|
||||
/// Invoked when player damages a tile.
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="args"></param>
|
||||
public void OnReceive(object sender, SyncTilePickingEventArgs args)
|
||||
{
|
||||
if (args.PlayerIndex != args.Player.Index)
|
||||
{
|
||||
TShock.Log.ConsoleDebug($"SyncTilePickingHandler: SyncTilePicking packet rejected for ID spoofing. Expected {args.Player.Index}, received {args.PlayerIndex} from {args.Player.Name}.");
|
||||
args.Handled = true;
|
||||
return;
|
||||
}
|
||||
|
||||
if (args.TileX > Main.maxTilesX || args.TileX < 0
|
||||
|| args.TileY > Main.maxTilesY || args.TileY < 0)
|
||||
{
|
||||
TShock.Log.ConsoleDebug($"SyncTilePickingHandler: X and Y position is out of world bounds! - From {args.Player.Name}");
|
||||
args.Handled = true;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue