Slight improvement for Packet Loss Prevention: Be able to send to 35 packets per call of net_udp_noloss_process_queue() and also let counter only increase if a packet was actually sent, making sure the queue is not stuck on the first 5 packets in the list

This commit is contained in:
zicodxx 2011-07-08 01:23:41 +02:00
parent 1bc5378f78
commit dbdf7e27dc
2 changed files with 11 additions and 9 deletions

View file

@ -1,5 +1,9 @@
D1X-Rebirth Changelog D1X-Rebirth Changelog
20110708
--------
main/net_udp.c: Slight improvement for Packet Loss Prevention: Be able to send to 35 packets per call of net_udp_noloss_process_queue() and also let counter only increase if a packet was actually sent, making sure the queue is not stuck on the first 5 packets in the list
20110704 20110704
-------- --------
main/game.c, main/gamerend.c: Only call show_netplayerinfo() if GM_MULTI is set and reset netplayerinfo_on in game_setup() main/game.c, main/gamerend.c: Only call show_netplayerinfo() if GM_MULTI is set and reset netplayerinfo_on in game_setup()

View file

@ -4246,7 +4246,7 @@ void net_udp_noloss_process_queue(fix64 time)
for (queuec = 0; queuec < UDP_MDATA_STOR_QUEUE_SIZE; queuec++) for (queuec = 0; queuec < UDP_MDATA_STOR_QUEUE_SIZE; queuec++)
{ {
fix resend_delay = (F1_0/2); fix resend_delay = (F1_0/2);
int resend = 0; int needack = 0;
if (!UDP_mdata_queue[queuec].used) if (!UDP_mdata_queue[queuec].used)
continue; continue;
@ -4284,23 +4284,21 @@ void net_udp_noloss_process_queue(fix64 time)
memcpy(&buf[len], UDP_mdata_queue[queuec].data, sizeof(char)*UDP_mdata_queue[queuec].data_size); memcpy(&buf[len], UDP_mdata_queue[queuec].data, sizeof(char)*UDP_mdata_queue[queuec].data_size);
len += UDP_mdata_queue[queuec].data_size; len += UDP_mdata_queue[queuec].data_size;
sendto (UDP_Socket[0], buf, len, 0, (struct sockaddr *)&Netgame.players[plc].protocol.udp.addr, sizeof(struct _sockaddr)); sendto (UDP_Socket[0], buf, len, 0, (struct sockaddr *)&Netgame.players[plc].protocol.udp.addr, sizeof(struct _sockaddr));
count++;
} }
resend++; needack++;
} }
} }
// Check if we can remove that packet due to to it had no resend's or Timeout // Check if we can remove that packet due to to it had no resend's or Timeout
if (!resend || UDP_mdata_queue[queuec].pkt_initial_timestamp + UDP_TIMEOUT <= time) if (needack==0 || (UDP_mdata_queue[queuec].pkt_initial_timestamp + UDP_TIMEOUT <= time))
{ {
con_printf(CON_VERBOSE, "P#%i: Removing stored pkt_num %i - All ACK: %i\n",Player_num, UDP_mdata_queue[queuec].pkt_num, !resend); con_printf(CON_VERBOSE, "P#%i: Removing stored pkt_num %i - missing ACKs: %i\n",Player_num, UDP_mdata_queue[queuec].pkt_num, needack);
memset(&UDP_mdata_queue[queuec],0,sizeof(UDP_mdata_store)); memset(&UDP_mdata_queue[queuec],0,sizeof(UDP_mdata_store));
} }
if (resend) // Send up to 35 packets (5 for all possible clients) from the queue by each time the queue process is called
count++; if (count >= 35)
// Only send 5 packets from the queue by each time the queue process is called
if (count >= 5)
break; break;
} }
} }