Do proper checks if Client Instance is valid

This commit is contained in:
PixieCore 2022-07-07 20:35:49 +02:00
parent ac55e6c142
commit 0463647268
2 changed files with 26 additions and 27 deletions

View File

@ -170,18 +170,16 @@ void CBanSystem::BanListCheck(void)
{
for (int c = 0; c < MAX_PLAYERS; c++) // Loop through all possible client instances.
{
CClient* pClient = g_pClient->GetClient(c);
CNetChan* pNetChan = pClient->GetNetChan();
if (!pClient || !pNetChan)
{
CClient* pClient = g_pClient->GetClient(i);
if (!pClient)
continue;
CNetChan* pNetChan = pClient->GetNetChan();
if (!pNetChan)
continue;
}
if (pClient->GetOriginID() != m_vRefuseList[i].second)
{
continue;
}
string svIpAddress = pNetChan->GetAddress();

View File

@ -80,11 +80,12 @@ void Host_Kick_f(const CCommand& args)
for (int i = 0; i < MAX_PLAYERS; i++)
{
CClient* pClient = g_pClient->GetClient(i);
CNetChan* pNetChan = pClient->GetNetChan();
if (!pClient || !pNetChan)
{
if (!pClient)
continue;
CNetChan* pNetChan = pClient->GetNetChan();
if (!pNetChan)
continue;
}
string svClientName = pNetChan->GetName(); // Get full name.
@ -120,12 +121,12 @@ void Host_KickID_f(const CCommand& args)
for (int i = 0; i < MAX_PLAYERS; i++)
{
CClient* pClient = g_pClient->GetClient(i);
CNetChan* pNetChan = pClient->GetNetChan();
if (!pClient || !pNetChan)
{
if (!pClient)
continue;
CNetChan* pNetChan = pClient->GetNetChan();
if (!pNetChan)
continue;
}
string svIpAddress = pNetChan->GetAddress(); // If this stays null they modified the packet somehow.
@ -184,12 +185,12 @@ void Host_Ban_f(const CCommand& args)
for (int i = 0; i < MAX_PLAYERS; i++)
{
CClient* pClient = g_pClient->GetClient(i);
CNetChan* pNetChan = pClient->GetNetChan();
if (!pClient || !pNetChan)
{
if (!pClient)
continue;
CNetChan* pNetChan = pClient->GetNetChan();
if (!pNetChan)
continue;
}
string svClientName = pNetChan->GetName(); // Get full name.
@ -229,12 +230,12 @@ void Host_BanID_f(const CCommand& args)
for (int i = 0; i < MAX_PLAYERS; i++)
{
CClient* pClient = g_pClient->GetClient(i);
CNetChan* pNetChan = pClient->GetNetChan();
if (!pClient || !pNetChan)
{
if (!pClient)
continue;
CNetChan* pNetChan = pClient->GetNetChan();
if (!pNetChan)
continue;
}
string svIpAddress = pNetChan->GetAddress(); // If this stays empty they modified the packet somehow.