Skip to content

Commit 5ff37ba

Browse files
committed
Add sv_hide_info option
1 parent 686aa96 commit 5ff37ba

File tree

2 files changed

+37
-2
lines changed

2 files changed

+37
-2
lines changed

src/engine/server/server.cpp

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1631,7 +1631,32 @@ void CServer::SendServerInfo(const NETADDR *pAddr, int Token, bool Extended, boo
16311631
memcpy(aBuf, g_Config.m_SvName, sizeof(aBuf));
16321632
#endif
16331633
}
1634-
1634+
1635+
const char *pMapName = GetMapName();
1636+
if(g_Config.m_SvHideInfo)
1637+
{
1638+
if(g_Config.m_SvHideInfo == 2)
1639+
{
1640+
// Full hide
1641+
PlayerCount = 0;
1642+
ClientCount = 0;
1643+
SendClients = false;
1644+
pMapName = "";
1645+
}
1646+
else
1647+
{
1648+
// Limit players
1649+
static const int SoftLimit = 8;
1650+
static const int HardLimit = 12;
1651+
if(PlayerCount > SoftLimit)
1652+
{
1653+
PlayerCount = SoftLimit + (PlayerCount - SoftLimit) / 3;
1654+
}
1655+
PlayerCount = minimum(PlayerCount, HardLimit);
1656+
ClientCount = minimum(ClientCount, PlayerCount);
1657+
}
1658+
}
1659+
16351660
if (Extended)
16361661
{
16371662
p.AddString(aBuf, 256);
@@ -1647,7 +1672,8 @@ void CServer::SendServerInfo(const NETADDR *pAddr, int Token, bool Extended, boo
16471672
p.AddString(bBuf, 64);
16481673
}
16491674
}
1650-
p.AddString(GetMapName(), 32);
1675+
1676+
p.AddString(pMapName, 32);
16511677

16521678
// gametype
16531679
p.AddString(GameServer()->GameType(), 16);
@@ -1692,6 +1718,14 @@ void CServer::SendServerInfo(const NETADDR *pAddr, int Token, bool Extended, boo
16921718
{
16931719
if(m_aClients[i].m_State != CClient::STATE_EMPTY)
16941720
{
1721+
if(g_Config.m_SvHideInfo)
1722+
{
1723+
if(PlayerCount == 0)
1724+
break;
1725+
1726+
--PlayerCount;
1727+
}
1728+
16951729
if (Skip-- > 0)
16961730
continue;
16971731
if (--Take < 0)

src/engine/shared/config_variables.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ MACRO_CONFIG_INT(SvRconTokenCheck, sv_rcon_token_check, 1, 0, 1, CFGFLAG_SERVER,
2929
MACRO_CONFIG_INT(SvAutoDemoRecord, sv_auto_demo_record, 0, 0, 1, CFGFLAG_SERVER, "Automatically record demos")
3030
MACRO_CONFIG_INT(SvAutoDemoMax, sv_auto_demo_max, 10, 0, 1000, CFGFLAG_SERVER, "Maximum number of automatically recorded demos (0 = no limit)")
3131
MACRO_CONFIG_INT(SvServerInfoPerSecond, sv_server_info_per_second, 10, 1, 1000, CFGFLAG_SERVER, "Maximum number of complete server info responses that are sent out per second")
32+
MACRO_CONFIG_INT(SvHideInfo, sv_hide_info, 0, 0, 2, CFGFLAG_SERVER, "Hide the server info (0=no hide, 1=limit players, 2=full hide)")
3233

3334
MACRO_CONFIG_STR(EcBindaddr, ec_bindaddr, 128, "localhost", CFGFLAG_ECON, "Address to bind the external console to. Anything but 'localhost' is dangerous")
3435
MACRO_CONFIG_INT(EcPort, ec_port, 0, 0, 0, CFGFLAG_ECON, "Port to use for the external console")

0 commit comments

Comments
 (0)