diff --git a/TShockAPI/GetDataHandlers.cs b/TShockAPI/GetDataHandlers.cs index 1ef2f4f8b..b736a5123 100644 --- a/TShockAPI/GetDataHandlers.cs +++ b/TShockAPI/GetDataHandlers.cs @@ -4445,6 +4445,11 @@ private static bool HandleSyncLoadout(GetDataHandlerArgs args) return true; } + // Don't modify the player data if it isn't there. + // This is the case whilst the player is connecting, as we receive the SyncLoadout packet before the ContinueConnecting2 packet. + if (args.Player.PlayerData == null) + return false; + // The client does not sync slot changes when changing loadouts, it only tells the server the loadout index changed, // and the server will replicate the changes the client did. This means that PlayerData.StoreSlot is never called, so we need to // swap around the PlayerData items ourself. diff --git a/docs/changelog.md b/docs/changelog.md index 6da4547cc..a96b47a7f 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -90,6 +90,7 @@ Use past tense when adding new entries; sign your name off when you add or chang * Fixed the `/wind` command not being very helpful. (@punchready) * Fixed /help, /me, and /p commands can't work in non-English languages. (@ACaiCat) * Added a hook `AccountHooks.AccountGroupUpdate`, which is called when you change the user group. (@AgaSpace) +* * Ensured `TSPlayer.PlayerData` is non-null whilst syncing loadouts. (@drunderscore) ## TShock 5.2.1 * Updated `TSPlayer.GodMode`. (@AgaSpace) @@ -108,6 +109,7 @@ Use past tense when adding new entries; sign your name off when you add or chang * Added CI for Docker images. (@timschumi) * Fixed Cursed Flares kicking players for invalid buff. (@Arthri) + ## TShock 5.2 * An additional option `pvpwithnoteam` is added at `PvPMode` to enable PVP with no team. (@CelestialAnarchy, #2617, @ATFGK) * Corrected and updated deserialization of the following packets (@ATFGK):