Skip to content

Commit

Permalink
Merge pull request Pryaxis#1270 from ProfessorXZ/syncextravalue-valid…
Browse files Browse the repository at this point in the history
…ation

SyncExtraValue validation. Fixes Pryaxis#1024
  • Loading branch information
AxisKriel authored Aug 18, 2016
2 parents 599b8ab + 6c0f3ec commit 66f5f9f
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 7 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ This is the rolling changelog for TShock for Terraria. Use past tense when addin
* Players can no longer quick stack items into region protected chests (@ProfessorXZ)
* Rope placement is no longer blocked by range checks (@ProfessorXZ)
* The Drill Containment Unit breaks blocks properly now (@ProfessorXZ)
* Fixed Expert mode coin duplication (@ProfessorXZ)
* Players are no longer able to place liquids using LoadNetModule packet (@ProfessorXZ)

## TShock 4.3.17

Expand Down
36 changes: 34 additions & 2 deletions TShockAPI/GetDataHandlers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ public class TileKillEventArgs : HandledEventArgs
public int TileY { get; set; }
}
/// <summary>
/// TileKill - When a tile is removed fromt he world
/// TileKill - When a tile is removed from the world
/// </summary>
public static HandlerList<TileKillEventArgs> TileKill;

Expand Down Expand Up @@ -1259,6 +1259,8 @@ public static void InitGetDataHandler()
{ PacketTypes.KillPortal, HandleKillPortal },
{ PacketTypes.PlaceTileEntity, HandlePlaceTileEntity },
{ PacketTypes.PlaceItemFrame, HandlePlaceItemFrame },
{ PacketTypes.SyncExtraValue, HandleSyncExtraValue },
{ PacketTypes.LoadNetModule, HandleLoadNetModule },
{ PacketTypes.ToggleParty, HandleToggleParty }
};
}
Expand Down Expand Up @@ -4203,11 +4205,41 @@ private static bool HandlePlaceItemFrame(GetDataHandlerArgs args)
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 HandleLoadNetModule(GetDataHandlerArgs args)
{
// Since this packet is never actually sent to us, every attempt at sending it can be considered as a liquid exploit attempt
return true;
}

private static bool HandleToggleParty(GetDataHandlerArgs args)
{
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;
}

Expand Down
34 changes: 29 additions & 5 deletions TShockAPI/TSPlayer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -198,8 +198,14 @@ public Group Group
/// </summary>
public int LoginAttempts { get; set; }

/// <summary>
/// Unused.
/// </summary>
public Vector2 TeleportCoords = new Vector2(-1, -1);

/// <summary>
/// The player's last known position from PlayerUpdate packet.
/// </summary>
public Vector2 LastNetPosition = Vector2.Zero;

/// <summary>
Expand Down Expand Up @@ -247,6 +253,9 @@ public int UserID
/// </summary>
public bool HasBeenNaggedAboutLoggingIn;

/// <summary>
/// Whether other players can teleport to the player.
/// </summary>
public bool TPAllow = true;

/// <summary>
Expand Down Expand Up @@ -435,7 +444,7 @@ public IEnumerable<Item> Accessories
}

/// <summary>
/// Saves the player's inventory to SSI
/// Saves the player's inventory to SSC
/// </summary>
/// <returns>bool - True/false if it saved successfully</returns>
public bool SaveServerCharacter()
Expand Down Expand Up @@ -534,21 +543,24 @@ public float Y
}

/// <summary>
/// Gets the player's X tile coordinate.
/// Player X coordinate divided by 16. Supposed X world coordinate.
/// </summary>
public int TileX
{
get { return (int) (X/16); }
}

/// <summary>
/// Gets the player's Y tile coordinate.
/// Player Y cooridnate divided by 16. Supposed Y world coordinate.
/// </summary>
public int TileY
{
get { return (int) (Y/16); }
}

/// <summary>
/// Unused.
/// </summary>
public bool TpLock;

/// <summary>
Expand Down Expand Up @@ -630,6 +642,10 @@ public object RemoveData(string key)
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)
{
TilesDestroyed = new Dictionary<Vector2, Tile>();
Expand All @@ -640,6 +656,10 @@ public TSPlayer(int index)
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)
{
TilesDestroyed = new Dictionary<Vector2, Tile>();
Expand Down Expand Up @@ -686,7 +706,7 @@ public void TempGroupTimerElapsed(object sender, ElapsedEventArgs args)
}

/// <summary>
/// Teleports a player to the given coordinates in the world.
/// Teleports the player to the given coordinates in the world.
/// </summary>
/// <param name="x">The X coordinate.</param>
/// <param name="y">The Y coordinate.</param>
Expand Down Expand Up @@ -989,7 +1009,7 @@ public virtual void SendMessage(string msg, byte red, byte green, byte blue)
}

/// <summary>
/// Sends a message to a player with the specified RGB color.
/// Sends a message to the player with the specified RGB color.
/// </summary>
/// <param name="msg">The message.</param>
/// <param name="red">The amount of red color to factor in. Max: 255.</param>
Expand Down Expand Up @@ -1116,6 +1136,10 @@ private void LogStackFrame()
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)
{
var time2 = (int) time;
Expand Down

0 comments on commit 66f5f9f

Please sign in to comment.