Merge branch 'general-devel' into sqliteconf

This commit is contained in:
Axeel 2020-05-20 22:46:15 +08:00 committed by GitHub
commit 773092b7bf
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 54 additions and 40 deletions

View file

@ -3,6 +3,7 @@
This is the rolling changelog for TShock for Terraria. Use past tense when adding new entries; sign your name off when you add or change something. This should primarily be things like user changes, not necessarily codebase changes unless it's really relevant or large. This is the rolling changelog for TShock for Terraria. Use past tense when adding new entries; sign your name off when you add or change something. This should primarily be things like user changes, not necessarily codebase changes unless it's really relevant or large.
## Upcoming changes ## Upcoming changes
* Update player spawn related things to 1.4. `Terraria.Player.Spawn` method now has a required argument, `PlayerSpawnContext context`. (@AxeelAnder)
* Make sqlite db path configurable. (@AxeelAnder) * Make sqlite db path configurable. (@AxeelAnder)
## TShock 4.4.0 (Pre-release 4) ## TShock 4.4.0 (Pre-release 4)

View file

@ -164,7 +164,7 @@ namespace TShockAPI
var lastTileY = args.Player.LastNetPosition.Y - 48; var lastTileY = args.Player.LastNetPosition.Y - 48;
if (!args.Player.Teleport(lastTileX, lastTileY)) if (!args.Player.Teleport(lastTileX, lastTileY))
{ {
args.Player.Spawn(); args.Player.Spawn(PlayerSpawnContext.RecallFromItem);
} }
TShock.Log.ConsoleDebug("Bouncer / OnPlayerUpdate rejected from (??) {0}", args.Player.Name); TShock.Log.ConsoleDebug("Bouncer / OnPlayerUpdate rejected from (??) {0}", args.Player.Name);
args.Handled = true; args.Handled = true;
@ -491,7 +491,7 @@ namespace TShockAPI
return; return;
} }
} }
/// <summary>Bouncer's SendTileSquare hook halts large scope world destruction.</summary> /// <summary>Bouncer's SendTileSquare hook halts large scope world destruction.</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>
@ -684,7 +684,7 @@ namespace TShockAPI
args.Handled = true; args.Handled = true;
} }
/// <summary>Registered when items fall to the ground to prevent cheating.</summary> /// <summary>Registered when items fall to the ground to prevent cheating.</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>
@ -969,7 +969,7 @@ namespace TShockAPI
return; return;
} }
} }
/// <summary>Handles ProjectileKill events for throttling and out of bounds projectiles.</summary> /// <summary>Handles ProjectileKill events for throttling and out of bounds projectiles.</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>
@ -995,7 +995,7 @@ namespace TShockAPI
return; return;
} }
} }
/// <summary>Handles when a chest item is changed.</summary> /// <summary>Handles when a chest item is changed.</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>
@ -1032,7 +1032,7 @@ namespace TShockAPI
return; return;
} }
} }
/// <summary>The Bouncer handler for when chests are opened.</summary> /// <summary>The Bouncer handler for when chests are opened.</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>
@ -1059,7 +1059,7 @@ namespace TShockAPI
int id = Chest.FindChest(args.X, args.Y); int id = Chest.FindChest(args.X, args.Y);
args.Player.ActiveChest = id; args.Player.ActiveChest = id;
} }
/// <summary>The place chest event that Bouncer hooks to prevent accidental damage.</summary> /// <summary>The place chest event that Bouncer hooks to prevent accidental damage.</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>
@ -1119,7 +1119,7 @@ namespace TShockAPI
return; return;
} }
} }
/// <summary>Handles PlayerZone events for preventing spawning NPC maliciously.</summary> /// <summary>Handles PlayerZone events for preventing spawning NPC maliciously.</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>
@ -1155,7 +1155,7 @@ namespace TShockAPI
} }
} }
} }
/// <summary>Handles basic animation throttling for disabled players.</summary> /// <summary>Handles basic animation throttling for disabled players.</summary>
/// <param name="sender">sender</param> /// <param name="sender">sender</param>
/// <param name="args">args</param> /// <param name="args">args</param>
@ -1175,7 +1175,7 @@ namespace TShockAPI
return; return;
} }
} }
/// <summary>Handles Bouncer's liquid set anti-cheat.</summary> /// <summary>Handles Bouncer's liquid set anti-cheat.</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>
@ -1315,7 +1315,7 @@ namespace TShockAPI
return; return;
} }
} }
/// <summary>Handles Buff events.</summary> /// <summary>Handles Buff events.</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>
@ -1372,7 +1372,7 @@ namespace TShockAPI
return; return;
} }
} }
/// <summary>Handles NPCAddBuff events.</summary> /// <summary>Handles NPCAddBuff events.</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>
@ -1432,7 +1432,7 @@ namespace TShockAPI
args.Handled = true; args.Handled = true;
} }
} }
/// <summary>The Bouncer handler for when an NPC is rehomed.</summary> /// <summary>The Bouncer handler for when an NPC is rehomed.</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>
@ -1459,7 +1459,7 @@ namespace TShockAPI
return; return;
} }
} }
/// <summary>Bouncer's HealOther handler prevents gross misuse of HealOther packets by hackers.</summary> /// <summary>Bouncer's HealOther handler prevents gross misuse of HealOther packets by hackers.</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>
@ -1501,7 +1501,7 @@ namespace TShockAPI
args.Handled = false; args.Handled = false;
return; 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>
@ -1571,8 +1571,8 @@ namespace TShockAPI
return; return;
} }
// This is neccessary to check in order to prevent special tiles such as // This is neccessary to check in order to prevent special tiles such as
// queen bee larva, paintings etc that use this packet from being placed // queen bee larva, paintings etc that use this packet from being placed
// without selecting the right item. // without selecting the right item.
if (type != args.Player.TPlayer.inventory[args.Player.TPlayer.selectedItem].createTile) if (type != args.Player.TPlayer.inventory[args.Player.TPlayer.selectedItem].createTile)
{ {
@ -1634,7 +1634,7 @@ namespace TShockAPI
args.Player.TilesCreated.Add(coords, Main.tile[x, y]); args.Player.TilesCreated.Add(coords, Main.tile[x, y]);
} }
} }
/// <summary>Fired when a PlaceTileEntity occurs for basic anti-cheat on perms and range.</summary> /// <summary>Fired when a PlaceTileEntity occurs for basic anti-cheat on perms and range.</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>
@ -1658,7 +1658,7 @@ namespace TShockAPI
return; return;
} }
} }
/// <summary>Fired when an item frame is placed for anti-cheat detection.</summary> /// <summary>Fired when an item frame is placed for anti-cheat detection.</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>
@ -1685,7 +1685,7 @@ namespace TShockAPI
return; return;
} }
} }
internal void OnPlayerPortalTeleport(object sender, GetDataHandlers.TeleportThroughPortalEventArgs args) internal void OnPlayerPortalTeleport(object sender, GetDataHandlers.TeleportThroughPortalEventArgs args)
{ {
//Packet 96 (player teleport through portal) has no validation on whether or not the player id provided //Packet 96 (player teleport through portal) has no validation on whether or not the player id provided
@ -1713,7 +1713,7 @@ namespace TShockAPI
return; return;
} }
} }
/// <summary>Handles the anti-cheat components of gem lock toggles.</summary> /// <summary>Handles the anti-cheat components of gem lock toggles.</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>
@ -1743,7 +1743,7 @@ namespace TShockAPI
return; return;
} }
} }
/// <summary>Handles validation of of basic anti-cheat on mass wire operations.</summary> /// <summary>Handles validation of of basic anti-cheat on mass wire operations.</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>

View file

@ -2565,7 +2565,7 @@ namespace TShockAPI
private static void Home(CommandArgs args) private static void Home(CommandArgs args)
{ {
args.Player.Spawn(); args.Player.Spawn(PlayerSpawnContext.RecallFromItem);
args.Player.SendSuccessMessage("Teleported to your spawnpoint."); args.Player.SendSuccessMessage("Teleported to your spawnpoint.");
} }

View file

@ -2092,7 +2092,7 @@ namespace TShockAPI
if (respawnTimer > 0) if (respawnTimer > 0)
args.Player.Dead = true; args.Player.Dead = true;
else else
args.Player.Dead = false; args.Player.Dead = false;
return false; return false;
} }
@ -2662,7 +2662,7 @@ namespace TShockAPI
if (type == 1 && TShock.Config.DisableDungeonGuardian) if (type == 1 && TShock.Config.DisableDungeonGuardian)
{ {
args.Player.SendMessage("The Dungeon Guardian returned you to your spawn point", Color.Purple); args.Player.SendMessage("The Dungeon Guardian returned you to your spawn point", Color.Purple);
args.Player.Spawn(); args.Player.Spawn(PlayerSpawnContext.RecallFromItem);
return true; return true;
} }

View file

@ -1,4 +1,4 @@
/* /*
TShock, a server mod for Terraria TShock, a server mod for Terraria
Copyright (C) 2011-2019 Pryaxis & TShock Contributors Copyright (C) 2011-2019 Pryaxis & TShock Contributors
@ -18,6 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
using System.IO; using System.IO;
using System.IO.Streams; using System.IO.Streams;
using Terraria;
namespace TShockAPI.Net namespace TShockAPI.Net
{ {
@ -28,15 +29,19 @@ namespace TShockAPI.Net
get { return PacketTypes.PlayerSpawn; } get { return PacketTypes.PlayerSpawn; }
} }
public byte PlayerIndex { get; set; }
public short TileX { get; set; } public short TileX { get; set; }
public short TileY { get; set; } public short TileY { get; set; }
public byte PlayerIndex { get; set; } public int RespawnTimer { get; set; }
public PlayerSpawnContext PlayerSpawnContext { get; set; }
public override void Pack(Stream stream) public override void Pack(Stream stream)
{ {
stream.WriteInt8(PlayerIndex); stream.WriteInt8(PlayerIndex);
stream.WriteInt32(TileX); stream.WriteInt16(TileX);
stream.WriteInt32(TileY); stream.WriteInt16(TileY);
stream.WriteInt32(RespawnTimer);
stream.WriteByte((byte) PlayerSpawnContext);
} }
} }
} }

View file

@ -297,7 +297,11 @@ namespace TShockAPI
/// <summary> /// <summary>
/// The player's respawn timer. /// The player's respawn timer.
/// </summary> /// </summary>
public int RespawnTimer; public int RespawnTimer
{
get => TPlayer.respawnTimer;
set => TPlayer.respawnTimer = value;
}
/// <summary> /// <summary>
/// Whether the player is dead or not. /// Whether the player is dead or not.
@ -569,7 +573,7 @@ namespace TShockAPI
} }
} }
} }
} }
return check; return check;
@ -1164,15 +1168,15 @@ namespace TShockAPI
/// <summary> /// <summary>
/// Spawns the player at his spawn point. /// Spawns the player at his spawn point.
/// </summary> /// </summary>
public void Spawn() public void Spawn(PlayerSpawnContext context, int? respawnTimer = null)
{ {
if (this.sX > 0 && this.sY > 0) if (this.sX > 0 && this.sY > 0)
{ {
Spawn(this.sX, this.sY); Spawn(this.sX, this.sY, context, respawnTimer);
} }
else else
{ {
Spawn(TPlayer.SpawnX, TPlayer.SpawnY); Spawn(TPlayer.SpawnX, TPlayer.SpawnY, context, respawnTimer);
} }
} }
@ -1181,7 +1185,9 @@ namespace TShockAPI
/// </summary> /// </summary>
/// <param name="tilex">The X coordinate.</param> /// <param name="tilex">The X coordinate.</param>
/// <param name="tiley">The Y coordinate.</param> /// <param name="tiley">The Y coordinate.</param>
public void Spawn(int tilex, int tiley) /// <param name="context">The PlayerSpawnContext.</param>
/// <param name="respawnTimer">The respawn timer, will be Player.respawnTimer if parameter is null.</param>
public void Spawn(int tilex, int tiley, PlayerSpawnContext context, int? respawnTimer = null)
{ {
using (var ms = new MemoryStream()) using (var ms = new MemoryStream())
{ {
@ -1189,7 +1195,9 @@ namespace TShockAPI
{ {
PlayerIndex = (byte)Index, PlayerIndex = (byte)Index,
TileX = (short)tilex, TileX = (short)tilex,
TileY = (short)tiley TileY = (short)tiley,
RespawnTimer = respawnTimer ?? TShock.Players[Index].TPlayer.respawnTimer,
PlayerSpawnContext = context,
}; };
msg.PackFull(ms); msg.PackFull(ms);
SendRawData(ms.ToArray()); SendRawData(ms.ToArray());
@ -1215,7 +1223,7 @@ namespace TShockAPI
} }
} }
/// <summary>Sends a tile square at a location with a given size. /// <summary>Sends a tile square at a location with a given size.
/// Typically used to revert changes by Bouncer through sending the /// Typically used to revert changes by Bouncer through sending the
/// "old" version of modified data back to a client. /// "old" version of modified data back to a client.
/// Prevents desync issues. /// Prevents desync issues.
@ -1624,7 +1632,7 @@ namespace TShockAPI
public void SendMultipleMatchError(IEnumerable<object> matches) public void SendMultipleMatchError(IEnumerable<object> matches)
{ {
SendErrorMessage("More than one match found: "); SendErrorMessage("More than one match found: ");
var lines = PaginationTools.BuildLinesFromTerms(matches.ToArray()); var lines = PaginationTools.BuildLinesFromTerms(matches.ToArray());
lines.ForEach(SendInfoMessage); lines.ForEach(SendInfoMessage);

View file

@ -1048,7 +1048,7 @@ namespace TShockAPI
if (player.RespawnTimer > 0 && --player.RespawnTimer == 0 && player.Difficulty != 2) if (player.RespawnTimer > 0 && --player.RespawnTimer == 0 && player.Difficulty != 2)
{ {
player.Spawn(); player.Spawn(PlayerSpawnContext.ReviveFromDeath);
} }
if (!Main.ServerSideCharacter || (Main.ServerSideCharacter && player.IsLoggedIn)) if (!Main.ServerSideCharacter || (Main.ServerSideCharacter && player.IsLoggedIn))