Skip to content

Commit

Permalink
Check for null or empty scene on client enter scene
Browse files Browse the repository at this point in the history
  • Loading branch information
Extremelyd1 committed Dec 17, 2023
1 parent 139d734 commit 318eabb
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions HKMP/Game/Server/ServerManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,16 @@ private void OnClientEnterScene(ServerPlayerData playerData) {
var enterSceneList = new List<ClientPlayerEnterScene>();
var alreadyPlayersInScene = false;

// Edge case where the scene of the player is empty (uninitialized) and we don't want to match with other
// uninitialized players. Otherwise, it causes issues where other parts of the player data for other players
// could be null and result in NREs further down the line
if (string.IsNullOrEmpty(playerData.CurrentScene)) {
_netServer.GetUpdateManagerForClient(playerData.Id)?.AddPlayerAlreadyInSceneData(
enterSceneList,
true
);
}

foreach (var idPlayerDataPair in _playerData) {
// Skip source player
if (idPlayerDataPair.Key == playerData.Id) {
Expand Down

0 comments on commit 318eabb

Please sign in to comment.