Unbatcher: simplify GetNextMessage

This commit is contained in:
mischa 2023-06-15 19:37:53 +08:00
parent 54f6abb6ce
commit 581d16eb75

View File

@ -90,22 +90,17 @@ public bool GetNextMessage(out NetworkReader message, out double remoteTimeStamp
// ProcessMessage(message);
//
message = null;
remoteTimeStamp = 0;
// do nothing if we don't have any batches.
// otherwise the below queue.Dequeue() would throw an
// InvalidOperationException if operating on empty queue.
if (batches.Count == 0)
{
remoteTimeStamp = 0;
return false;
}
// was our reader pointed to anything yet?
if (reader.Capacity == 0)
{
remoteTimeStamp = 0;
return false;
}
// no more data to read?
if (reader.Remaining == 0)
@ -123,11 +118,7 @@ public bool GetNextMessage(out NetworkReader message, out double remoteTimeStamp
StartReadingBatch(next);
}
// otherwise there's nothing more to read
else
{
remoteTimeStamp = 0;
return false;
}
else return false;
}
// use the current batch's remote timestamp