Port SRB2Classic Packetloss indication logic
This commit is contained in:
parent
84422603d0
commit
fcba6319d3
4 changed files with 26 additions and 15 deletions
|
|
@ -5764,7 +5764,6 @@ static void SV_Maketic(void)
|
|||
INT32 i;
|
||||
for (i = 0; i < MAXPLAYERS; i++)
|
||||
{
|
||||
packetloss[i][maketic%PACKETMEASUREWINDOW] = false;
|
||||
if (!playeringame[i])
|
||||
continue;
|
||||
if (K_PlayerUsesBotMovement(&players[i]))
|
||||
|
|
@ -5780,8 +5779,6 @@ static void SV_Maketic(void)
|
|||
// Copy the input from the previous tic
|
||||
*ticcmd = *prevticcmd;
|
||||
ticcmd->flags &= ~TICCMD_RECEIVED;
|
||||
// packetloss[i][leveltime%PACKETMEASUREWINDOW] = (cmd->flags & TICCMD_RECEIVED) ? false : true;
|
||||
//packetloss[i][maketic%PACKETMEASUREWINDOW] = true;
|
||||
}
|
||||
}
|
||||
// Moved here so bots and packetloss indication doesn't break....
|
||||
|
|
@ -5933,7 +5930,7 @@ static INT32 pingtimeout[MAXPLAYERS];
|
|||
|
||||
static inline void PingUpdate(void)
|
||||
{
|
||||
INT32 i, j;
|
||||
INT32 i;
|
||||
boolean laggers[MAXPLAYERS];
|
||||
UINT8 numlaggers = 0;
|
||||
doomdata_t *netbuffer = DOOMCOM_DATA(doomcom);
|
||||
|
|
@ -5997,14 +5994,18 @@ static inline void PingUpdate(void)
|
|||
playerpingtable[i] = realpingtable[i] / pingmeasurecount;
|
||||
realpingtable[i] = 0; //Reset each as we go.
|
||||
|
||||
UINT32 lost = 0;
|
||||
for (j = 0; j < PACKETMEASUREWINDOW; j++)
|
||||
UINT32 node = playernode[i];
|
||||
if (node < MAXNETNODES)
|
||||
{
|
||||
if (packetloss[i][j])
|
||||
lost++;
|
||||
if (sentpackets[node] == 0)
|
||||
playerpacketlosstable[i] = 0;
|
||||
else
|
||||
playerpacketlosstable[i] = lostpackets[node];
|
||||
lostpackets[node] = 0;
|
||||
sentpackets[node] = 0;
|
||||
}
|
||||
|
||||
netbuffer->u.netinfo.packetloss[i] = lost;
|
||||
netbuffer->u.netinfo.packetloss[i] = playerpacketlosstable[i];
|
||||
netbuffer->u.netinfo.delay[i] = playerdelaytable[i];
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -360,7 +360,7 @@ struct doomdata_t
|
|||
UINT8 ackreturn; // The return of the ack number
|
||||
|
||||
UINT8 packettype;
|
||||
UINT8 reserved; // Padding
|
||||
UINT8 packetindex;
|
||||
union
|
||||
{
|
||||
clientcmd_pak clientpak;
|
||||
|
|
|
|||
15
src/d_net.c
15
src/d_net.c
|
|
@ -97,12 +97,12 @@ bannednode_t *bannednode = NULL;
|
|||
static tic_t statstarttic;
|
||||
INT32 getbytes = 0;
|
||||
INT64 sendbytes = 0;
|
||||
UINT32 sentpackets[MAXNETNODES];
|
||||
UINT32 lostpackets[MAXNETNODES];
|
||||
static INT32 retransmit = 0, duppacket = 0;
|
||||
static INT32 sendackpacket = 0, getackpacket = 0;
|
||||
INT32 ticruned = 0, ticmiss = 0;
|
||||
|
||||
boolean packetloss[MAXPLAYERS][PACKETMEASUREWINDOW];
|
||||
|
||||
// globals
|
||||
INT32 getbps, sendbps;
|
||||
float lostpercent, duppercent, gamelostpercent;
|
||||
|
|
@ -194,6 +194,8 @@ typedef struct
|
|||
UINT8 nextacknum;
|
||||
|
||||
UINT8 flags;
|
||||
UINT8 sendnum;
|
||||
UINT8 recvnum;
|
||||
} netnode_t;
|
||||
|
||||
static netnode_t nodes[MAXNETNODES];
|
||||
|
|
@ -523,6 +525,7 @@ void Net_AckTicker(void)
|
|||
ackpak[i].senttime = I_GetTime();
|
||||
ackpak[i].resentnum++;
|
||||
ackpak[i].nextacknum = node->nextacknum;
|
||||
netbuffer->packetindex = node->sendnum++;
|
||||
retransmit++; // For stat
|
||||
HSendPacket((INT32)(node - nodes), false, ackpak[i].acknum,
|
||||
(size_t)(ackpak[i].length - BASEPACKETSIZE));
|
||||
|
|
@ -633,6 +636,8 @@ static void InitNode(netnode_t *node)
|
|||
node->nextacknum = 1;
|
||||
node->remotefirstack = 0;
|
||||
node->flags = 0;
|
||||
node->sendnum = 0;
|
||||
node->recvnum = 0;
|
||||
}
|
||||
|
||||
static void InitAck(void)
|
||||
|
|
@ -1077,6 +1082,7 @@ boolean HSendPacket(INT32 node, boolean reliable, UINT8 acknum, size_t packetlen
|
|||
else
|
||||
netbuffer->ack = acknum;
|
||||
|
||||
netbuffer->packetindex = nodes[doomcom->remotenode].sendnum++;
|
||||
netbuffer->checksum = NetbufferChecksum();
|
||||
sendbytes += packetheaderlength + doomcom->datalength; // For stat
|
||||
|
||||
|
|
@ -1196,6 +1202,11 @@ boolean HGetPacket(void)
|
|||
continue; // discarded (duplicated)
|
||||
}
|
||||
|
||||
// measure packet loss
|
||||
sentpackets[doomcom->remotenode] += (UINT32)netbuffer->packetindex - nodes[doomcom->remotenode].recvnum;
|
||||
lostpackets[doomcom->remotenode] += (UINT32)netbuffer->packetindex - nodes[doomcom->remotenode].recvnum - 1;
|
||||
nodes[doomcom->remotenode].recvnum = netbuffer->packetindex;
|
||||
|
||||
// A packet with just ackreturn
|
||||
if (netbuffer->packettype == PT_NOTHING)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -41,9 +41,8 @@ extern INT32 packetheaderlength;
|
|||
boolean Net_GetNetStat(void);
|
||||
extern INT32 getbytes;
|
||||
extern INT64 sendbytes; // Realtime updated
|
||||
|
||||
#define PACKETMEASUREWINDOW (TICRATE*2)
|
||||
extern boolean packetloss[MAXPLAYERS][PACKETMEASUREWINDOW];
|
||||
extern UINT32 sentpackets[MAXNETNODES];
|
||||
extern UINT32 lostpackets[MAXNETNODES];
|
||||
|
||||
extern SINT8 nodetoplayer[MAXNETNODES];
|
||||
extern SINT8 nodetoplayer2[MAXNETNODES]; // Say the numplayer for this node if any (splitscreen)
|
||||
|
|
|
|||
Loading…
Reference in a new issue