diff --git a/TShockAPI/DB/CharacterManager.cs b/TShockAPI/DB/CharacterManager.cs index 32ac924d..0b8246b9 100644 --- a/TShockAPI/DB/CharacterManager.cs +++ b/TShockAPI/DB/CharacterManager.cs @@ -189,7 +189,7 @@ namespace TShockAPI.DB if (!player.IsLoggedIn) return false; - if (player.State < (int)ClientState.ClientSpawned) + if (player.State < (int)ConnectionState.Complete) return false; if (player.HasPermission(Permissions.bypassssc) && !fromCommand) diff --git a/TShockAPI/GetDataHandlers.cs b/TShockAPI/GetDataHandlers.cs index 043b12a4..ac290356 100644 --- a/TShockAPI/GetDataHandlers.cs +++ b/TShockAPI/GetDataHandlers.cs @@ -2628,8 +2628,8 @@ namespace TShockAPI { if (account.UUID == args.Player.UUID) { - if (args.Player.State == (int)ClientState.ClientReceivingPlayerSlot) - args.Player.State = (int)ClientState.ClientSentPlayerInformation; + if (args.Player.State == (int)ConnectionState.AssigningPlayerSlot) + args.Player.State = (int)ConnectionState.AwaitingPlayerInfo; NetMessage.SendData((int)PacketTypes.WorldInfo, args.Player.Index); @@ -2688,8 +2688,8 @@ namespace TShockAPI return true; } - if (args.Player.State == (int)ClientState.ClientReceivingPlayerSlot) - args.Player.State = 2; + if (args.Player.State == (int)ConnectionState.AssigningPlayerSlot) + args.Player.State = (int)ConnectionState.AwaitingPlayerInfo; NetMessage.SendData((int)PacketTypes.WorldInfo, args.Player.Index); return true; @@ -2728,7 +2728,7 @@ namespace TShockAPI short numberOfDeathsPVP = args.Data.ReadInt16(); PlayerSpawnContext context = (PlayerSpawnContext)args.Data.ReadByte(); - if (args.Player.State >= (int)ClientState.ClientRequestedWorldData && !args.Player.FinishedHandshake) + if (args.Player.State >= (int)ConnectionState.RequestingWorldData && !args.Player.FinishedHandshake) args.Player.FinishedHandshake = true; //If the player has requested world data before sending spawn player, they should be at the obvious ClientRequestedWorldData state. Also only set this once to remove redundant updates. if (OnPlayerSpawn(args.Player, args.Data, player, spawnx, spawny, respawnTimer, numberOfDeathsPVE, numberOfDeathsPVP, context)) @@ -3221,8 +3221,8 @@ namespace TShockAPI args.Player.RequiresPassword = false; args.Player.PlayerData = TShock.CharacterDB.GetPlayerData(args.Player, account.ID); - if (args.Player.State == (int)ClientState.ClientReceivingPlayerSlot) - args.Player.State = (int)ClientState.ClientSentPlayerInformation; + if (args.Player.State == (int)ConnectionState.AssigningPlayerSlot) + args.Player.State = (int)ConnectionState.AwaitingPlayerInfo; NetMessage.SendData((int)PacketTypes.WorldInfo, args.Player.Index); @@ -3271,8 +3271,8 @@ namespace TShockAPI { args.Player.RequiresPassword = false; - if (args.Player.State == (int)ClientState.ClientReceivingPlayerSlot) - args.Player.State = (int)ClientState.ClientSentPlayerInformation; + if (args.Player.State == (int)ConnectionState.AssigningPlayerSlot) + args.Player.State = (int)ConnectionState.AwaitingPlayerInfo; NetMessage.SendData((int)PacketTypes.WorldInfo, args.Player.Index); return true; diff --git a/TShockAPI/TSPlayer.cs b/TShockAPI/TSPlayer.cs index aeadd408..cf08d5bf 100644 --- a/TShockAPI/TSPlayer.cs +++ b/TShockAPI/TSPlayer.cs @@ -65,44 +65,44 @@ namespace TShockAPI /// /// An enum based on the current client's connection state to the server. /// - public enum ClientState : int + public enum ConnectionState : int { /// - /// The server has accepted the client's connection but now requires a password from them before they can continue. (Only for password protected servers) + /// The server is password protected and the connection is pending until a password is sent by the client. /// - RequiresPassword = -1, + AwaitingPassword = -1, /// - /// The server has accepted the client's connection. In this state, they will send their current version string to the server. + /// The connection has been established, and the client must verify its version. /// - ClientConnecting = 0, + AwaitingVersionCheck = 0, /// - /// The server has accepted the client's password to connect and/or the server has verified the client's version string as being correct. In this state, the server will send them their user slot and in return, they must send their player information. + /// The server has accepted the client's password to connect and/or the server has verified the client's version string as being correct. The client is now being assigned a player slot. /// - ClientReceivingPlayerSlot = 1, + AssigningPlayerSlot = 1, /// - /// The client has sent their player information. In this state, they must request world data. + /// The player slot has been received by the client, and the server is now waiting for the player information. /// - ClientSentPlayerInformation = 2, + AwaitingPlayerInfo = 2, /// - /// The client has requested the world data. + /// Player information has been received, and the client is requesting world data. /// - ClientRequestedWorldData = 3, + RequestingWorldData = 3, /// - /// The client has received the world data. + /// The world data is being sent to the client. /// - ClientReceivedWorldData = 4, + ReceivingWorldData = 4, /// - /// The client has loaded the world data and map. + /// The world data has been received, and the client is now finalizing the load. /// - ClientLoadedWorldData = 5, + FinalizingWorldLoad = 5, /// /// The client is requesting tile data. /// - ClientRequestingTileData = 6, + RequestingTileData = 6, /// - /// The client has sent a SpawnPlayer packet and has finished the connection process. + /// The connection process is complete (The player has spawned), and the client has fully joined the game. /// - ClientSpawned = 10 + Complete = 10 } public class TSPlayer @@ -2186,7 +2186,7 @@ namespace TShockAPI if (!NecessaryPacket(msgType) && !FinishedHandshake) return; - if (msgType == PacketTypes.WorldInfo && State < (int)ClientState.ClientRequestedWorldData) + if (msgType == PacketTypes.WorldInfo && State < (int)ConnectionState.RequestingWorldData) return; NetMessage.SendData((int)msgType, Index, -1, text == null ? null : NetworkText.FromLiteral(text), number, number2, number3, number4, number5); diff --git a/TShockAPI/TShock.cs b/TShockAPI/TShock.cs index b70a857d..f3afa716 100644 --- a/TShockAPI/TShock.cs +++ b/TShockAPI/TShock.cs @@ -1440,7 +1440,7 @@ namespace TShockAPI if (tsplr.ReceivedInfo) { - if (!tsplr.SilentKickInProgress && tsplr.State >= (int)ClientState.ClientRequestedWorldData && tsplr.FinishedHandshake) //The player has left, do not broadcast any clients exploiting the behaviour of not spawning their player. + if (!tsplr.SilentKickInProgress && tsplr.State >= (int)ConnectionState.RequestingWorldData && 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); Log.Info(GetString("{0} disconnected.", tsplr.Name)); @@ -1678,7 +1678,7 @@ namespace TShockAPI return; } - if ((player.State < (int)ClientState.ClientSpawned || player.Dead) && (int)type > 12 && (int)type != 16 && (int)type != 42 && (int)type != 50 && + if ((player.State < (int)ConnectionState.Complete || player.Dead) && (int)type > 12 && (int)type != 16 && (int)type != 42 && (int)type != 50 && (int)type != 38 && (int)type != 21 && (int)type != 22 && type != PacketTypes.SyncLoadout) { e.Handled = true;