From a4fe005e3b0a203610df2f4c780d561740a23009 Mon Sep 17 00:00:00 2001 From: Lynix Date: Wed, 8 Mar 2017 22:40:15 +0100 Subject: [PATCH] Network/ENetPeer: Fix packets not being resend after timeout sometimes --- src/Nazara/Network/ENetPeer.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/Nazara/Network/ENetPeer.cpp b/src/Nazara/Network/ENetPeer.cpp index 2a9adfcbf..5ce92a1e4 100644 --- a/src/Nazara/Network/ENetPeer.cpp +++ b/src/Nazara/Network/ENetPeer.cpp @@ -287,12 +287,15 @@ namespace Nz UInt32 serviceTime = m_host->GetServiceTime(); auto it = m_sentReliableCommands.begin(); - for (; it != m_sentReliableCommands.end(); ++it) + for (; it != m_sentReliableCommands.end();) { OutgoingCommand& command = *it; if (ENetTimeDifference(serviceTime, command.sentTime) < command.roundTripTimeout) + { + ++it; continue; + } if (m_earliestTimeout == 0 || ENetTimeLess(command.sentTime, m_earliestTimeout)) m_earliestTimeout = command.sentTime; @@ -315,6 +318,7 @@ namespace Nz command.roundTripTimeoutLimit = m_timeoutLimit * command.roundTripTimeout; m_outgoingReliableCommands.emplace_front(std::move(command)); + it = m_sentReliableCommands.erase(it); // Okay this should just never procs, I don't see how it would be possible /*if (currentCommand == enet_list_begin(&peer->sentReliableCommands) && @@ -326,8 +330,6 @@ namespace Nz }*/ } - m_sentReliableCommands.erase(m_sentReliableCommands.begin(), it); - return false; }