Merge pull request #2952 from drunderscore/fix/player-data-is-sometimes-not-there

Ensure `TSPlayer.PlayerData` is non-null whilst syncing loadouts
This commit is contained in:
Lucas Nicodemus 2025-01-27 09:00:47 +09:00 committed by GitHub
commit 64a4c9c1cd
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 7 additions and 0 deletions

View file

@ -4445,6 +4445,11 @@ namespace TShockAPI
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.

View file

@ -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):