Merge remote-tracking branch 'tru321/general-devel' into general-devel
This commit is contained in:
commit
e42da74f85
3 changed files with 122 additions and 0 deletions
|
|
@ -11,6 +11,9 @@ This is the rolling changelog for TShock for Terraria. Use past tense when addin
|
||||||
* Do not insert tabs into this file, under any circumstances, ever.
|
* Do not insert tabs into this file, under any circumstances, ever.
|
||||||
* Do not forget to sign every line you change with your name. (@hakusaro)
|
* Do not forget to sign every line you change with your name. (@hakusaro)
|
||||||
* If there is no section called "Upcoming changes" below this line, please add one with `## Upcoming changes` as the first line, and then a bulleted item directly after with the first change.
|
* If there is no section called "Upcoming changes" below this line, please add one with `## Upcoming changes` as the first line, and then a bulleted item directly after with the first change.
|
||||||
|
## Upcoming changes
|
||||||
|
* Added hook `GetDataHandlers.OnReleaseNpc` to handling ReleaseNPC packet and a bouncer to stops unregistered and logged out players on SSC servers from releasing critters NPC. The bouncer has additional filter to stops players who tried to release different critter using crafted packet, e.g. using bunny item to release golden bunny. (@tru321)
|
||||||
|
* Added filter in `GetDataHandlers.HandleCatchNpc` that stops unregistered and logged out players on SSC servers to catch critters. (@tru321)
|
||||||
|
|
||||||
## Upcoming changes
|
## Upcoming changes
|
||||||
* Fixed rejection check inside of `HandlePaintTile` to account for the Paint Sprayer (or Architect Gizmo Pack) being inside your inventory, rather than on an accessory slot. (@drunderscore)
|
* Fixed rejection check inside of `HandlePaintTile` to account for the Paint Sprayer (or Architect Gizmo Pack) being inside your inventory, rather than on an accessory slot. (@drunderscore)
|
||||||
|
|
|
||||||
|
|
@ -105,6 +105,7 @@ namespace TShockAPI
|
||||||
GetDataHandlers.NPCAddBuff += OnNPCAddBuff;
|
GetDataHandlers.NPCAddBuff += OnNPCAddBuff;
|
||||||
GetDataHandlers.NPCHome += OnUpdateNPCHome;
|
GetDataHandlers.NPCHome += OnUpdateNPCHome;
|
||||||
GetDataHandlers.HealOtherPlayer += OnHealOtherPlayer;
|
GetDataHandlers.HealOtherPlayer += OnHealOtherPlayer;
|
||||||
|
GetDataHandlers.ReleaseNPC += OnReleaseNPC;
|
||||||
GetDataHandlers.PlaceObject += OnPlaceObject;
|
GetDataHandlers.PlaceObject += OnPlaceObject;
|
||||||
GetDataHandlers.PlaceTileEntity += OnPlaceTileEntity;
|
GetDataHandlers.PlaceTileEntity += OnPlaceTileEntity;
|
||||||
GetDataHandlers.PlaceItemFrame += OnPlaceItemFrame;
|
GetDataHandlers.PlaceItemFrame += OnPlaceItemFrame;
|
||||||
|
|
@ -1829,6 +1830,52 @@ namespace TShockAPI
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// A bouncer for checking NPC released by player
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="sender">The object that triggered the event.</param>
|
||||||
|
/// <param name="args">The packet arguments that the event has.</param>
|
||||||
|
internal void OnReleaseNPC(object sender, GetDataHandlers.ReleaseNpcEventArgs args)
|
||||||
|
{
|
||||||
|
int x = args.X;
|
||||||
|
int y = args.Y;
|
||||||
|
short type = args.Type;
|
||||||
|
byte style = args.Style;
|
||||||
|
|
||||||
|
// if npc released outside allowed tile
|
||||||
|
if (x >= Main.maxTilesX * 16 - 16 || x < 0 || y >= Main.maxTilesY * 16 - 16 || y < 0)
|
||||||
|
{
|
||||||
|
TShock.Log.ConsoleDebug("Bouncer / OnReleaseNPC rejected out of bounds from {0}", args.Player.Name);
|
||||||
|
args.Handled = true;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// if player disabled
|
||||||
|
if (args.Player.IsBeingDisabled())
|
||||||
|
{
|
||||||
|
TShock.Log.ConsoleDebug("Bouncer / OnReleaseNPC rejected npc release from {0}", args.Player.Name);
|
||||||
|
args.Handled = true;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// if released npc not from its item (from crafted packet)
|
||||||
|
// e.g. using bunny item to release golden bunny
|
||||||
|
if (args.Player.TPlayer.lastVisualizedSelectedItem.makeNPC != type && args.Player.TPlayer.lastVisualizedSelectedItem.placeStyle != style)
|
||||||
|
{
|
||||||
|
TShock.Log.ConsoleDebug("Bouncer / OnReleaseNPC released different critter from {0}", args.Player.Name);
|
||||||
|
args.Player.Kick("Released critter was not from its item.", true);
|
||||||
|
args.Handled = true;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (args.Player.IsBouncerThrottled())
|
||||||
|
{
|
||||||
|
TShock.Log.ConsoleDebug("Bouncer / OnReleaseNPC rejected throttle from {0}", args.Player.Name);
|
||||||
|
args.Handled = true;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>Bouncer's PlaceObject hook reverts malicious tile placement.</summary>
|
/// <summary>Bouncer's PlaceObject hook reverts malicious tile placement.</summary>
|
||||||
/// <param name="sender">The object that triggered the event.</param>
|
/// <param name="sender">The object that triggered the event.</param>
|
||||||
/// <param name="args">The packet arguments that the event has.</param>
|
/// <param name="args">The packet arguments that the event has.</param>
|
||||||
|
|
|
||||||
|
|
@ -136,6 +136,7 @@ namespace TShockAPI
|
||||||
{ PacketTypes.Teleport, HandleTeleport },
|
{ PacketTypes.Teleport, HandleTeleport },
|
||||||
{ PacketTypes.PlayerHealOther, HandleHealOther },
|
{ PacketTypes.PlayerHealOther, HandleHealOther },
|
||||||
{ PacketTypes.CatchNPC, HandleCatchNpc },
|
{ PacketTypes.CatchNPC, HandleCatchNpc },
|
||||||
|
{ PacketTypes.ReleaseNPC, HandleReleaseNpc },
|
||||||
{ PacketTypes.TeleportationPotion, HandleTeleportationPotion },
|
{ PacketTypes.TeleportationPotion, HandleTeleportationPotion },
|
||||||
{ PacketTypes.CompleteAnglerQuest, HandleCompleteAnglerQuest },
|
{ PacketTypes.CompleteAnglerQuest, HandleCompleteAnglerQuest },
|
||||||
{ PacketTypes.NumberOfAnglerQuestsCompleted, HandleNumberOfAnglerQuestsCompleted },
|
{ PacketTypes.NumberOfAnglerQuestsCompleted, HandleNumberOfAnglerQuestsCompleted },
|
||||||
|
|
@ -1676,6 +1677,56 @@ namespace TShockAPI
|
||||||
return args.Handled;
|
return args.Handled;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The ReleaseNPC event arguments
|
||||||
|
/// </summary>
|
||||||
|
public class ReleaseNpcEventArgs : GetDataHandledEventArgs
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// The X value of where NPC released
|
||||||
|
/// </summary>
|
||||||
|
public int X { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The Y value of where NPC released
|
||||||
|
/// </summary>
|
||||||
|
public int Y { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The NPC Type that player release
|
||||||
|
/// </summary>
|
||||||
|
public short Type { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The NPC release style
|
||||||
|
/// </summary>
|
||||||
|
public byte Style { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Called when player release a NPC, for checking critter released from item.
|
||||||
|
/// </summary>
|
||||||
|
public static HandlerList<ReleaseNpcEventArgs> ReleaseNPC = new HandlerList<ReleaseNpcEventArgs>();
|
||||||
|
private static bool OnReleaseNpc(TSPlayer player, MemoryStream data, int _x, int _y, short _type, byte _style)
|
||||||
|
{
|
||||||
|
if (ReleaseNPC == null)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
var args = new ReleaseNpcEventArgs
|
||||||
|
{
|
||||||
|
Player = player,
|
||||||
|
Data = data,
|
||||||
|
X = _x,
|
||||||
|
Y = _y,
|
||||||
|
Type = _type,
|
||||||
|
Style = _style
|
||||||
|
};
|
||||||
|
ReleaseNPC.Invoke(null, args);
|
||||||
|
return args.Handled;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>The arguments to the PlaceObject hook.</summary>
|
/// <summary>The arguments to the PlaceObject hook.</summary>
|
||||||
public class PlaceObjectEventArgs : GetDataHandledEventArgs
|
public class PlaceObjectEventArgs : GetDataHandledEventArgs
|
||||||
{
|
{
|
||||||
|
|
@ -3725,10 +3776,31 @@ namespace TShockAPI
|
||||||
NetMessage.SendData((int)PacketTypes.NpcUpdate, -1, -1, NetworkText.Empty, npcID);
|
NetMessage.SendData((int)PacketTypes.NpcUpdate, -1, -1, NetworkText.Empty, npcID);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(args.Player.IsBeingDisabled())
|
||||||
|
{
|
||||||
|
TShock.Log.ConsoleDebug("GetDataHandlers / HandleCatchNpc rejected catch npc {0}", args.Player.Name);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static bool HandleReleaseNpc(GetDataHandlerArgs args)
|
||||||
|
{
|
||||||
|
var x = args.Data.ReadInt32();
|
||||||
|
var y = args.Data.ReadInt32();
|
||||||
|
var type = args.Data.ReadInt16();
|
||||||
|
var style = args.Data.ReadInt8();
|
||||||
|
|
||||||
|
if (OnReleaseNpc(args.Player, args.Data, x, y, type, style))
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
private static bool HandleTeleportationPotion(GetDataHandlerArgs args)
|
private static bool HandleTeleportationPotion(GetDataHandlerArgs args)
|
||||||
{
|
{
|
||||||
var type = args.Data.ReadByte();
|
var type = args.Data.ReadByte();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue