Skip to content

Commit

Permalink
Fix NRE during sync
Browse files Browse the repository at this point in the history
  • Loading branch information
Lacyway committed Sep 26, 2024
1 parent a9dc1a1 commit 45b12e6
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions Fika.Core/Coop/Components/CoopHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public class CoopHandler : MonoBehaviour
public Dictionary<int, CoopPlayer> Players = [];
public List<CoopPlayer> HumanPlayers = [];
public int AmountOfHumans = 1;
public List<int> ExtractedPlayers = [];
public List<int> ExtractedPlayers = [];
public List<string> queuedProfileIds = [];
public CoopPlayer MyPlayer
{
Expand Down Expand Up @@ -146,7 +146,7 @@ protected void OnDestroy()
{
Players.Clear();
HumanPlayers.Clear();
}
}

public EQuitState GetQuitState()
{
Expand Down Expand Up @@ -227,7 +227,7 @@ private void ProcessQuitting()
public void SetReady(bool state)
{
ready = state;
}
}

private void SyncPlayersWithServer()
{
Expand All @@ -244,7 +244,11 @@ private void SyncPlayersWithServer()
requestPacket.Characters = [.. characters];
}

Singleton<FikaClient>.Instance.SendData(ref requestPacket, DeliveryMethod.ReliableOrdered);
FikaClient client = Singleton<FikaClient>.Instance;
if (client.NetClient.FirstPeer != null)
{
client.SendData(ref requestPacket, DeliveryMethod.ReliableOrdered);
}
}

private async void SpawnPlayer(SpawnObject spawnObject)
Expand Down

0 comments on commit 45b12e6

Please sign in to comment.