From 4f2fff050dbbae17d59ff9fc9ddca677665010dd Mon Sep 17 00:00:00 2001 From: ohayo Date: Sun, 2 Feb 2025 12:40:04 +1000 Subject: [PATCH] Quick bug fix - forgot about respawns + only set handshake once The connection state should NEVER be set to under 3 if the player is fully connected. --- TShockAPI/GetDataHandlers.cs | 3 ++- TShockAPI/TShock.cs | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/TShockAPI/GetDataHandlers.cs b/TShockAPI/GetDataHandlers.cs index 42bd6401..c0faf964 100644 --- a/TShockAPI/GetDataHandlers.cs +++ b/TShockAPI/GetDataHandlers.cs @@ -2726,7 +2726,8 @@ namespace TShockAPI short numberOfDeathsPVP = args.Data.ReadInt16(); PlayerSpawnContext context = (PlayerSpawnContext)args.Data.ReadByte(); - args.Player.FinishedHandshake = args.Player.State == 3; //If the player has requested world data before sending spawn player, this should be set to 3, otherwise it'll be set to 1. + if (args.Player.State >= 3 && !args.Player.FinishedHandshake) + args.Player.FinishedHandshake = true; //If the player has requested world data before sending spawn player, this should be equal to or greater than 3, otherwise it'll usually be 1. Also only set this once to remove redundant updates. if (OnPlayerSpawn(args.Player, args.Data, player, spawnx, spawny, respawnTimer, numberOfDeathsPVE, numberOfDeathsPVP, context)) return true; diff --git a/TShockAPI/TShock.cs b/TShockAPI/TShock.cs index e984da2f..d88b4403 100644 --- a/TShockAPI/TShock.cs +++ b/TShockAPI/TShock.cs @@ -1461,7 +1461,8 @@ namespace TShockAPI } } - + TShock.Log.ConsoleInfo($"Setting handshake to false for {tsplr.Name}"); + tsplr.FinishedHandshake = false; // Fire the OnPlayerLogout hook too, if the player was logged in and they have a TSPlayer object.