Skip to content

Commit

Permalink
Merge pull request #2952 from drunderscore/fix/player-data-is-sometim…
Browse files Browse the repository at this point in the history
…es-not-there

Ensure `TSPlayer.PlayerData` is non-null whilst syncing loadouts
  • Loading branch information
hakusaro authored Jan 27, 2025
2 parents de8a0a6 + 3115e1f commit 64a4c9c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
5 changes: 5 additions & 0 deletions TShockAPI/GetDataHandlers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 2 additions & 0 deletions docs/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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):
Expand Down

0 comments on commit 64a4c9c

Please sign in to comment.