Rewrite ping timeout

- Reduce the joiner grace period for normal ping limit to 10 seconds (from 30)
- Properly account for ignoring all local players when the host is splitscreen

# Conflicts:
#	src/d_clisrv.c
This commit is contained in:
toaster 2022-10-26 20:27:32 +01:00
parent 3b212a1138
commit c77147fd1c

View file

@ -5529,56 +5529,64 @@ boolean TryRunTics(tic_t realtics)
static INT32 pingtimeout[MAXPLAYERS]; static INT32 pingtimeout[MAXPLAYERS];
#define PINGKICK_TICQUEUE 2
#define PINGKICK_LIMIT 1
static inline void PingUpdate(void) static inline void PingUpdate(void)
{ {
INT32 i; INT32 i;
boolean laggers[MAXPLAYERS]; boolean pingkick[MAXPLAYERS];
UINT8 numlaggers = 0; UINT8 nonlaggers = 0;
memset(laggers, 0, sizeof(boolean) * MAXPLAYERS); memset(pingkick, 0, sizeof(pingkick));
netbuffer->packettype = PT_PING; netbuffer->packettype = PT_PING;
//check for ping limit breakage. //check for ping limit breakage.
if (cv_maxping.value) if (cv_maxping.value)
{ {
for (i = 1; i < MAXPLAYERS; i++) for (i = 0; i < MAXPLAYERS; i++)
{ {
if (playeringame[i] if (!playeringame[i] || P_IsMachineLocalPlayer(&players[i]))
&& (realpingtable[i] / pingmeasurecount > (unsigned)cv_maxping.value))
{ {
if (players[i].jointime > 30 * TICRATE) pingtimeout[i] = 0;
laggers[i] = true; continue;
numlaggers++; }
if ((cv_maxping.value)
&& (realpingtable[i] / pingmeasurecount > (unsigned)cv_maxping.value))
{
if (players[i].jointime > 10 * TICRATE)
{
pingkick[i] = true;
}
} }
else else
pingtimeout[i] = 0; {
nonlaggers++;
// you aren't lagging, but you aren't free yet. In case you'll keep spiking, we just make the timer go back down. (Very unstable net must still get kicked).
if (pingtimeout[i] > 0)
pingtimeout[i]--;
}
} }
//kick lagging players... unless everyone but the server's ping sucks. //kick lagging players... unless everyone but the server's ping sucks.
//in that case, it is probably the server's fault. //in that case, it is probably the server's fault.
if (numlaggers < D_NumPlayers() - 1) if (nonlaggers > 0)
{ {
for (i = 1; i < MAXPLAYERS; i++) for (i = 0; i < MAXPLAYERS; i++)
{ {
if (playeringame[i] && laggers[i]) XBOXSTATIC char buf[2];
{
pingtimeout[i]++;
// ok your net has been bad for too long, you deserve to die. if (!playeringame[i] || !pingkick[i])
if (pingtimeout[i] > cv_pingtimeout.value) continue;
{
pingtimeout[i] = 0; // Don't kick on ping alone if we haven't reached our threshold yet.
SendKick(i, KICK_MSG_PING_HIGH); if (++pingtimeout[i] < cv_pingtimeout.value)
} continue;
}
/* pingtimeout[i] = 0;
you aren't lagging, SendKick(i, KICK_MSG_PING_HIGH);
but you aren't free yet.
In case you'll keep spiking,
we just make the timer go back down. (Very unstable net must still get kicked).
*/
else
pingtimeout[i] = (pingtimeout[i] == 0 ? 0 : pingtimeout[i]-1);
} }
} }
} }