Merge branch 'general-devel' into patch-5
This commit is contained in:
commit
61e7d10941
11 changed files with 159 additions and 18 deletions
|
|
@ -67,6 +67,7 @@ namespace TShockAPI
|
|||
GetDataHandlers.MassWireOperation += OnMassWireOperation;
|
||||
GetDataHandlers.PlayerDamage += OnPlayerDamage;
|
||||
GetDataHandlers.KillMe += OnKillMe;
|
||||
GetDataHandlers.FoodPlatterTryPlacing += OnFoodPlatterTryPlacing;
|
||||
}
|
||||
|
||||
internal void OnGetSection(object sender, GetDataHandlers.GetSectionEventArgs args)
|
||||
|
|
@ -557,6 +558,8 @@ namespace TShockAPI
|
|||
return;
|
||||
}
|
||||
|
||||
bool changed = false;
|
||||
bool failed = false;
|
||||
try
|
||||
{
|
||||
var tiles = new NetTile[size, size];
|
||||
|
|
@ -568,7 +571,6 @@ namespace TShockAPI
|
|||
}
|
||||
}
|
||||
|
||||
bool changed = false;
|
||||
for (int x = 0; x < size; x++)
|
||||
{
|
||||
int realx = tileX + x;
|
||||
|
|
@ -708,9 +710,10 @@ namespace TShockAPI
|
|||
catch
|
||||
{
|
||||
args.Player.SendTileSquare(tileX, tileY, size);
|
||||
failed = true;
|
||||
}
|
||||
|
||||
TShock.Log.ConsoleDebug("Bouncer / SendTileSquare reimplemented from spaghetti from {0}", args.Player.Name);
|
||||
TShock.Log.ConsoleDebug("Bouncer / SendTileSquare from {0} {1} {2}", args.Player.Name, changed, failed);
|
||||
args.Handled = true;
|
||||
}
|
||||
|
||||
|
|
@ -2062,6 +2065,54 @@ namespace TShockAPI
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Called when a player is trying to place an item into a food plate.
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="args"></param>
|
||||
internal void OnFoodPlatterTryPlacing(object sender, GetDataHandlers.FoodPlatterTryPlacingEventArgs args)
|
||||
{
|
||||
if (args.Player.ItemInHand.type != args.ItemID)
|
||||
{
|
||||
TShock.Log.ConsoleDebug("Bouncer / OnFoodPlatterTryPlacing rejected item not placed by hand from {0}", args.Player.Name);
|
||||
args.Player.SendTileSquare(args.TileX, args.TileY, 1);
|
||||
args.Handled = true;
|
||||
return;
|
||||
}
|
||||
if (args.Player.IsBeingDisabled())
|
||||
{
|
||||
TShock.Log.ConsoleDebug("Bouncer / OnFoodPlatterTryPlacing rejected disabled from {0}", args.Player.Name);
|
||||
Item item = new Item();
|
||||
item.netDefaults(args.ItemID);
|
||||
args.Player.GiveItemCheck(args.ItemID, item.Name, args.Stack, args.Prefix);
|
||||
args.Player.SendTileSquare(args.TileX, args.TileY, 1);
|
||||
args.Handled = true;
|
||||
return;
|
||||
}
|
||||
|
||||
if (!args.Player.HasBuildPermission(args.TileX, args.TileY))
|
||||
{
|
||||
TShock.Log.ConsoleDebug("Bouncer / OnFoodPlatterTryPlacing rejected permissions from {0}", args.Player.Name);
|
||||
Item item = new Item();
|
||||
item.netDefaults(args.ItemID);
|
||||
args.Player.GiveItemCheck(args.ItemID, item.Name, args.Stack, args.Prefix);
|
||||
args.Player.SendTileSquare(args.TileX, args.TileY, 1);
|
||||
args.Handled = true;
|
||||
return;
|
||||
}
|
||||
|
||||
if (!args.Player.IsInRange(args.TileX, args.TileY))
|
||||
{
|
||||
TShock.Log.ConsoleDebug("Bouncer / OnFoodPlatterTryPlacing rejected range checks from {0}", args.Player.Name);
|
||||
Item item = new Item();
|
||||
item.netDefaults(args.ItemID);
|
||||
args.Player.GiveItemCheck(args.ItemID, item.Name, args.Stack, args.Prefix);
|
||||
args.Player.SendTileSquare(args.TileX, args.TileY, 1);
|
||||
args.Handled = true;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
internal void OnSecondUpdate()
|
||||
{
|
||||
Task.Run(() =>
|
||||
|
|
|
|||
|
|
@ -589,6 +589,10 @@ namespace TShockAPI
|
|||
{
|
||||
HelpText = "Creates a reference tables for Terraria data types and the TShock permission system in the server folder."
|
||||
});
|
||||
add(new Command(Permissions.synclocalarea, SyncLocalArea, "sync")
|
||||
{
|
||||
HelpText = "Sends all tiles from the server to the player to resync the client with the actual world state."
|
||||
});
|
||||
#endregion
|
||||
|
||||
add(new Command(Aliases, "aliases")
|
||||
|
|
@ -5302,6 +5306,13 @@ namespace TShockAPI
|
|||
return;
|
||||
}
|
||||
|
||||
private static void SyncLocalArea(CommandArgs args)
|
||||
{
|
||||
args.Player.SendTileSquare((int) args.Player.TileX, (int) args.Player.TileY, 32);
|
||||
args.Player.SendWarningMessage("Sync'd!");
|
||||
return;
|
||||
}
|
||||
|
||||
#endregion General Commands
|
||||
|
||||
#region Cheat Commands
|
||||
|
|
|
|||
|
|
@ -64,7 +64,8 @@ namespace TShockAPI.DB
|
|||
Permissions.canlogin,
|
||||
Permissions.canpartychat,
|
||||
Permissions.cantalkinthird,
|
||||
Permissions.canchat));
|
||||
Permissions.canchat,
|
||||
Permissions.synclocalarea));
|
||||
|
||||
AddDefaultGroup("default", "guest",
|
||||
string.Join(",",
|
||||
|
|
|
|||
|
|
@ -150,7 +150,8 @@ namespace TShockAPI
|
|||
{ PacketTypes.ToggleParty, HandleToggleParty },
|
||||
{ PacketTypes.CrystalInvasionStart, HandleOldOnesArmy },
|
||||
{ PacketTypes.PlayerHurtV2, HandlePlayerDamageV2 },
|
||||
{ PacketTypes.PlayerDeathV2, HandlePlayerKillMeV2 }
|
||||
{ PacketTypes.PlayerDeathV2, HandlePlayerKillMeV2 },
|
||||
{ PacketTypes.FoodPlatterTryPlacing, HandleFoodPlatterTryPlacing }
|
||||
};
|
||||
}
|
||||
|
||||
|
|
@ -1863,6 +1864,52 @@ namespace TShockAPI
|
|||
return args.Handled;
|
||||
}
|
||||
|
||||
public class FoodPlatterTryPlacingEventArgs : GetDataHandledEventArgs
|
||||
{
|
||||
/// <summary>
|
||||
/// The X tile position of the placement action.
|
||||
/// </summary>
|
||||
public short TileX { get; set; }
|
||||
/// <summary>
|
||||
/// The Y tile position of the placement action.
|
||||
/// </summary>
|
||||
public short TileY { get; set; }
|
||||
/// <summary>
|
||||
/// The Item ID that is being placed in the plate.
|
||||
/// </summary>
|
||||
public short ItemID { get; set; }
|
||||
/// <summary>
|
||||
/// The prefix of the item that is being placed in the plate.
|
||||
/// </summary>
|
||||
public byte Prefix { get; set; }
|
||||
/// <summary>
|
||||
/// The stack of the item that is being placed in the plate.
|
||||
/// </summary>
|
||||
public short Stack { get; set; }
|
||||
}
|
||||
/// <summary>
|
||||
/// Called when a player is placing an item in a food plate.
|
||||
/// </summary>
|
||||
public static HandlerList<FoodPlatterTryPlacingEventArgs> FoodPlatterTryPlacing = new HandlerList<FoodPlatterTryPlacingEventArgs>();
|
||||
private static bool OnFoodPlatterTryPlacing(TSPlayer player, MemoryStream data, short tileX, short tileY, short itemID, byte prefix, short stack)
|
||||
{
|
||||
if (FoodPlatterTryPlacing == null)
|
||||
return false;
|
||||
|
||||
var args = new FoodPlatterTryPlacingEventArgs
|
||||
{
|
||||
Player = player,
|
||||
Data = data,
|
||||
TileX = tileX,
|
||||
TileY = tileY,
|
||||
ItemID = itemID,
|
||||
Prefix = prefix,
|
||||
Stack = stack,
|
||||
};
|
||||
FoodPlatterTryPlacing.Invoke(null, args);
|
||||
return args.Handled;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private static bool HandlePlayerInfo(GetDataHandlerArgs args)
|
||||
|
|
@ -2118,7 +2165,7 @@ namespace TShockAPI
|
|||
TShock.Log.ConsoleDebug("GetDataHandlers / HandleSpawn force teleport 'vanilla spawn' {0}", args.Player.Name);
|
||||
}
|
||||
|
||||
if ((Main.ServerSideCharacter) && (args.Player.sX > 0) && (args.Player.sY > 0) && (args.TPlayer.SpawnX > 0) && ((args.TPlayer.SpawnX != args.Player.sX) && (args.TPlayer.SpawnY != args.Player.sY)))
|
||||
else if ((Main.ServerSideCharacter) && (args.Player.sX > 0) && (args.Player.sY > 0) && (args.TPlayer.SpawnX > 0) && ((args.TPlayer.SpawnX != args.Player.sX) && (args.TPlayer.SpawnY != args.Player.sY)))
|
||||
{
|
||||
|
||||
args.Player.sX = args.TPlayer.SpawnX;
|
||||
|
|
@ -2269,6 +2316,14 @@ namespace TShockAPI
|
|||
{
|
||||
var player = args.Player;
|
||||
var size = args.Data.ReadInt16();
|
||||
|
||||
var changeType = TileChangeType.None;
|
||||
bool hasChangeType = ((size & 0x7FFF) & 0x8000) != 0;
|
||||
if (hasChangeType)
|
||||
{
|
||||
changeType = (TileChangeType)args.Data.ReadInt8();
|
||||
}
|
||||
|
||||
var tileX = args.Data.ReadInt16();
|
||||
var tileY = args.Data.ReadInt16();
|
||||
var data = args.Data;
|
||||
|
|
@ -3524,7 +3579,7 @@ namespace TShockAPI
|
|||
}
|
||||
|
||||
// Handle kicks/bans on mediumcore/hardcore deaths.
|
||||
if (args.TPlayer.difficulty != 0) // Player is not softcore
|
||||
if (args.TPlayer.difficulty == 1 || args.TPlayer.difficulty == 2) // Player is not softcore
|
||||
{
|
||||
bool mediumcore = args.TPlayer.difficulty == 1;
|
||||
bool shouldBan = mediumcore ? TShock.Config.BanOnMediumcoreDeath : TShock.Config.BanOnHardcoreDeath;
|
||||
|
|
@ -3559,7 +3614,19 @@ namespace TShockAPI
|
|||
|
||||
return false;
|
||||
}
|
||||
private static bool HandleFoodPlatterTryPlacing(GetDataHandlerArgs args)
|
||||
{
|
||||
short tileX = args.Data.ReadInt16();
|
||||
short tileY = args.Data.ReadInt16();
|
||||
short itemID = args.Data.ReadInt16();
|
||||
byte prefix = args.Data.ReadInt8();
|
||||
short stack = args.Data.ReadInt16();
|
||||
|
||||
if (OnFoodPlatterTryPlacing(args.Player, args.Data, tileX, tileY, itemID, prefix, stack))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public enum EditAction
|
||||
{
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ namespace TShockAPI.Net
|
|||
public short FrameX { get; set; }
|
||||
public short FrameY { get; set; }
|
||||
public bool Lighted { get; set; }
|
||||
public byte Wall { get; set; }
|
||||
public ushort Wall { get; set; }
|
||||
public byte Liquid { get; set; }
|
||||
public byte LiquidType { get; set; }
|
||||
public bool Wire { get; set; }
|
||||
|
|
@ -175,7 +175,7 @@ namespace TShockAPI.Net
|
|||
}
|
||||
|
||||
if (HasWall)
|
||||
stream.WriteInt8(Wall);
|
||||
stream.WriteInt16((short)Wall);;
|
||||
|
||||
if (HasLiquid)
|
||||
{
|
||||
|
|
@ -218,7 +218,7 @@ namespace TShockAPI.Net
|
|||
|
||||
if (flags[2])
|
||||
{
|
||||
Wall = stream.ReadInt8();
|
||||
Wall = stream.ReadUInt16();
|
||||
}
|
||||
|
||||
if (flags[3])
|
||||
|
|
|
|||
|
|
@ -465,6 +465,9 @@ namespace TShockAPI
|
|||
|
||||
[Description("Player can see advanced information about any user account.")]
|
||||
public static readonly string advaccountinfo = "tshock.accountinfo.details";
|
||||
|
||||
[Description("Player can resync themselves with server state.")]
|
||||
public static readonly string synclocalarea = "tshock.synclocalarea";
|
||||
#endregion
|
||||
/// <summary>
|
||||
/// Lists all commands associated with a given permission
|
||||
|
|
|
|||
|
|
@ -685,7 +685,7 @@ namespace TShockAPI
|
|||
/// <returns>True if they can paint.</returns>
|
||||
public bool HasPaintPermission(int x, int y)
|
||||
{
|
||||
return HasBuildPermission(x, y) || HasPermission(Permissions.canpaint);
|
||||
return HasBuildPermission(x, y) && HasPermission(Permissions.canpaint);
|
||||
}
|
||||
|
||||
/// <summary>Checks if a player can place ice, and if they can, tracks ice placements and removals.</summary>
|
||||
|
|
|
|||
|
|
@ -1493,8 +1493,6 @@ namespace TShockAPI
|
|||
|
||||
PacketTypes type = e.MsgID;
|
||||
|
||||
Log.ConsoleDebug("Recv: {0:X}: {2} ({1:XX})", e.Msg.whoAmI, (byte)type, type);
|
||||
|
||||
var player = Players[e.Msg.whoAmI];
|
||||
if (player == null || !player.ConnectionAlive)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -221,4 +221,4 @@
|
|||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
-->
|
||||
</Project>
|
||||
</Project>
|
||||
Loading…
Add table
Add a link
Reference in a new issue