Merge branch 'h/door' into general-devel
This commit is contained in:
commit
39e7de1d7c
2 changed files with 65 additions and 4 deletions
|
|
@ -23,6 +23,7 @@ This is the rolling changelog for TShock for Terraria. Use past tense when addin
|
|||
* Added warnings for conditions where a password is set at runtime but can be bypassed. The thinking is that if a user sets a password when they're booting the server, that's what they expect to be the password. The only thing is that sometimes, other config options can basically defeat this as a security feature. The goal is just to communicate more and make things clearer. The server also warns users when UUID login is enabled, because it can be confusing and insecure. (@hakusaro, @Onusai)
|
||||
* Fixed Torch God's Favor biome torch placement being rejected by the server. (@moisterrific)
|
||||
* Backups created by the backup manager now use ISO8601-style timestamps. I say "style" because it's impossible to implement ISO8601 or RFC3389 dates in a filename on most modern filesystems. So instead of the proper ISO separators, we've got dashes and dots. (@hakusaro, change sponsored by @drunderscore)
|
||||
* Added hook for `OnDoorUse` (`DoorUse`) and associated `DoorUseEventArgs` fired when a door is used. Also added `GetDataHandlers.DoorAction` enum for determining the action of a door. (@hakusaro)
|
||||
|
||||
## TShock 4.5.3
|
||||
* Added permissions for using Teleportation Potions, Magic Conch, and Demon Conch. (@drunderscore)
|
||||
|
|
|
|||
|
|
@ -493,6 +493,50 @@ namespace TShockAPI
|
|||
return args.Handled;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// DoorUseEventArgs - the arguments for a DoorUse event
|
||||
/// </summary>
|
||||
public class DoorUseEventArgs : GetDataHandledEventArgs
|
||||
{
|
||||
/// <summary>
|
||||
/// X - The x position of the door being used
|
||||
/// </summary>
|
||||
public short X { get; set; }
|
||||
/// <summary>
|
||||
/// Y - The y position of the door being used
|
||||
/// </summary>
|
||||
public short Y { get; set; }
|
||||
/// <summary>
|
||||
/// Direction - Information about which way the door opens or where the player is relative to the door
|
||||
/// </summary>
|
||||
public byte Direction { get; set; }
|
||||
/// <summary>
|
||||
/// Action - The type of thing happening to the door
|
||||
/// </summary>
|
||||
public DoorAction Action { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// DoorUse - called when a door is opened or closed (normal or trap)
|
||||
/// </summary>
|
||||
public static HandlerList<DoorUseEventArgs> DoorUse = new HandlerList<DoorUseEventArgs>();
|
||||
private static bool OnDoorUse(TSPlayer ply, MemoryStream data, short x, short y, byte direction, DoorAction action)
|
||||
{
|
||||
if (DoorUse == null)
|
||||
return false;
|
||||
|
||||
var args = new DoorUseEventArgs
|
||||
{
|
||||
Player = ply,
|
||||
X = x,
|
||||
Y = y,
|
||||
Direction = direction,
|
||||
Action = action
|
||||
};
|
||||
DoorUse.Invoke(null, args);
|
||||
return args.Handled;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// For use in a SendTileRect event
|
||||
/// </summary>
|
||||
|
|
@ -2618,10 +2662,17 @@ namespace TShockAPI
|
|||
|
||||
private static bool HandleDoorUse(GetDataHandlerArgs args)
|
||||
{
|
||||
byte type = (byte)args.Data.ReadByte();
|
||||
byte action = (byte)args.Data.ReadByte();
|
||||
short x = args.Data.ReadInt16();
|
||||
short y = args.Data.ReadInt16();
|
||||
args.Data.ReadByte(); //Ignore direction
|
||||
byte direction = (byte)args.Data.ReadByte();
|
||||
|
||||
DoorAction doorAction = (DoorAction)action;
|
||||
|
||||
if (OnDoorUse(args.Player, args.Data, x, y, direction, doorAction))
|
||||
return true;
|
||||
|
||||
ushort tileType = Main.tile[x, y].type;
|
||||
|
||||
if (x >= Main.maxTilesX || y >= Main.maxTilesY || x < 0 || y < 0) // Check for out of range
|
||||
{
|
||||
|
|
@ -2629,13 +2680,12 @@ namespace TShockAPI
|
|||
return true;
|
||||
}
|
||||
|
||||
if (type < 0 || type > 5)
|
||||
if (action < 0 || action > 5)
|
||||
{
|
||||
TShock.Log.ConsoleDebug("GetDataHandlers / HandleDoorUse rejected type 0 5 check {0}", args.Player.Name);
|
||||
return true;
|
||||
}
|
||||
|
||||
ushort tileType = Main.tile[x, y].type;
|
||||
|
||||
if (tileType != TileID.ClosedDoor && tileType != TileID.OpenDoor
|
||||
&& tileType != TileID.TallGateClosed && tileType != TileID.TallGateOpen
|
||||
|
|
@ -3995,6 +4045,16 @@ namespace TShockAPI
|
|||
return true;
|
||||
}
|
||||
|
||||
public enum DoorAction
|
||||
{
|
||||
OpenDoor = 0,
|
||||
CloseDoor,
|
||||
OpenTrapdoor,
|
||||
CloseTrapdoor,
|
||||
OpenTallGate,
|
||||
CloseTallGate
|
||||
}
|
||||
|
||||
public enum EditAction
|
||||
{
|
||||
KillTile = 0,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue