Fix RUDP ordered control sequence parity
This commit is contained in:
parent
38d772c250
commit
4335ab10bd
9 changed files with 237 additions and 1 deletions
|
|
@ -1377,6 +1377,14 @@ namespace GameCult.Networking
|
|||
_orderedNextSequenceByChannel[frame.ChannelId] = next;
|
||||
}
|
||||
|
||||
while (frame.Sequence > next
|
||||
&& _receivedSequences.Contains(next)
|
||||
&& (!_orderedBuffers.TryGetValue(frame.ChannelId, out var pendingBuffer) || !pendingBuffer.ContainsKey(next)))
|
||||
{
|
||||
next++;
|
||||
_orderedNextSequenceByChannel[frame.ChannelId] = next;
|
||||
}
|
||||
|
||||
if (frame.Sequence < next)
|
||||
{
|
||||
return Array.Empty<CultNetRudpDeliveredFrame>();
|
||||
|
|
@ -1411,11 +1419,27 @@ namespace GameCult.Networking
|
|||
buffer.Remove(next);
|
||||
delivered.Add(pending.Frame);
|
||||
_orderedNextSequenceByChannel[channelId] = pending.NextSequence;
|
||||
SkipReceivedNonChannelSequences(channelId);
|
||||
}
|
||||
|
||||
return delivered;
|
||||
}
|
||||
|
||||
private void SkipReceivedNonChannelSequences(string channelId)
|
||||
{
|
||||
if (!_orderedNextSequenceByChannel.TryGetValue(channelId, out var next))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
while (_receivedSequences.Contains(next)
|
||||
&& (!_orderedBuffers.TryGetValue(channelId, out var buffer) || !buffer.ContainsKey(next)))
|
||||
{
|
||||
next++;
|
||||
_orderedNextSequenceByChannel[channelId] = next;
|
||||
}
|
||||
}
|
||||
|
||||
private ushort AllocateFragmentId()
|
||||
{
|
||||
var fragmentId = _nextFragmentId;
|
||||
|
|
|
|||
Loading…
Reference in a new issue