mirror of
https://github.com/Mauler125/r5sdk.git
synced 2025-02-09 19:15:03 +01:00
Server: remove exraneous client pointer check
CServer::GetClient() will never return NULL as it returns address of client in array. Removed extraneous checks as its misleading, and added const where possible.
This commit is contained in:
parent
5ed734a4ff
commit
a809b1f262
@ -47,9 +47,7 @@ int CServer::GetNumHumanPlayers(void) const
|
||||
int nHumans = 0;
|
||||
for (int i = 0; i < gpGlobals->maxClients; i++)
|
||||
{
|
||||
CClient* pClient = g_pServer->GetClient(i);
|
||||
if (!pClient)
|
||||
continue;
|
||||
const CClient* const pClient = g_pServer->GetClient(i);
|
||||
|
||||
if (pClient->IsHumanPlayer())
|
||||
nHumans++;
|
||||
@ -67,9 +65,7 @@ int CServer::GetNumFakeClients(void) const
|
||||
int nBots = 0;
|
||||
for (int i = 0; i < gpGlobals->maxClients; i++)
|
||||
{
|
||||
CClient* pClient = g_pServer->GetClient(i);
|
||||
if (!pClient)
|
||||
continue;
|
||||
const CClient* const pClient = g_pServer->GetClient(i);
|
||||
|
||||
if (pClient->IsConnected() && pClient->IsFakeClient())
|
||||
nBots++;
|
||||
@ -87,9 +83,7 @@ int CServer::GetNumClients(void) const
|
||||
int nClients = 0;
|
||||
for (int i = 0; i < gpGlobals->maxClients; i++)
|
||||
{
|
||||
CClient* pClient = g_pServer->GetClient(i);
|
||||
if (!pClient)
|
||||
continue;
|
||||
const CClient* const pClient = g_pServer->GetClient(i);
|
||||
|
||||
if (pClient->IsConnected())
|
||||
nClients++;
|
||||
|
@ -79,10 +79,6 @@ void SV_CheckClientsForBan(const CBanSystem::BannedList_t* const pBannedVec /*=
|
||||
for (int c = 0; c < gpGlobals->maxClients; c++) // Loop through all possible client instances.
|
||||
{
|
||||
CClient* const pClient = g_pServer->GetClient(c);
|
||||
|
||||
if (!pClient)
|
||||
continue;
|
||||
|
||||
const CNetChan* const pNetChan = pClient->GetNetChan();
|
||||
|
||||
if (!pNetChan)
|
||||
@ -199,9 +195,6 @@ void SV_BroadcastVoiceData(CClient* const cl, const int nBytes, char* const data
|
||||
{
|
||||
CClient* const pClient = g_pServer->GetClient(i);
|
||||
|
||||
if (!pClient)
|
||||
continue;
|
||||
|
||||
// is this client fully connected
|
||||
if (pClient->GetSignonState() != SIGNONSTATE::SIGNONSTATE_FULL)
|
||||
continue;
|
||||
@ -246,9 +239,6 @@ void SV_BroadcastDurangoVoiceData(CClient* const cl, const int nBytes, char* con
|
||||
{
|
||||
CClient* const pClient = g_pServer->GetClient(i);
|
||||
|
||||
if (!pClient)
|
||||
continue;
|
||||
|
||||
// is this client fully connected
|
||||
if (pClient->GetSignonState() != SIGNONSTATE::SIGNONSTATE_FULL)
|
||||
continue;
|
||||
|
@ -168,13 +168,13 @@ void CServerGameClients::_ProcessUserCmds(CServerGameClients* thisp, edict_t edi
|
||||
Assert(numCmds >= 0);
|
||||
Assert((totalCmds - numCmds) >= 0);
|
||||
|
||||
CPlayer* pPlayer = UTIL_PlayerByIndex(edict);
|
||||
CPlayer* const pPlayer = UTIL_PlayerByIndex(edict);
|
||||
|
||||
// Too many commands?
|
||||
if (totalCmds < 0 || totalCmds >= (MAX_BACKUP_COMMANDS_PROCESS - 1) ||
|
||||
numCmds < 0 || numCmds > totalCmds)
|
||||
{
|
||||
CClient* pClient = g_pServer->GetClient(edict-1);
|
||||
const CClient* const pClient = g_pServer->GetClient(edict-1);
|
||||
|
||||
Warning(eDLL_T::SERVER, "%s: Player '%s' sent too many cmds (%i)\n", __FUNCTION__, pClient->GetServerName(), totalCmds);
|
||||
buf->SetOverflowFlag();
|
||||
|
@ -24,13 +24,11 @@ void Physics_RunBotSimulation(bool bSimulating)
|
||||
|
||||
for (int i = 0; i < g_ServerGlobalVariables->maxClients; i++)
|
||||
{
|
||||
CClient* pClient = g_pServer->GetClient(i);
|
||||
if (!pClient)
|
||||
continue;
|
||||
const CClient* const pClient = g_pServer->GetClient(i);
|
||||
|
||||
if (pClient->IsActive() && pClient->IsFakeClient())
|
||||
{
|
||||
CPlayer* pPlayer = UTIL_PlayerByIndex(pClient->GetHandle());
|
||||
CPlayer* const pPlayer = UTIL_PlayerByIndex(pClient->GetHandle());
|
||||
if (pPlayer)
|
||||
pPlayer->RunNullCommand();
|
||||
}
|
||||
|
@ -314,11 +314,9 @@ void CBanSystem::AuthorPlayerByName(const char* playerName, const bool shouldBan
|
||||
|
||||
for (int i = 0; i < gpGlobals->maxClients; i++)
|
||||
{
|
||||
CClient* pClient = g_pServer->GetClient(i);
|
||||
if (!pClient)
|
||||
continue;
|
||||
CClient* const pClient = g_pServer->GetClient(i);
|
||||
const CNetChan* const pNetChan = pClient->GetNetChan();
|
||||
|
||||
const CNetChan* pNetChan = pClient->GetNetChan();
|
||||
if (!pNetChan)
|
||||
continue;
|
||||
|
||||
@ -365,11 +363,9 @@ void CBanSystem::AuthorPlayerById(const char* playerHandle, const bool shouldBan
|
||||
|
||||
for (int i = 0; i < gpGlobals->maxClients; i++)
|
||||
{
|
||||
CClient* pClient = g_pServer->GetClient(i);
|
||||
if (!pClient)
|
||||
continue;
|
||||
CClient* const pClient = g_pServer->GetClient(i);
|
||||
const CNetChan* const pNetChan = pClient->GetNetChan();
|
||||
|
||||
const CNetChan* pNetChan = pClient->GetNetChan();
|
||||
if (!pNetChan)
|
||||
continue;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user