Merge branch 'fix-leftover-players-idle' into 'next'

Do not send disconnected players' statuses to the MS

See merge request STJr/SRB2!2209
This commit is contained in:
Logan Aerl Arias 2023-12-26 00:02:48 +00:00
commit cbd6e397e3
3 changed files with 14 additions and 2 deletions

View file

@ -1623,6 +1623,17 @@ INT32 D_NumPlayers(void)
return num;
}
/** Returns the number of nodes on the server.
*/
INT32 D_NumNodes(void)
{
INT32 num = 0;
for (INT32 ix = 0; ix < MAXNETNODES; ix++)
if (netnodes[ix].ingame)
num++;
return num;
}
/** Similar to the above, but counts only bots.
* Purpose is to remove bots from both the player count and the
* max player count on the server view

View file

@ -121,6 +121,7 @@ extern char motd[254], server_context[8];
extern UINT8 playernode[MAXPLAYERS];
INT32 D_NumPlayers(void);
INT32 D_NumNodes(void);
INT32 D_NumBots(void);
tic_t GetLag(INT32 node);

View file

@ -109,7 +109,7 @@ static void SV_SendServerInfo(INT32 node, tic_t servertime)
netbuffer->u.serverinfo.leveltime = (tic_t)LONG(leveltime);
// Exclude bots from both counts
netbuffer->u.serverinfo.numberofplayer = (UINT8)(D_NumPlayers() - D_NumBots());
netbuffer->u.serverinfo.numberofplayer = (UINT8)D_NumNodes();
netbuffer->u.serverinfo.maxplayer = (UINT8)(cv_maxplayers.value - D_NumBots());
netbuffer->u.serverinfo.refusereason = GetRefuseReason(node);
@ -164,7 +164,7 @@ static void SV_SendPlayerInfo(INT32 node)
for (UINT8 i = 0; i < MAXPLAYERS; i++)
{
if (!playeringame[i])
if (playernode[i] == UINT8_MAX || !netnodes[playernode[i]].ingame)
{
netbuffer->u.playerinfo[i].num = 255; // This slot is empty.
continue;