Update packet logic up to 17 (not including 17 ->tile edit...something needs to be done with the last two bytes)

This commit is contained in:
Zack Piispanen 2013-09-29 05:29:18 -04:00
parent c80ebbc116
commit 40ba6c56d3

View file

@ -443,13 +443,15 @@ namespace TShockAPI
/// Velocity of the player /// Velocity of the player
/// </summary> /// </summary>
public Vector2 Velocity { get; set; } public Vector2 Velocity { get; set; }
public byte Pulley { get; set; }
} }
/// <summary> /// <summary>
/// PlayerUpdate - When the player sends it's updated information to the server /// PlayerUpdate - When the player sends it's updated information to the server
/// </summary> /// </summary>
public static HandlerList<PlayerUpdateEventArgs> PlayerUpdate; public static HandlerList<PlayerUpdateEventArgs> PlayerUpdate;
private static bool OnPlayerUpdate(byte player, byte control, byte item, Vector2 position, Vector2 velocity) private static bool OnPlayerUpdate(byte player, byte control, byte item, Vector2 position, Vector2 velocity, byte pulley)
{ {
if (PlayerUpdate == null) if (PlayerUpdate == null)
return false; return false;
@ -461,6 +463,7 @@ namespace TShockAPI
Item = item, Item = item,
Position = position, Position = position,
Velocity = velocity, Velocity = velocity,
Pulley = pulley
}; };
PlayerUpdate.Invoke(null, args); PlayerUpdate.Invoke(null, args);
return args.Handled; return args.Handled;
@ -1251,7 +1254,7 @@ namespace TShockAPI
if (args.Player.FirstMaxHP == 0) if (args.Player.FirstMaxHP == 0)
args.Player.FirstMaxHP = max; args.Player.FirstMaxHP = max;
if (max > TShock.Config.MaxHealth && max > args.Player.FirstMaxHP) if ((max > TShock.Config.MaxHealth && max > args.Player.FirstMaxHP) && !args.Player.Group.HasPermission(Permissions.ignorestathackdetection))
{ {
TShock.Utils.ForceKick(args.Player, "Hacked Client Detected.", true); TShock.Utils.ForceKick(args.Player, "Hacked Client Detected.", true);
return false; return false;
@ -1988,13 +1991,19 @@ namespace TShockAPI
var item = args.Data.ReadInt8(); var item = args.Data.ReadInt8();
var pos = new Vector2(args.Data.ReadSingle(), args.Data.ReadSingle()); var pos = new Vector2(args.Data.ReadSingle(), args.Data.ReadSingle());
var vel = new Vector2(args.Data.ReadSingle(), args.Data.ReadSingle()); var vel = new Vector2(args.Data.ReadSingle(), args.Data.ReadSingle());
if (OnPlayerUpdate(plr, control, item, pos, vel)) byte pulley = args.Data.ReadInt8();
if (OnPlayerUpdate(plr, control, item, pos, vel, pulley))
return true; return true;
if (item < 0 || item >= args.TPlayer.inventory.Length) if (item < 0 || item >= args.TPlayer.inventory.Length)
{ {
return true; return true;
} }
if (pulley > 2)
{
return true;
}
if (args.Player.LastNetPosition == Vector2.Zero) if (args.Player.LastNetPosition == Vector2.Zero)
{ {
return true; return true;
@ -2093,6 +2102,8 @@ namespace TShockAPI
args.TPlayer.controlRight = false; args.TPlayer.controlRight = false;
args.TPlayer.controlJump = false; args.TPlayer.controlJump = false;
args.TPlayer.controlUseItem = false; args.TPlayer.controlUseItem = false;
args.TPlayer.pulley = pulley != 0;
args.TPlayer.pulleyDir = pulley;
args.TPlayer.direction = -1; args.TPlayer.direction = -1;
if ((control & 1) == 1) if ((control & 1) == 1)
{ {