Skip to content

Commit

Permalink
Add sv_hide_info option
Browse files Browse the repository at this point in the history
  • Loading branch information
Kaffeine committed Mar 19, 2021
1 parent 686aa96 commit 5ff37ba
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 2 deletions.
38 changes: 36 additions & 2 deletions src/engine/server/server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1631,7 +1631,32 @@ void CServer::SendServerInfo(const NETADDR *pAddr, int Token, bool Extended, boo
memcpy(aBuf, g_Config.m_SvName, sizeof(aBuf));
#endif
}


const char *pMapName = GetMapName();
if(g_Config.m_SvHideInfo)
{
if(g_Config.m_SvHideInfo == 2)
{
// Full hide
PlayerCount = 0;
ClientCount = 0;
SendClients = false;
pMapName = "";
}
else
{
// Limit players
static const int SoftLimit = 8;
static const int HardLimit = 12;
if(PlayerCount > SoftLimit)
{
PlayerCount = SoftLimit + (PlayerCount - SoftLimit) / 3;
}
PlayerCount = minimum(PlayerCount, HardLimit);
ClientCount = minimum(ClientCount, PlayerCount);
}
}

if (Extended)
{
p.AddString(aBuf, 256);
Expand All @@ -1647,7 +1672,8 @@ void CServer::SendServerInfo(const NETADDR *pAddr, int Token, bool Extended, boo
p.AddString(bBuf, 64);
}
}
p.AddString(GetMapName(), 32);

p.AddString(pMapName, 32);

// gametype
p.AddString(GameServer()->GameType(), 16);
Expand Down Expand Up @@ -1692,6 +1718,14 @@ void CServer::SendServerInfo(const NETADDR *pAddr, int Token, bool Extended, boo
{
if(m_aClients[i].m_State != CClient::STATE_EMPTY)
{
if(g_Config.m_SvHideInfo)
{
if(PlayerCount == 0)
break;

--PlayerCount;
}

if (Skip-- > 0)
continue;
if (--Take < 0)
Expand Down
1 change: 1 addition & 0 deletions src/engine/shared/config_variables.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ MACRO_CONFIG_INT(SvRconTokenCheck, sv_rcon_token_check, 1, 0, 1, CFGFLAG_SERVER,
MACRO_CONFIG_INT(SvAutoDemoRecord, sv_auto_demo_record, 0, 0, 1, CFGFLAG_SERVER, "Automatically record demos")
MACRO_CONFIG_INT(SvAutoDemoMax, sv_auto_demo_max, 10, 0, 1000, CFGFLAG_SERVER, "Maximum number of automatically recorded demos (0 = no limit)")
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")
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)")

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

0 comments on commit 5ff37ba

Please sign in to comment.