mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-18 14:08:19 +00:00
Ensure debug dummies are not included in server info
Also fix normal clients being disconnected/controlled like debug dummies. Closes #7523.
This commit is contained in:
parent
f95b0f163f
commit
48bfecc0d3
|
@ -573,6 +573,7 @@ int CServer::Init()
|
|||
Client.m_Traffic = 0;
|
||||
Client.m_TrafficSince = 0;
|
||||
Client.m_ShowIps = false;
|
||||
Client.m_DebugDummy = false;
|
||||
Client.m_AuthKey = -1;
|
||||
Client.m_Latency = 0;
|
||||
Client.m_Sixup = false;
|
||||
|
@ -1083,6 +1084,7 @@ int CServer::NewClientNoAuthCallback(int ClientID, void *pUser)
|
|||
pThis->m_aClients[ClientID].m_AuthTries = 0;
|
||||
pThis->m_aClients[ClientID].m_pRconCmdToSend = 0;
|
||||
pThis->m_aClients[ClientID].m_ShowIps = false;
|
||||
pThis->m_aClients[ClientID].m_DebugDummy = false;
|
||||
pThis->m_aClients[ClientID].m_DDNetVersion = VERSION_NONE;
|
||||
pThis->m_aClients[ClientID].m_GotDDNetVersionPacket = false;
|
||||
pThis->m_aClients[ClientID].m_DDNetVersionSettled = false;
|
||||
|
@ -1114,6 +1116,7 @@ int CServer::NewClientCallback(int ClientID, void *pUser, bool Sixup)
|
|||
pThis->m_aClients[ClientID].m_Traffic = 0;
|
||||
pThis->m_aClients[ClientID].m_TrafficSince = 0;
|
||||
pThis->m_aClients[ClientID].m_ShowIps = false;
|
||||
pThis->m_aClients[ClientID].m_DebugDummy = false;
|
||||
pThis->m_aClients[ClientID].m_DDNetVersion = VERSION_NONE;
|
||||
pThis->m_aClients[ClientID].m_GotDDNetVersionPacket = false;
|
||||
pThis->m_aClients[ClientID].m_DDNetVersionSettled = false;
|
||||
|
@ -1200,6 +1203,7 @@ int CServer::DelClientCallback(int ClientID, const char *pReason, void *pUser)
|
|||
pThis->m_aClients[ClientID].m_Traffic = 0;
|
||||
pThis->m_aClients[ClientID].m_TrafficSince = 0;
|
||||
pThis->m_aClients[ClientID].m_ShowIps = false;
|
||||
pThis->m_aClients[ClientID].m_DebugDummy = false;
|
||||
pThis->m_aPrevStates[ClientID] = CClient::STATE_EMPTY;
|
||||
pThis->m_aClients[ClientID].m_Snapshots.PurgeAll();
|
||||
pThis->m_aClients[ClientID].m_Sixup = false;
|
||||
|
@ -1933,7 +1937,7 @@ void CServer::CacheServerInfo(CCache *pCache, int Type, bool SendClients)
|
|||
int PlayerCount = 0, ClientCount = 0;
|
||||
for(int i = 0; i < MAX_CLIENTS; i++)
|
||||
{
|
||||
if(m_aClients[i].m_State != CClient::STATE_EMPTY)
|
||||
if(m_aClients[i].IncludedInServerInfo())
|
||||
{
|
||||
if(GameServer()->IsClientPlayer(i))
|
||||
PlayerCount++;
|
||||
|
@ -2065,7 +2069,7 @@ void CServer::CacheServerInfo(CCache *pCache, int Type, bool SendClients)
|
|||
|
||||
for(int i = 0; i < MAX_CLIENTS; i++)
|
||||
{
|
||||
if(m_aClients[i].m_State != CClient::STATE_EMPTY)
|
||||
if(m_aClients[i].IncludedInServerInfo())
|
||||
{
|
||||
if(Remaining == 0)
|
||||
{
|
||||
|
@ -2147,7 +2151,7 @@ void CServer::CacheServerInfoSixup(CCache *pCache, bool SendClients)
|
|||
int PlayerCount = 0, ClientCount = 0;
|
||||
for(int i = 0; i < MAX_CLIENTS; i++)
|
||||
{
|
||||
if(m_aClients[i].m_State != CClient::STATE_EMPTY)
|
||||
if(m_aClients[i].IncludedInServerInfo())
|
||||
{
|
||||
if(GameServer()->IsClientPlayer(i))
|
||||
PlayerCount++;
|
||||
|
@ -2183,7 +2187,7 @@ void CServer::CacheServerInfoSixup(CCache *pCache, bool SendClients)
|
|||
{
|
||||
for(int i = 0; i < MAX_CLIENTS; i++)
|
||||
{
|
||||
if(m_aClients[i].m_State != CClient::STATE_EMPTY)
|
||||
if(m_aClients[i].IncludedInServerInfo())
|
||||
{
|
||||
Packer.AddString(ClientName(i), MAX_NAME_LENGTH); // client name
|
||||
Packer.AddString(ClientClan(i), MAX_CLAN_LENGTH); // client clan
|
||||
|
@ -2286,7 +2290,7 @@ void CServer::UpdateRegisterServerInfo()
|
|||
int PlayerCount = 0, ClientCount = 0;
|
||||
for(int i = 0; i < MAX_CLIENTS; i++)
|
||||
{
|
||||
if(m_aClients[i].m_State != CClient::STATE_EMPTY)
|
||||
if(m_aClients[i].IncludedInServerInfo())
|
||||
{
|
||||
if(GameServer()->IsClientPlayer(i))
|
||||
PlayerCount++;
|
||||
|
@ -2334,7 +2338,7 @@ void CServer::UpdateRegisterServerInfo()
|
|||
bool FirstPlayer = true;
|
||||
for(int i = 0; i < MAX_CLIENTS; i++)
|
||||
{
|
||||
if(m_aClients[i].m_State != CClient::STATE_EMPTY)
|
||||
if(m_aClients[i].IncludedInServerInfo())
|
||||
{
|
||||
char aCName[32];
|
||||
char aCClan[32];
|
||||
|
@ -2628,17 +2632,18 @@ void CServer::UpdateDebugDummies(bool ForceDisconnect)
|
|||
if(AddDummy && m_aClients[ClientID].m_State == CClient::STATE_EMPTY)
|
||||
{
|
||||
NewClientCallback(ClientID, this, false);
|
||||
m_aClients[ClientID].m_DebugDummy = true;
|
||||
GameServer()->OnClientConnected(ClientID, nullptr);
|
||||
m_aClients[ClientID].m_State = CClient::STATE_INGAME;
|
||||
str_format(m_aClients[ClientID].m_aName, sizeof(m_aClients[ClientID].m_aName), "Debug dummy %d", DummyIndex + 1);
|
||||
GameServer()->OnClientEnter(ClientID);
|
||||
}
|
||||
else if(!AddDummy && m_aClients[ClientID].m_State == CClient::STATE_INGAME)
|
||||
else if(!AddDummy && m_aClients[ClientID].m_DebugDummy)
|
||||
{
|
||||
DelClientCallback(ClientID, "Dropping debug dummy", this);
|
||||
}
|
||||
|
||||
if(AddDummy && m_aClients[ClientID].m_State == CClient::STATE_INGAME)
|
||||
if(AddDummy && m_aClients[ClientID].m_DebugDummy)
|
||||
{
|
||||
CNetObj_PlayerInput Input = {0};
|
||||
Input.m_Direction = (ClientID & 1) ? -1 : 1;
|
||||
|
|
|
@ -197,6 +197,7 @@ public:
|
|||
int m_NextMapChunk;
|
||||
int m_Flags;
|
||||
bool m_ShowIps;
|
||||
bool m_DebugDummy;
|
||||
|
||||
const IConsole::CCommandInfo *m_pRconCmdToSend;
|
||||
|
||||
|
@ -220,6 +221,11 @@ public:
|
|||
std::shared_ptr<CHostLookup> m_pDnsblLookup;
|
||||
|
||||
bool m_Sixup;
|
||||
|
||||
bool IncludedInServerInfo() const
|
||||
{
|
||||
return m_State != STATE_EMPTY && !m_DebugDummy;
|
||||
}
|
||||
};
|
||||
|
||||
CClient m_aClients[MAX_CLIENTS];
|
||||
|
|
Loading…
Reference in a new issue