Further parse bunches till their channel receives them

This commit is contained in:
AeonLucid
2022-01-10 20:20:02 +01:00
parent f3b0a31761
commit 0a27bdd3c0
23 changed files with 1187 additions and 51 deletions
@@ -71,7 +71,7 @@ public class FNetPacketNotify
var inSeqDelta = GetSequenceDelta(notificationData);
if (inSeqDelta > 0)
{
Logger.Verbose("FNetPacketNotify::Update - Seq {Seq}, InSeq {InSeq}", notificationData.Seq.Value, _inSeq.Value);
Logger.Verbose("Update - Seq {Seq}, InSeq {InSeq}", notificationData.Seq.Value, _inSeq.Value);
ProcessReceivedAcks(notificationData, func);
@@ -143,4 +143,34 @@ public class FNetPacketNotify
return new SequenceNumber((ushort)(ackedSeq.Value - MaxSequenceHistoryLength));
}
/// <summary>
/// Mark Seq as received and update current InSeq, missing sequence numbers will be marked as lost
/// </summary>
public void AckSeq(SequenceNumber seq)
{
AckSeq(seq, true);
}
/// <summary>
/// Explicitly mark Seq as not received and update current InSeq, additional missing sequence numbers will be marked as lost
/// </summary>
public void NakSeq(SequenceNumber seq)
{
AckSeq(seq, false);
}
private void AckSeq(SequenceNumber ackedSeq, bool isAck)
{
while (ackedSeq.Greater(_inAckSeq))
{
_inAckSeq.IncrementAndGet();
var bReportAcked = _inAckSeq.Equals(ackedSeq) ? isAck : false;
Logger.Verbose("AckSeq - AckedSeq: {Seq}, IsAck {IsAck}", _inAckSeq.Value, bReportAcked);
_inSeqHistory.AddDeliveryStatus(bReportAcked);
}
}
}
@@ -18,15 +18,6 @@ public readonly struct SequenceHistory
{
_storage = new uint[WordCount];
}
public void Read(FBitReader reader, uint numWords)
{
numWords = Math.Min(numWords, WordCount);
for (var i = 0; i < numWords; i++)
{
_storage[i] = reader.ReadUInt32();
}
}
public void Reset()
{
@@ -36,6 +27,20 @@ public readonly struct SequenceHistory
}
}
public void AddDeliveryStatus(bool delivered)
{
var carry = delivered ? 1u : 0u;
var valueMask = 1u << (int)(BitsPerWord - 1);
for (var i = 0; i < WordCount; i++)
{
var oldValue = carry;
carry = (_storage[i] & valueMask) >> (int)(BitsPerWord - 1);
_storage[i] = (_storage[i] << 1) | oldValue;
}
}
public bool IsDelivered(int index)
{
var wordIndex = (int)(index / BitsPerWord);
@@ -43,4 +48,13 @@ public readonly struct SequenceHistory
return (_storage[wordIndex] & wordMask) != 0;
}
public void Read(FBitReader reader, uint numWords)
{
numWords = Math.Min(numWords, WordCount);
for (var i = 0; i < numWords; i++)
{
_storage[i] = reader.ReadUInt32();
}
}
}