Network/ENetPacket: Fix acknowledge callback on fragmented packets
This commit is contained in:
parent
62702ec481
commit
f71d149785
|
|
@ -38,6 +38,7 @@ namespace Nz
|
||||||
NetPacket data;
|
NetPacket data;
|
||||||
std::size_t poolIndex;
|
std::size_t poolIndex;
|
||||||
std::size_t referenceCount = 0;
|
std::size_t referenceCount = 0;
|
||||||
|
UInt32 remainingFragments; // for ack
|
||||||
|
|
||||||
NazaraSignal(OnAcknowledged);
|
NazaraSignal(OnAcknowledged);
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -224,6 +224,8 @@ namespace Nz
|
||||||
startSequenceNumber = HostToNet<UInt16>(channel.outgoingReliableSequenceNumber + 1);
|
startSequenceNumber = HostToNet<UInt16>(channel.outgoingReliableSequenceNumber + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
packetRef->remainingFragments = fragmentCount;
|
||||||
|
|
||||||
for (UInt32 fragmentNumber = 0, fragmentOffset = 0; fragmentOffset < packetSize; ++fragmentNumber, fragmentOffset += fragmentLength)
|
for (UInt32 fragmentNumber = 0, fragmentOffset = 0; fragmentOffset < packetSize; ++fragmentNumber, fragmentOffset += fragmentLength)
|
||||||
{
|
{
|
||||||
if (packetSize - fragmentOffset < fragmentLength)
|
if (packetSize - fragmentOffset < fragmentLength)
|
||||||
|
|
@ -247,6 +249,9 @@ namespace Nz
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
packetRef->remainingFragments = 1;
|
||||||
|
|
||||||
ENetProtocol command;
|
ENetProtocol command;
|
||||||
command.header.channelID = channelId;
|
command.header.channelID = channelId;
|
||||||
|
|
@ -271,6 +276,7 @@ namespace Nz
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void ENetPeer::ThrottleConfigure(UInt32 interval, UInt32 acceleration, UInt32 deceleration)
|
void ENetPeer::ThrottleConfigure(UInt32 interval, UInt32 acceleration, UInt32 deceleration)
|
||||||
{
|
{
|
||||||
|
|
@ -1031,6 +1037,9 @@ namespace Nz
|
||||||
if (currentCommand->packet && wasSent)
|
if (currentCommand->packet && wasSent)
|
||||||
{
|
{
|
||||||
m_reliableDataInTransit -= currentCommand->fragmentLength;
|
m_reliableDataInTransit -= currentCommand->fragmentLength;
|
||||||
|
|
||||||
|
assert(currentCommand->packet->remainingFragments > 0);
|
||||||
|
if (--currentCommand->packet->remainingFragments == 0)
|
||||||
currentCommand->packet->OnAcknowledged();
|
currentCommand->packet->OnAcknowledged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue