did not actually change that much, maybe it just shows more than actual is changed due to tabs/spaces

This commit is contained in:
jenz 2024-05-01 11:21:54 +02:00
parent aaec53ec79
commit 5ecfc920c4

View File

@ -332,194 +332,140 @@ public void OnClientDisconnect(int client)
//---------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------
public void CheckPopulation() public void CheckPopulation()
{ {
g_bCheckRequested = false; g_bCheckRequested = false;
if(g_bMapEnded) if(g_bMapEnded)
return; return;
int iPlayers = GetClientCount(false); int iPlayers = GetClientCount(false);
for(int i = 1; i <= MaxClients; i++) for(int i = 1; i <= MaxClients; i++)
{ {
if(IsClientConnected(i) && IsFakeClient(i)) if(IsClientConnected(i) && IsFakeClient(i))
iPlayers--; iPlayers--;
} }
bool bServerDying; int iFakes = 0;
if(iPlayers < (g_iPopulation - 10)) int iFakesInTeam = 0;
bServerDying = true;
int iFakes = 0; for(int i = 1; i <= MaxClients; i++)
int iFakesInTeam = 0; {
if (g_bFakePopulation[i])
iFakes++;
}
for(int i = 1; i <= MaxClients; i++) int iFakesNeeded = 0;
{ int iFakesInTeamNeeded = 0;
if (g_bFakePopulation[i])
iFakes++; //24 to account for 4 autismbots.
} iFakesNeeded = 24 - RoundToFloor(iPlayers / 1.5);
if (iFakesNeeded < 0)
{
iFakesNeeded = 0;
iFakesInTeamNeeded = 0;
}
else
{
iFakesInTeamNeeded = iFakesNeeded / 3;
}
int iFakesNeeded = 0; if(g_iAdminFakes != -1)
int iFakesInTeamNeeded = 0; iFakesNeeded = g_iAdminFakes;
if(bServerDying) if (iFakes != iFakesNeeded)
{ {
if (iPlayers > 45) while (iFakes < iFakesNeeded && !g_bBlockInstantFakeConnects)
{ {
iFakesNeeded = 6; ArrayList hNames = g_hNames.Clone();
iFakesInTeamNeeded = 2; char sName[MAX_NAME_LENGTH];
} for(int i = 1; i <= MaxClients; i++)
else if (iPlayers > 20) {
{ if(g_bFakePopulation[i])
iFakesNeeded = 7; {
iFakesInTeamNeeded = 3; GetClientName(i, sName, sizeof(sName));
} int iPos = hNames.FindString(sName);
else if (iPlayers > 10) if (iPos > -1)
{ hNames.Erase(iPos);
iFakesNeeded = 6; }
iFakesInTeamNeeded = 2; }
}
else
{
iFakesNeeded = 5;
iFakesInTeamNeeded = 0;
}
}
else
{
if (iPlayers > 61)
{
iFakesNeeded = 0;
iFakesInTeamNeeded = 0;
}
else if(iPlayers > 59)
{
iFakesNeeded = 1;
iFakesInTeamNeeded = 0;
}
else if(iPlayers > 57)
{
iFakesNeeded = 2;
iFakesInTeamNeeded = 1;
}
else if(iPlayers > 55)
{
iFakesNeeded = 3;
iFakesInTeamNeeded = 1;
}
else if (iPlayers > 20)
{
iFakesNeeded = 5;
iFakesInTeamNeeded = 2;
}
else if (iPlayers > 10)
{
iFakesNeeded = 5;
iFakesInTeamNeeded = 1;
}
else
{
iFakesNeeded = 5;
iFakesInTeamNeeded = 0;
}
}
if(g_iAdminFakes != -1) int iRand = GetRandomInt(0, hNames.Length - 1);
iFakesNeeded = g_iAdminFakes; hNames.GetString(iRand, sName, sizeof(sName));
delete hNames;
if (iFakes != iFakesNeeded) int iIndex = CreateFakeClient(sName);
{
while (iFakes < iFakesNeeded && !g_bBlockInstantFakeConnects)
{
ArrayList hNames = g_hNames.Clone();
char sName[MAX_NAME_LENGTH];
for(int i = 1; i <= MaxClients; i++)
{
if(g_bFakePopulation[i])
{
GetClientName(i, sName, sizeof(sName));
int iPos = hNames.FindString(sName);
if (iPos > -1)
hNames.Erase(iPos);
}
}
int iRand = GetRandomInt(0, hNames.Length - 1); if(iIndex < 1 || iIndex > MaxClients)
hNames.GetString(iRand, sName, sizeof(sName)); return;
delete hNames;
int iIndex = CreateFakeClient(sName); SetEntityFlags(iIndex, FL_CLIENT);
DispatchKeyValue(iIndex, "classname", "player");
DispatchSpawn(iIndex);
if(iIndex < 1 || iIndex > MaxClients) g_bFakePopulation[iIndex] = true;
return; g_iBaseLatency[iIndex] = GetRandomInt(20, 110);
g_iLatency[iIndex] = g_iBaseLatency[iIndex];
SetEntityFlags(iIndex, FL_CLIENT); AdminId FakeAdmin = CreateAdmin();
DispatchKeyValue(iIndex, "classname", "player"); SetAdminFlag(FakeAdmin, Admin_Custom6, true);
DispatchSpawn(iIndex); SetUserAdmin(iIndex, FakeAdmin, true);
//CS_SetClientClanTag(iIndex, "UNLOZE");
iFakes++;
g_bFakePopulation[iIndex] = true; g_bBlockInstantFakeConnects = true;
g_iBaseLatency[iIndex] = GetRandomInt(20, 110); }
g_iLatency[iIndex] = g_iBaseLatency[iIndex];
AdminId FakeAdmin = CreateAdmin(); while (iFakes > iFakesNeeded)
SetAdminFlag(FakeAdmin, Admin_Custom6, true); {
SetUserAdmin(iIndex, FakeAdmin, true); for(int i = 1; i <= MaxClients; i++)
//CS_SetClientClanTag(iIndex, "UNLOZE"); {
iFakes++; if(g_bFakePopulation[i])
{
g_bFakePopulation[i] = false;
g_iLatency[i] = 0;
KickClient(i, "Disconnect by user.");
iFakes--;
break;
}
}
}
}
g_bBlockInstantFakeConnects = true; for(int i = 1; i <= MaxClients; i++)
} {
if (g_bFakePopulation[i] && GetClientTeam(i) >= CS_TEAM_T)
iFakesInTeam++;
}
while (iFakes > iFakesNeeded) if (iFakes == iFakesNeeded && iFakesInTeam != iFakesInTeamNeeded && g_iAdminFakes == -1)
{ {
for(int i = 1; i <= MaxClients; i++) while (iFakesInTeam < iFakesInTeamNeeded)
{ {
if(g_bFakePopulation[i]) for(int i = 1; i <= MaxClients; i++)
{ {
g_bFakePopulation[i] = false; if(g_bFakePopulation[i] && GetClientTeam(i) <= CS_TEAM_SPECTATOR)
g_iLatency[i] = 0; {
KickClient(i, "Disconnect by user."); ChangeClientTeam(i, CS_TEAM_CT);
iFakes--; FakeClientCommandEx(i, "joinclass");
break; iFakesInTeam++;
} break;
} }
} }
} }
for(int i = 1; i <= MaxClients; i++) while (iFakesInTeam > iFakesInTeamNeeded)
{ {
if (g_bFakePopulation[i] && GetClientTeam(i) >= CS_TEAM_T) for(int i = 1; i <= MaxClients; i++)
iFakesInTeam++; {
} if(g_bFakePopulation[i] && GetClientTeam(i) >= CS_TEAM_T)
{
if (iFakes == iFakesNeeded && iFakesInTeam != iFakesInTeamNeeded && g_iAdminFakes == -1) ChangeClientTeam(i, CS_TEAM_SPECTATOR);
{ iFakesInTeam--;
while (iFakesInTeam < iFakesInTeamNeeded) break;
{ }
for(int i = 1; i <= MaxClients; i++) }
{ }
if(g_bFakePopulation[i] && GetClientTeam(i) <= CS_TEAM_SPECTATOR) }
{
ChangeClientTeam(i, CS_TEAM_CT);
FakeClientCommandEx(i, "joinclass");
iFakesInTeam++;
break;
}
}
}
while (iFakesInTeam > iFakesInTeamNeeded)
{
for(int i = 1; i <= MaxClients; i++)
{
if(g_bFakePopulation[i] && GetClientTeam(i) >= CS_TEAM_T)
{
ChangeClientTeam(i, CS_TEAM_SPECTATOR);
iFakesInTeam--;
break;
}
}
}
}
} }
//---------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------