Skip to content

Commit

Permalink
Add errors for strange situations. Fix #555
Browse files Browse the repository at this point in the history
  • Loading branch information
RevenantX committed Jul 18, 2024
1 parent e99f35f commit 132a807
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions LiteNetLib/NetManager.HashSet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,11 @@ private void ClearPeerSet()

private bool ContainsPeer(NetPeer item)
{
if (item == null)
{
NetDebug.WriteError($"Contains peer null: {item}");
return false;
}
if (_buckets != null)
{
int hashCode = item.GetHashCode() & Lower31BitMask;
Expand Down Expand Up @@ -121,6 +126,11 @@ public bool TryGetPeerById(int id, out NetPeer peer)

private void AddPeer(NetPeer peer)
{
if (peer == null)
{
NetDebug.WriteError($"Add peer null: {peer}");
return;
}
_peersLock.EnterWriteLock();
if (_headPeer != null)
{
Expand Down Expand Up @@ -149,6 +159,11 @@ private void RemovePeer(NetPeer peer)

private void RemovePeerInternal(NetPeer peer)
{
if (peer == null)
{
NetDebug.WriteError($"Remove peer null: {peer}");
return;
}
if (!RemovePeerFromSet(peer))
return;
if (peer == _headPeer)
Expand Down
Binary file modified LiteNetLibSampleUnity/Assets/LiteNetLib.dll
Binary file not shown.

0 comments on commit 132a807

Please sign in to comment.