Send huge unreliable packets by TCP when they are too big.

merge-requests/48/head
Mr_Goldberg 2022-05-07 16:37:09 -04:00
parent d215070876
commit 95fc8ac687
No known key found for this signature in database
GPG Key ID: 8597D87419DEF278
1 changed files with 3 additions and 1 deletions

View File

@ -1153,6 +1153,9 @@ bool Networking::sendTo(Common_Message *msg, bool reliable, Connection *conn)
{ {
if (!enabled) return false; if (!enabled) return false;
size_t size = msg->ByteSizeLong();
if (size >= 65000) reliable = true; //too big for UDP
bool ret = false; bool ret = false;
CSteamID dest_id((uint64)msg->dest_id()); CSteamID dest_id((uint64)msg->dest_id());
if (std::find(ids.begin(), ids.end(), dest_id) != ids.end()) { if (std::find(ids.begin(), ids.end(), dest_id) != ids.end()) {
@ -1178,7 +1181,6 @@ bool Networking::sendTo(Common_Message *msg, bool reliable, Connection *conn)
ret = true; ret = true;
} }
} else { } else {
size_t size = msg->ByteSizeLong();
char *buffer = new char[size]; char *buffer = new char[size];
msg->SerializeToArray(buffer, size); msg->SerializeToArray(buffer, size);
send_packet_to(udp_socket, conn->udp_ip_port, buffer, size); send_packet_to(udp_socket, conn->udp_ip_port, buffer, size);