You've already forked lidgren-network-gen3
mirror of
https://github.com/lidgren/lidgren-network-gen3.git
synced 2026-05-06 02:11:06 +09:00
NetQueue fixes
This commit is contained in:
@@ -67,9 +67,6 @@ namespace Lidgren.Network
|
||||
throw new NetException("Executing on wrong thread! Should be library system thread (is " + ct.Name + " mId " + ct.ManagedThreadId + ")");
|
||||
}
|
||||
|
||||
//
|
||||
// Network loop
|
||||
//
|
||||
private void InitializeNetwork()
|
||||
{
|
||||
//
|
||||
@@ -143,6 +140,9 @@ namespace Lidgren.Network
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Network loop
|
||||
//
|
||||
private void NetworkLoop()
|
||||
{
|
||||
VerifyNetworkThread();
|
||||
|
||||
@@ -173,8 +173,16 @@ namespace Lidgren.Network
|
||||
int ptr = m_head;
|
||||
for (int i = 0; i < m_size; i++)
|
||||
{
|
||||
if (m_items[ptr].Equals(item))
|
||||
return true;
|
||||
if (m_items[ptr] == null)
|
||||
{
|
||||
if (item == null)
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (m_items[ptr].Equals(item))
|
||||
return true;
|
||||
}
|
||||
ptr = (ptr + 1) % m_items.Length;
|
||||
}
|
||||
}
|
||||
@@ -188,6 +196,7 @@ namespace Lidgren.Network
|
||||
for (int i = 0; i < m_items.Length; i++)
|
||||
m_items[i] = default(T);
|
||||
m_head = 0;
|
||||
m_size = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,6 +14,12 @@ namespace UnitTests
|
||||
queue.Enqueue(2);
|
||||
queue.Enqueue(3);
|
||||
|
||||
if (queue.Contains(4))
|
||||
throw new Exception("NetQueue Contains failure");
|
||||
|
||||
if (!queue.Contains(2))
|
||||
throw new Exception("NetQueue Contains failure 2");
|
||||
|
||||
if (queue.Count != 3)
|
||||
throw new Exception("NetQueue failed");
|
||||
if (queue.TryDequeue() != 1)
|
||||
|
||||
Reference in New Issue
Block a user