static void NET_SV_ParseGameDataACK(net_packet_t *packet, net_client_t *client) { unsigned int ackseq; if (server_state != SERVER_IN_GAME) { return; } // Read header if (!NET_ReadInt8(packet, &ackseq)) { return; } // Expand 8-bit values to the full sequence number ackseq = NET_SV_ExpandTicNum(ackseq); // Higher acknowledgement point than we already have? if (ackseq > client->acknowledged) { client->acknowledged = ackseq; } }
static void NET_SV_ParseGameDataACK(net_packet_t *packet, net_client_t *client) { unsigned int ackseq; NET_Log("server: processing game data ack packet"); if (server_state != SERVER_IN_GAME) { NET_Log("server: error: not in game state, server_state=%d", server_state); return; } // Read header if (!NET_ReadInt8(packet, &ackseq)) { NET_Log("server: error: missing acknowledgement field"); return; } // Expand 8-bit values to the full sequence number ackseq = NET_SV_ExpandTicNum(ackseq); // Higher acknowledgement point than we already have? if (ackseq > client->acknowledged) { NET_Log("server: acknowledged up to %d", ackseq); client->acknowledged = ackseq; } }
static void NET_SV_ParseGameData(net_packet_t *packet, net_client_t *client) { net_client_recv_t *recvobj; unsigned int seq; unsigned int ackseq; unsigned int num_tics; unsigned int nowtime; size_t i; int player; int resend_start, resend_end; int index; if (server_state != SERVER_IN_GAME) { return; } if (client->drone) { // Drones do not contribute any game data. return; } player = client->player_number; // Read header if (!NET_ReadInt8(packet, &ackseq) || !NET_ReadInt8(packet, &seq) || !NET_ReadInt8(packet, &num_tics)) { return; } // Get the current time nowtime = I_GetTimeMS(); // Expand 8-bit values to the full sequence number ackseq = NET_SV_ExpandTicNum(ackseq); seq = NET_SV_ExpandTicNum(seq); // Sanity checks for (i=0; i<num_tics; ++i) { net_ticdiff_t diff; signed int latency; if (!NET_ReadSInt16(packet, &latency) || !NET_ReadTiccmdDiff(packet, &diff, sv_settings.lowres_turn)) { return; } index = seq + i - recvwindow_start; if (index < 0 || index >= BACKUPTICS) { // Not in range of the recv window continue; } recvobj = &recvwindow[index][player]; recvobj->active = true; recvobj->diff = diff; recvobj->latency = latency; client->last_gamedata_time = nowtime; } // Higher acknowledgement point? if (ackseq > client->acknowledged) { client->acknowledged = ackseq; } // Has this been received out of sequence, ie. have we not received // all tics before the first tic in this packet? If so, send a // resend request. //printf("SV: %p: %i\n", client, seq); resend_end = seq - recvwindow_start; if (resend_end <= 0) return; if (resend_end >= BACKUPTICS) resend_end = BACKUPTICS - 1; index = resend_end - 1; resend_start = resend_end; while (index >= 0) { recvobj = &recvwindow[index][player]; if (recvobj->active) { // ended our run of unreceived tics break; } if (recvobj->resend_time != 0) { // Already sent a resend request for this tic break; } resend_start = index; --index; } // Possibly send a resend request if (resend_start < resend_end) { /* printf("missed %i-%i before %i, send resend\n", recvwindow_start + resend_start, recvwindow_start + resend_end - 1, seq); */ NET_SV_SendResendRequest(client, recvwindow_start + resend_start, recvwindow_start + resend_end - 1); } }