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