SyncExtraValue validation. Fixes #1024

This commit is contained in:
ProfessorXZ 2016-08-10 11:25:03 +02:00
parent 599b8abe2a
commit e0f17b82ef
2 changed files with 55 additions and 6 deletions

View file

@ -1259,6 +1259,7 @@ namespace TShockAPI
{ PacketTypes.KillPortal, HandleKillPortal }, { PacketTypes.KillPortal, HandleKillPortal },
{ PacketTypes.PlaceTileEntity, HandlePlaceTileEntity }, { PacketTypes.PlaceTileEntity, HandlePlaceTileEntity },
{ PacketTypes.PlaceItemFrame, HandlePlaceItemFrame }, { PacketTypes.PlaceItemFrame, HandlePlaceItemFrame },
{ PacketTypes.SyncExtraValue, HandleSyncExtraValue },
{ PacketTypes.ToggleParty, HandleToggleParty } { PacketTypes.ToggleParty, HandleToggleParty }
}; };
} }
@ -4203,11 +4204,35 @@ namespace TShockAPI
return false; return false;
} }
private static bool HandleSyncExtraValue(GetDataHandlerArgs args)
{
var npcIndex = args.Data.ReadInt16();
var extraValue = args.Data.ReadSingle();
var position = new Vector2(args.Data.ReadSingle(), args.Data.ReadSingle());
if (position.X < 0 || position.X >= Main.maxTilesX || position.Y < 0 || position.Y >= Main.maxTilesY)
{
return true;
}
if (!Main.expertMode)
{
return true;
}
if (TShock.CheckRangePermission(args.Player, (int)position.X, (int)position.Y))
{
return true;
}
return false;
}
private static bool HandleToggleParty(GetDataHandlerArgs args) private static bool HandleToggleParty(GetDataHandlerArgs args)
{ {
if (args.Player != null && !args.Player.HasPermission(Permissions.toggleparty)) if (args.Player != null && !args.Player.HasPermission(Permissions.toggleparty))
{ {
args.Player.SendErrorMessage("You do not have permission to start a party"); args.Player.SendErrorMessage("You do not have permission to start a party.");
return true; return true;
} }

View file

@ -198,8 +198,14 @@ namespace TShockAPI
/// </summary> /// </summary>
public int LoginAttempts { get; set; } public int LoginAttempts { get; set; }
/// <summary>
/// Unused.
/// </summary>
public Vector2 TeleportCoords = new Vector2(-1, -1); public Vector2 TeleportCoords = new Vector2(-1, -1);
/// <summary>
/// The player's last known position from PlayerUpdate packet.
/// </summary>
public Vector2 LastNetPosition = Vector2.Zero; public Vector2 LastNetPosition = Vector2.Zero;
/// <summary> /// <summary>
@ -247,6 +253,9 @@ namespace TShockAPI
/// </summary> /// </summary>
public bool HasBeenNaggedAboutLoggingIn; public bool HasBeenNaggedAboutLoggingIn;
/// <summary>
/// Whether other players can teleport to the player.
/// </summary>
public bool TPAllow = true; public bool TPAllow = true;
/// <summary> /// <summary>
@ -435,7 +444,7 @@ namespace TShockAPI
} }
/// <summary> /// <summary>
/// Saves the player's inventory to SSI /// Saves the player's inventory to SSC
/// </summary> /// </summary>
/// <returns>bool - True/false if it saved successfully</returns> /// <returns>bool - True/false if it saved successfully</returns>
public bool SaveServerCharacter() public bool SaveServerCharacter()
@ -534,7 +543,7 @@ namespace TShockAPI
} }
/// <summary> /// <summary>
/// Gets the player's X tile coordinate. /// Player X coordinate divided by 16. Supposed X world coordinate.
/// </summary> /// </summary>
public int TileX public int TileX
{ {
@ -542,13 +551,16 @@ namespace TShockAPI
} }
/// <summary> /// <summary>
/// Gets the player's Y tile coordinate. /// Player Y cooridnate divided by 16. Supposed Y world coordinate.
/// </summary> /// </summary>
public int TileY public int TileY
{ {
get { return (int) (Y/16); } get { return (int) (Y/16); }
} }
/// <summary>
/// Unused.
/// </summary>
public bool TpLock; public bool TpLock;
/// <summary> /// <summary>
@ -630,6 +642,10 @@ namespace TShockAPI
return null; return null;
} }
/// <summary>
/// Initializes a new instance of the <see cref="TSPlayer"/> class.
/// </summary>
/// <param name="index">The player's index in the.</param>
public TSPlayer(int index) public TSPlayer(int index)
{ {
TilesDestroyed = new Dictionary<Vector2, Tile>(); TilesDestroyed = new Dictionary<Vector2, Tile>();
@ -640,6 +656,10 @@ namespace TShockAPI
AwaitingResponse = new Dictionary<string, Action<object>>(); AwaitingResponse = new Dictionary<string, Action<object>>();
} }
/// <summary>
/// Initializes a new instance of the <see cref="TSPlayer"/> class.
/// </summary>
/// <param name="playerName">The player's name.</param>
protected TSPlayer(String playerName) protected TSPlayer(String playerName)
{ {
TilesDestroyed = new Dictionary<Vector2, Tile>(); TilesDestroyed = new Dictionary<Vector2, Tile>();
@ -686,7 +706,7 @@ namespace TShockAPI
} }
/// <summary> /// <summary>
/// Teleports a player to the given coordinates in the world. /// Teleports the player to the given coordinates in the world.
/// </summary> /// </summary>
/// <param name="x">The X coordinate.</param> /// <param name="x">The X coordinate.</param>
/// <param name="y">The Y coordinate.</param> /// <param name="y">The Y coordinate.</param>
@ -989,7 +1009,7 @@ namespace TShockAPI
} }
/// <summary> /// <summary>
/// Sends a message to a player with the specified RGB color. /// Sends a message to the player with the specified RGB color.
/// </summary> /// </summary>
/// <param name="msg">The message.</param> /// <param name="msg">The message.</param>
/// <param name="red">The amount of red color to factor in. Max: 255.</param> /// <param name="red">The amount of red color to factor in. Max: 255.</param>
@ -1116,6 +1136,10 @@ namespace TShockAPI
TShock.Log.Debug(frame.GetMethod().DeclaringType.Name + " called Disable()."); TShock.Log.Debug(frame.GetMethod().DeclaringType.Name + " called Disable().");
} }
/// <summary>
/// Annoys the player for a specified amount of time.
/// </summary>
/// <param name="time">The</param>
public virtual void Whoopie(object time) public virtual void Whoopie(object time)
{ {
var time2 = (int) time; var time2 = (int) time;