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++;
}
int iFakesNeeded = 0; //24 to account for 4 autismbots.
int iFakesInTeamNeeded = 0; iFakesNeeded = 24 - RoundToFloor(iPlayers / 1.5);
if (iFakesNeeded < 0)
{
iFakesNeeded = 0;
iFakesInTeamNeeded = 0;
}
else
{
iFakesInTeamNeeded = iFakesNeeded / 3;
}
if(bServerDying) if(g_iAdminFakes != -1)
{ iFakesNeeded = g_iAdminFakes;
if (iPlayers > 45)
{
iFakesNeeded = 6;
iFakesInTeamNeeded = 2;
}
else if (iPlayers > 20)
{
iFakesNeeded = 7;
iFakesInTeamNeeded = 3;
}
else if (iPlayers > 10)
{
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) if (iFakes != iFakesNeeded)
iFakesNeeded = g_iAdminFakes; {
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);
}
}
if (iFakes != iFakesNeeded) int iRand = GetRandomInt(0, hNames.Length - 1);
{ hNames.GetString(iRand, sName, sizeof(sName));
while (iFakes < iFakesNeeded && !g_bBlockInstantFakeConnects) delete hNames;
{
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); int iIndex = CreateFakeClient(sName);
hNames.GetString(iRand, sName, sizeof(sName));
delete hNames;
int iIndex = CreateFakeClient(sName); if(iIndex < 1 || iIndex > MaxClients)
return;
if(iIndex < 1 || iIndex > MaxClients) SetEntityFlags(iIndex, FL_CLIENT);
return; DispatchKeyValue(iIndex, "classname", "player");
DispatchSpawn(iIndex);
SetEntityFlags(iIndex, FL_CLIENT); g_bFakePopulation[iIndex] = true;
DispatchKeyValue(iIndex, "classname", "player"); g_iBaseLatency[iIndex] = GetRandomInt(20, 110);
DispatchSpawn(iIndex); g_iLatency[iIndex] = g_iBaseLatency[iIndex];
g_bFakePopulation[iIndex] = true; AdminId FakeAdmin = CreateAdmin();
g_iBaseLatency[iIndex] = GetRandomInt(20, 110); SetAdminFlag(FakeAdmin, Admin_Custom6, true);
g_iLatency[iIndex] = g_iBaseLatency[iIndex]; SetUserAdmin(iIndex, FakeAdmin, true);
//CS_SetClientClanTag(iIndex, "UNLOZE");
iFakes++;
AdminId FakeAdmin = CreateAdmin(); g_bBlockInstantFakeConnects = true;
SetAdminFlag(FakeAdmin, Admin_Custom6, true); }
SetUserAdmin(iIndex, FakeAdmin, true);
//CS_SetClientClanTag(iIndex, "UNLOZE");
iFakes++;
g_bBlockInstantFakeConnects = true; while (iFakes > iFakesNeeded)
} {
for(int i = 1; i <= MaxClients; i++)
{
if(g_bFakePopulation[i])
{
g_bFakePopulation[i] = false;
g_iLatency[i] = 0;
KickClient(i, "Disconnect by user.");
iFakes--;
break;
}
}
}
}
while (iFakes > iFakesNeeded) for(int i = 1; i <= MaxClients; i++)
{ {
for(int i = 1; i <= MaxClients; i++) if (g_bFakePopulation[i] && GetClientTeam(i) >= CS_TEAM_T)
{ iFakesInTeam++;
if(g_bFakePopulation[i]) }
{
g_bFakePopulation[i] = false;
g_iLatency[i] = 0;
KickClient(i, "Disconnect by user.");
iFakes--;
break;
}
}
}
}
for(int i = 1; i <= MaxClients; i++) if (iFakes == iFakesNeeded && iFakesInTeam != iFakesInTeamNeeded && g_iAdminFakes == -1)
{ {
if (g_bFakePopulation[i] && GetClientTeam(i) >= CS_TEAM_T) while (iFakesInTeam < iFakesInTeamNeeded)
iFakesInTeam++; {
} 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;
}
}
}
if (iFakes == iFakesNeeded && iFakesInTeam != iFakesInTeamNeeded && g_iAdminFakes == -1) while (iFakesInTeam > iFakesInTeamNeeded)
{ {
while (iFakesInTeam < iFakesInTeamNeeded) for(int i = 1; i <= MaxClients; i++)
{ {
for(int i = 1; i <= MaxClients; i++) if(g_bFakePopulation[i] && GetClientTeam(i) >= CS_TEAM_T)
{ {
if(g_bFakePopulation[i] && GetClientTeam(i) <= CS_TEAM_SPECTATOR) ChangeClientTeam(i, CS_TEAM_SPECTATOR);
{ iFakesInTeam--;
ChangeClientTeam(i, CS_TEAM_CT); break;
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;
}
}
}
}
} }
//---------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------