diff --git a/src/engine/server.h b/src/engine/server.h index 2c9c6c0d2..f3197fecb 100644 --- a/src/engine/server.h +++ b/src/engine/server.h @@ -146,6 +146,7 @@ public: virtual void SetClientClan(int ClientID, char const *pClan) = 0; virtual void SetClientCountry(int ClientID, int Country) = 0; virtual void SetClientScore(int ClientID, int Score) = 0; + virtual void SetClientFlags(int ClientID, int Flags) = 0; virtual int SnapNewID() = 0; virtual void SnapFreeID(int ID) = 0; diff --git a/src/engine/server/server.cpp b/src/engine/server/server.cpp index bf07bbedd..c6c9ecda0 100644 --- a/src/engine/server/server.cpp +++ b/src/engine/server/server.cpp @@ -256,6 +256,7 @@ void CServer::CClient::Reset() m_SnapRate = CClient::SNAPRATE_INIT; m_Score = 0; m_NextMapChunk = 0; + m_Flags = 0; } CServer::CServer() @@ -407,6 +408,15 @@ void CServer::SetClientScore(int ClientID, int Score) m_aClients[ClientID].m_Score = Score; } +void CServer::SetClientFlags(int ClientID, int Flags) +{ + if(ClientID < 0 || ClientID >= MAX_CLIENTS || m_aClients[ClientID].m_State < CClient::STATE_READY) + return; + + if(Flags > m_aClients[ClientID].m_Flags) + m_aClients[ClientID].m_Flags = Flags; +} + void CServer::Kick(int ClientID, const char *pReason) { if(ClientID < 0 || ClientID >= MAX_CLIENTS || m_aClients[ClientID].m_State == CClient::STATE_EMPTY) @@ -2119,61 +2129,54 @@ void CServer::ConKick(IConsole::IResult *pResult, void *pUser) ((CServer *)pUser)->Kick(pResult->GetInteger(0), "Kicked by console"); } -void CServer::StatusImpl(IConsole::IResult *pResult, void *pUser, bool DnsblBlacklistedOnly) +void CServer::ConStatus(IConsole::IResult *pResult, void *pUser) { char aBuf[1024]; char aAddrStr[NETADDR_MAXSTRSIZE]; CServer *pThis = static_cast(pUser); - bool CanSeeAddress = pThis->m_aClients[pResult->m_ClientID].m_Authed > AUTHED_MOD; - for(int i = 0; i < MAX_CLIENTS; i++) { - if( - pThis->m_aClients[i].m_State != CClient::STATE_EMPTY - && (!DnsblBlacklistedOnly || pThis->m_aClients[i].m_DnsblState == CClient::DNSBL_STATE_BLACKLISTED) - ) + if(pThis->m_aClients[i].m_State == CClient::STATE_EMPTY) + continue; + + net_addr_str(pThis->m_NetServer.ClientAddr(i), aAddrStr, sizeof(aAddrStr), true); + if(pThis->m_aClients[i].m_State == CClient::STATE_INGAME) { - net_addr_str(pThis->m_NetServer.ClientAddr(i), aAddrStr, sizeof(aAddrStr), true); - if(pThis->m_aClients[i].m_State == CClient::STATE_INGAME) + char aDnsblStr[64]; + aDnsblStr[0] = '\0'; + if(g_Config.m_SvDnsbl) + { + const char *pDnsblStr = pThis->m_aClients[i].m_DnsblState == CClient::DNSBL_STATE_WHITELISTED ? "white" : + pThis->m_aClients[i].m_DnsblState == CClient::DNSBL_STATE_BLACKLISTED ? "black" : + pThis->m_aClients[i].m_DnsblState == CClient::DNSBL_STATE_PENDING ? "pending" : "n/a"; + + str_format(aDnsblStr, sizeof(aDnsblStr), " dnsbl=%s", pDnsblStr); + } + + char aAuthStr[128]; + aAuthStr[0] = '\0'; + if(pThis->m_aClients[i].m_AuthKey >= 0) { const char *pAuthStr = pThis->m_aClients[i].m_Authed == AUTHED_ADMIN ? "(Admin)" : pThis->m_aClients[i].m_Authed == AUTHED_MOD ? "(Mod)" : pThis->m_aClients[i].m_Authed == AUTHED_HELPER ? "(Helper)" : ""; - char aAuthStr[128]; - aAuthStr[0] = '\0'; - if(pThis->m_aClients[i].m_AuthKey >= 0) - str_format(aAuthStr, sizeof(aAuthStr), "key=%s %s", pThis->m_AuthManager.KeyIdent(pThis->m_aClients[i].m_AuthKey), pAuthStr); - if(CanSeeAddress) - str_format(aBuf, sizeof(aBuf), "id=%d addr=%s name='%s' score=%d client=%d secure=%s %s", i, aAddrStr, - pThis->m_aClients[i].m_aName, pThis->m_aClients[i].m_Score, pThis->GameServer()->GetClientVersion(i), pThis->m_NetServer.HasSecurityToken(i) ? "yes" : "no", aAuthStr); - else - str_format(aBuf, sizeof(aBuf), "id=%d name='%s' score=%d client=%d secure=%s %s", i, - pThis->m_aClients[i].m_aName, pThis->m_aClients[i].m_Score, pThis->GameServer()->GetClientVersion(i), pThis->m_NetServer.HasSecurityToken(i) ? "yes" : "no", aAuthStr); + str_format(aAuthStr, sizeof(aAuthStr), " key=%s %s", pThis->m_AuthManager.KeyIdent(pThis->m_aClients[i].m_AuthKey), pAuthStr); } - else - { - if(CanSeeAddress) - str_format(aBuf, sizeof(aBuf), "id=%d addr=%s connecting", i, aAddrStr); - else - str_format(aBuf, sizeof(aBuf), "id=%d connecting", i); - } - pThis->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "Server", aBuf); + + str_format(aBuf, sizeof(aBuf), "id=%d addr='%s' name='%s' client=%d secure=%s flags=%d%s%s", + i, aAddrStr, pThis->m_aClients[i].m_aName, pThis->GameServer()->GetClientVersion(i), + pThis->m_NetServer.HasSecurityToken(i) ? "yes" : "no", pThis->m_aClients[i].m_Flags, aDnsblStr, aAuthStr); } + else + { + str_format(aBuf, sizeof(aBuf), "id=%d addr=%s connecting", i, aAddrStr); + } + pThis->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "Server", aBuf); } } -void CServer::ConStatus(IConsole::IResult *pResult, void *pUser) -{ - StatusImpl(pResult, pUser, false); -} - -void CServer::ConDnsblStatus(IConsole::IResult *pResult, void *pUser) -{ - StatusImpl(pResult, pUser, true); -} - static int GetAuthLevel(const char *pLevel) { int Level = -1; @@ -2821,8 +2824,6 @@ void CServer::RegisterCommands() Console()->Register("dump_sqlservers", "s['r'|'w']", CFGFLAG_SERVER, ConDumpSqlServers, this, "dumps all sqlservers readservers = r, writeservers = w"); #endif - Console()->Register("dnsbl_status", "", CFGFLAG_SERVER, ConDnsblStatus, this, "List blacklisted players"); - Console()->Register("auth_add", "s[ident] s[level] s[pw]", CFGFLAG_SERVER|CFGFLAG_NONTEEHISTORIC, ConAuthAdd, this, "Add a rcon key"); Console()->Register("auth_add_p", "s[ident] s[level] s[hash] s[salt]", CFGFLAG_SERVER|CFGFLAG_NONTEEHISTORIC, ConAuthAddHashed, this, "Add a prehashed rcon key"); Console()->Register("auth_change", "s[ident] s[level] s[pw]", CFGFLAG_SERVER|CFGFLAG_NONTEEHISTORIC, ConAuthUpdate, this, "Update a rcon key"); diff --git a/src/engine/server/server.h b/src/engine/server/server.h index 4573d4800..6838fe66b 100644 --- a/src/engine/server/server.h +++ b/src/engine/server/server.h @@ -167,6 +167,7 @@ public: int m_AuthKey; int m_AuthTries; int m_NextMapChunk; + int m_Flags; const IConsole::CCommandInfo *m_pRconCmdToSend; @@ -236,6 +237,7 @@ public: virtual void SetClientClan(int ClientID, char const *pClan); virtual void SetClientCountry(int ClientID, int Country); virtual void SetClientScore(int ClientID, int Score); + virtual void SetClientFlags(int ClientID, int Flags); void Kick(int ClientID, const char *pReason); void Ban(int ClientID, int Seconds, const char *pReason); @@ -314,7 +316,6 @@ public: static void ConStopRecord(IConsole::IResult *pResult, void *pUser); static void ConMapReload(IConsole::IResult *pResult, void *pUser); static void ConLogout(IConsole::IResult *pResult, void *pUser); - static void ConDnsblStatus(IConsole::IResult *pResult, void *pUser); static void ConAuthAdd(IConsole::IResult *pResult, void *pUser); static void ConAuthAddHashed(IConsole::IResult *pResult, void *pUser); @@ -327,8 +328,6 @@ public: static void ConNameUnban(IConsole::IResult *pResult, void *pUser); static void ConNameBans(IConsole::IResult *pResult, void *pUser); - static void StatusImpl(IConsole::IResult *pResult, void *pUser, bool DnsblBlacklistedOnly); - #if defined (CONF_SQL) // console commands for sqlmasters static void ConAddSqlServer(IConsole::IResult *pResult, void *pUserData); diff --git a/src/game/server/player.cpp b/src/game/server/player.cpp index 0aa8ce961..b498b277c 100644 --- a/src/game/server/player.cpp +++ b/src/game/server/player.cpp @@ -429,7 +429,10 @@ void CPlayer::OnPredictedInput(CNetObj_PlayerInput *NewInput) void CPlayer::OnDirectInput(CNetObj_PlayerInput *NewInput) { - if (AfkTimer(NewInput->m_TargetX, NewInput->m_TargetY)) + if(NewInput->m_PlayerFlags) + Server()->SetClientFlags(m_ClientID, NewInput->m_PlayerFlags); + + if(AfkTimer(NewInput->m_TargetX, NewInput->m_TargetY)) return; // we must return if kicked, as player struct is already deleted AfkVoteTimer(NewInput);