Merge remote-tracking branch 'upstream/general-devel' into net9-upgrade

This commit is contained in:
Luke 2025-02-02 16:43:59 +10:00
commit 677426b746
7 changed files with 28 additions and 8 deletions

View file

@ -5363,7 +5363,7 @@ namespace TShockAPI
foreach (TSPlayer ply in TShock.Players) foreach (TSPlayer ply in TShock.Players)
{ {
if (ply != null && ply.Active) if (ply != null && ply.Active && ply.FinishedHandshake)
{ {
if (displayIdsRequested) if (displayIdsRequested)
if (ply.Account != null) if (ply.Account != null)

View file

@ -2726,6 +2726,8 @@ namespace TShockAPI
short numberOfDeathsPVP = args.Data.ReadInt16(); short numberOfDeathsPVP = args.Data.ReadInt16();
PlayerSpawnContext context = (PlayerSpawnContext)args.Data.ReadByte(); PlayerSpawnContext context = (PlayerSpawnContext)args.Data.ReadByte();
args.Player.FinishedHandshake = true;
if (OnPlayerSpawn(args.Player, args.Data, player, spawnx, spawny, respawnTimer, numberOfDeathsPVE, numberOfDeathsPVP, context)) if (OnPlayerSpawn(args.Player, args.Data, player, spawnx, spawny, respawnTimer, numberOfDeathsPVE, numberOfDeathsPVP, context))
return true; return true;
@ -2762,6 +2764,7 @@ namespace TShockAPI
args.Player.Dead = true; args.Player.Dead = true;
else else
args.Player.Dead = false; args.Player.Dead = false;
return false; return false;
} }

View file

@ -351,6 +351,9 @@ namespace TShockAPI
/// <summary>Determines if the player is disabled for not clearing their trash. A re-login is the only way to reset this.</summary> /// <summary>Determines if the player is disabled for not clearing their trash. A re-login is the only way to reset this.</summary>
public bool IsDisabledPendingTrashRemoval; public bool IsDisabledPendingTrashRemoval;
/// <summary>Determines if the player has finished the handshake (Sent all necessary packets for connection, such as Request World Data, Spawn Player, etc). A normal client would do all of this no problem.</summary>
public bool FinishedHandshake = false;
/// <summary>Checks to see if active throttling is happening on events by Bouncer. Rejects repeated events by malicious clients in a short window.</summary> /// <summary>Checks to see if active throttling is happening on events by Bouncer. Rejects repeated events by malicious clients in a short window.</summary>
/// <returns>If the player is currently being throttled by Bouncer, or not.</returns> /// <returns>If the player is currently being throttled by Bouncer, or not.</returns>
public bool IsBouncerThrottled() public bool IsBouncerThrottled()

View file

@ -63,7 +63,7 @@ namespace TShockAPI
/// <summary>VersionNum - The version number the TerrariaAPI will return back to the API. We just use the Assembly info.</summary> /// <summary>VersionNum - The version number the TerrariaAPI will return back to the API. We just use the Assembly info.</summary>
public static readonly Version VersionNum = Assembly.GetExecutingAssembly().GetName().Version; public static readonly Version VersionNum = Assembly.GetExecutingAssembly().GetName().Version;
/// <summary>VersionCodename - The version codename is displayed when the server starts. Inspired by software codenames conventions.</summary> /// <summary>VersionCodename - The version codename is displayed when the server starts. Inspired by software codenames conventions.</summary>
public static readonly string VersionCodename = "Intensity"; public static readonly string VersionCodename = "East";
/// <summary>SavePath - This is the path TShock saves its data in. This path is relative to the TerrariaServer.exe (not in ServerPlugins).</summary> /// <summary>SavePath - This is the path TShock saves its data in. This path is relative to the TerrariaServer.exe (not in ServerPlugins).</summary>
public static string SavePath = "tshock"; public static string SavePath = "tshock";
@ -1366,6 +1366,8 @@ namespace TShockAPI
} }
} }
} }
Bans.CheckBan(player);
Players[args.Who] = player; Players[args.Who] = player;
} }
@ -1387,7 +1389,8 @@ namespace TShockAPI
return; return;
} }
Bans.CheckBan(player); if (Bans.CheckBan(player))
return;
} }
/// <summary>OnLeave - Called when a player leaves the server.</summary> /// <summary>OnLeave - Called when a player leaves the server.</summary>
@ -1427,7 +1430,7 @@ namespace TShockAPI
if (tsplr.ReceivedInfo) if (tsplr.ReceivedInfo)
{ {
if (!tsplr.SilentKickInProgress && tsplr.State >= 3) if (!tsplr.SilentKickInProgress && tsplr.State >= 3 && tsplr.FinishedHandshake) //The player has left, do not broadcast any clients exploiting the behaviour of not spawning their player.
Utils.Broadcast(GetString("{0} has left.", tsplr.Name), Color.Yellow); Utils.Broadcast(GetString("{0} has left.", tsplr.Name), Color.Yellow);
Log.Info(GetString("{0} disconnected.", tsplr.Name)); Log.Info(GetString("{0} disconnected.", tsplr.Name));
@ -1448,6 +1451,9 @@ namespace TShockAPI
} }
} }
tsplr.FinishedHandshake = false;
// Fire the OnPlayerLogout hook too, if the player was logged in and they have a TSPlayer object. // Fire the OnPlayerLogout hook too, if the player was logged in and they have a TSPlayer object.
if (tsplr.IsLoggedIn) if (tsplr.IsLoggedIn)
{ {
@ -1477,6 +1483,12 @@ namespace TShockAPI
return; return;
} }
if (!tsplr.FinishedHandshake)
{
args.Handled = true;
return;
}
if (args.Text.Length > 500) if (args.Text.Length > 500)
{ {
tsplr.Kick(GetString("Crash attempt via long chat packet."), true); tsplr.Kick(GetString("Crash attempt via long chat packet."), true);
@ -1693,14 +1705,14 @@ namespace TShockAPI
Log.Info(GetString("{0} ({1}) from '{2}' group from '{3}' joined. ({4}/{5})", player.Name, player.IP, Log.Info(GetString("{0} ({1}) from '{2}' group from '{3}' joined. ({4}/{5})", player.Name, player.IP,
player.Group.Name, player.Country, TShock.Utils.GetActivePlayerCount(), player.Group.Name, player.Country, TShock.Utils.GetActivePlayerCount(),
TShock.Config.Settings.MaxSlots)); TShock.Config.Settings.MaxSlots));
if (!player.SilentJoinInProgress) if (!player.SilentJoinInProgress && player.FinishedHandshake)
Utils.Broadcast(GetString("{0} ({1}) has joined.", player.Name, player.Country), Color.Yellow); Utils.Broadcast(GetString("{0} ({1}) has joined.", player.Name, player.Country), Color.Yellow);
} }
else else
{ {
Log.Info(GetString("{0} ({1}) from '{2}' group joined. ({3}/{4})", player.Name, player.IP, Log.Info(GetString("{0} ({1}) from '{2}' group joined. ({3}/{4})", player.Name, player.IP,
player.Group.Name, TShock.Utils.GetActivePlayerCount(), TShock.Config.Settings.MaxSlots)); player.Group.Name, TShock.Utils.GetActivePlayerCount(), TShock.Config.Settings.MaxSlots));
if (!player.SilentJoinInProgress) if (!player.SilentJoinInProgress && player.FinishedHandshake)
Utils.Broadcast(GetString("{0} has joined.", player.Name), Color.Yellow); Utils.Broadcast(GetString("{0} has joined.", player.Name), Color.Yellow);
} }

View file

@ -18,7 +18,7 @@
Also, be sure to release on github with the exact assembly version tag as below Also, be sure to release on github with the exact assembly version tag as below
so that the update manager works correctly (via the Github releases api and mimic) so that the update manager works correctly (via the Github releases api and mimic)
--> -->
<Version>5.2.1</Version> <Version>5.2.2</Version>
<AssemblyTitle>TShock for Terraria</AssemblyTitle> <AssemblyTitle>TShock for Terraria</AssemblyTitle>
<Company>Pryaxis &amp; TShock Contributors</Company> <Company>Pryaxis &amp; TShock Contributors</Company>
<Product>TShockAPI</Product> <Product>TShockAPI</Product>

View file

@ -183,7 +183,7 @@ namespace TShockAPI
/// <returns>The number of active players on the server.</returns> /// <returns>The number of active players on the server.</returns>
public int GetActivePlayerCount() public int GetActivePlayerCount()
{ {
return TShock.Players.Count(p => null != p && p.Active); return TShock.Players.Count(p => null != p && p.Active && p.FinishedHandshake);
} }
//Random should not be generated in a method //Random should not be generated in a method

View file

@ -78,6 +78,8 @@ Use past tense when adding new entries; sign your name off when you add or chang
* 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 ## Upcoming changes
* Added a variable for handshake (True upon spawn player), clients no longer notify others of their presence and cant chat if this is never set to true. (@ohayo)
* Fixed a security issue with how bans are handled on join. (@ohayo)
* Fixed `/dump-reference-data` mutate the command names. (#2943, @sgkoishi) * Fixed `/dump-reference-data` mutate the command names. (#2943, @sgkoishi)
* Added `ParryDamageBuff` (Striking Moment with Brand of the Inferno and shield) for player, updated `CursedInferno` buff for NPC (@sgkoishi, #3005) * Added `ParryDamageBuff` (Striking Moment with Brand of the Inferno and shield) for player, updated `CursedInferno` buff for NPC (@sgkoishi, #3005)
* Changed the use of `Player.active` to `TSPlayer.Active` for consistency. (@sgkoishi, #2939) * Changed the use of `Player.active` to `TSPlayer.Active` for consistency. (@sgkoishi, #2939)