Ensure TSPlayer.PlayerData is non-null whilst syncing loadouts

During connection, we receive a `SyncLoadout` packet before the
`ContinueConnecting2` packet, meaning we have not yet created a
`PlayerData` for this player.
This commit is contained in:
James Puleo 2023-06-09 03:00:45 -04:00
parent d00e78ed12
commit b5b72e9f6c
No known key found for this signature in database
GPG key ID: 3E16C7EFA34FB15D

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.