mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 01:58:19 +00:00
Merge #3680
3680: Fix legacy serverinfo with reserved slots and num_players > 15 (fixes #3678) r=heinrich5991 a=def- <!-- What is the motivation for the changes of this pull request --> ## Checklist - [ ] Tested the change ingame - [ ] Provided screenshots if it is a visual change - [ ] Tested in combination with possibly related configuration options - [ ] Written a unit test if it works standalone, system.c especially - [ ] Considered possible null pointers and out of bounds array indexing - [ ] Changed no physics that affect existing maps - [ ] Tested the change with [ASan+UBSan or valgrind's memcheck](https://github.com/ddnet/ddnet/#using-addresssanitizer--undefinedbehavioursanitizer-or-valgrinds-memcheck) (optional) Co-authored-by: def <dennis@felsin9.de>
This commit is contained in:
commit
75e9b20e45
|
@ -1855,6 +1855,9 @@ void CServer::CacheServerInfo(CCache *pCache, int Type, bool SendClients)
|
|||
ADD_INT(p, g_Config.m_Password[0] ? SERVER_FLAG_PASSWORD : 0);
|
||||
|
||||
int MaxClients = m_NetServer.MaxClients();
|
||||
// How many clients the used serverinfo protocol supports, has to be tracked
|
||||
// separately to make sure we don't subtract the reserved slots from it
|
||||
int MaxClientsProtocol = MAX_CLIENTS;
|
||||
if(Type == SERVERINFO_VANILLA || Type == SERVERINFO_INGAME)
|
||||
{
|
||||
if(ClientCount >= VANILLA_MAX_CLIENTS)
|
||||
|
@ -1864,16 +1867,15 @@ void CServer::CacheServerInfo(CCache *pCache, int Type, bool SendClients)
|
|||
else
|
||||
ClientCount = VANILLA_MAX_CLIENTS;
|
||||
}
|
||||
if(MaxClients > VANILLA_MAX_CLIENTS)
|
||||
MaxClients = VANILLA_MAX_CLIENTS;
|
||||
MaxClientsProtocol = VANILLA_MAX_CLIENTS;
|
||||
if(PlayerCount > ClientCount)
|
||||
PlayerCount = ClientCount;
|
||||
}
|
||||
|
||||
ADD_INT(p, PlayerCount); // num players
|
||||
ADD_INT(p, maximum(MaxClients - maximum(g_Config.m_SvSpectatorSlots, g_Config.m_SvReservedSlots), PlayerCount)); // max players
|
||||
ADD_INT(p, minimum(MaxClientsProtocol, maximum(MaxClients - maximum(g_Config.m_SvSpectatorSlots, g_Config.m_SvReservedSlots), PlayerCount))); // max players
|
||||
ADD_INT(p, ClientCount); // num clients
|
||||
ADD_INT(p, maximum(MaxClients - g_Config.m_SvReservedSlots, ClientCount)); // max clients
|
||||
ADD_INT(p, minimum(MaxClientsProtocol, maximum(MaxClients - g_Config.m_SvReservedSlots, ClientCount))); // max clients
|
||||
|
||||
if(Type == SERVERINFO_EXTENDED)
|
||||
p.AddString("", 0); // extra info, reserved
|
||||
|
|
Loading…
Reference in a new issue