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
|
|
@ -40,6 +40,7 @@ namespace TShockAPI
|
|||
internal Handlers.NetModules.NetModulePacketHandler NetModuleHandler { get; set; }
|
||||
internal Handlers.EmojiHandler EmojiHandler { get; set; }
|
||||
internal Handlers.LandGolfBallInCupHandler LandGolfBallInCupHandler { get; set; }
|
||||
internal Handlers.SyncTilePickingHandler SyncTilePickingHandler { get; set; }
|
||||
|
||||
/// <summary>Constructor call initializes Bouncer and related functionality.</summary>
|
||||
/// <returns>A new Bouncer.</returns>
|
||||
|
|
@ -57,6 +58,9 @@ namespace TShockAPI
|
|||
LandGolfBallInCupHandler = new Handlers.LandGolfBallInCupHandler();
|
||||
GetDataHandlers.LandGolfBallInCup += LandGolfBallInCupHandler.OnReceive;
|
||||
|
||||
SyncTilePickingHandler = new Handlers.SyncTilePickingHandler();
|
||||
GetDataHandlers.SyncTilePicking += SyncTilePickingHandler.OnReceive;
|
||||
|
||||
// Setup hooks
|
||||
GetDataHandlers.GetSection += OnGetSection;
|
||||
GetDataHandlers.PlayerUpdate += OnPlayerUpdate;
|
||||
|
|
|
|||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -100,6 +100,7 @@
|
|||
<Compile Include="Handlers\EmojiHandler.cs" />
|
||||
<Compile Include="Handlers\LandGolfBallInCupHandler.cs" />
|
||||
<Compile Include="Handlers\SendTileSquareHandler.cs" />
|
||||
<Compile Include="Handlers\SyncTilePickingHandler.cs" />
|
||||
<Compile Include="Hooks\AccountHooks.cs" />
|
||||
<Compile Include="Hooks\GeneralHooks.cs" />
|
||||
<Compile Include="Hooks\PlayerHooks.cs" />
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue