Created
July 14, 2013 20:25
-
-
Save bqqbarbhg/5995832 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
P = send_reliable.begin(); | |
while (!send_reliable.empty()) { | |
unsigned int fragc = fragment_count(writer.write_amount(), P->packet.size()); | |
unsigned int start = 0; | |
for (unsigned int i = 0; i < fragc - 1; i++) { | |
start += add_packet(writer, P->chan, P->packet, start, fragc); | |
send_packet(writer); | |
} | |
add_packet(writer, P->chan, P->packet, start, fragc); | |
send_reliable.erase(P); | |
auto pos = writer.write_amount(); | |
while (can_fit_any(pos)) { | |
auto it = std::find_if(send_reliable.begin(), send_reliable.end(), | |
[=](const SendPacket& p) { | |
return fragment_count(pos, p.packet.size()) == 1; | |
}); | |
if (it != send_reliable.end()) { | |
add_packet(writer, it->chan, it->packet, 0, 1); | |
send_reliable.erase(it); | |
} else { | |
break; | |
} | |
pos = writer.write_amount(); | |
} | |
if (can_fit_any(pos)) { | |
auto it = std::find_if(send_reliable.begin(), send_reliable.end(), | |
[=](const SendPacket& p) { | |
return fragment_count(pos, p.packet.size()) < fragment_count(0, p.packet.size()); | |
}); | |
if (it != send_reliable.end()) { | |
P = it; | |
continue; | |
} | |
} | |
send_packet(writer); | |
P = send_reliable.begin(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment