further clean up of unneeded stuff

This commit is contained in:
jenz 2026-04-06 23:28:09 +02:00
parent 06734d1b6e
commit 13f4727826

View File

@ -11,17 +11,10 @@
ArrayList g_hNames; ArrayList g_hNames;
ArrayList g_hClanNames; ArrayList g_hClanNames;
bool g_bMapEnded;
int g_iBaseLatency[MAXPLAYERS + 1]; int g_iBaseLatency[MAXPLAYERS + 1];
int g_iLatency[MAXPLAYERS + 1]; int g_iLatency[MAXPLAYERS + 1];
int g_iAdminFakes; int g_iAdminFakes;
int g_iPopulation;
bool g_bCheckRequested;
bool g_bBlockInstantFakeConnects;
Database g_hDatabase; Database g_hDatabase;
Database g_hDatabase_hlstats; Database g_hDatabase_hlstats;
@ -31,7 +24,7 @@ Database g_hDatabase_hlstats;
//---------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------
public Plugin myinfo = public Plugin myinfo =
{ {
name = "ImprovedHitboxes", //camouflage name = "fakes",
author = "Neon + Dogan + Botox", author = "Neon + Dogan + Botox",
description = "Handle Hitboxes via Plugin", description = "Handle Hitboxes via Plugin",
version = "5.3.1", version = "5.3.1",
@ -52,22 +45,12 @@ public void OnPluginStart()
g_hClanNames = CreateArray(arraySize); g_hClanNames = CreateArray(arraySize);
g_iAdminFakes = -1; g_iAdminFakes = -1;
g_iPopulation = GetClientCount(false); CreateTimer(20.0, RunPopulationCheck, _, TIMER_REPEAT);
for(int i = 1; i <= MaxClients; i++)
{
if(IsClientConnected(i) && IsFakeClient(i) && !IsClientSourceTV(i))
g_iPopulation--;
}
g_bMapEnded = false;
g_bBlockInstantFakeConnects = false;
CreateTimer(10.0, BlockInstantFakeConnects, _, TIMER_REPEAT);
CreateTimer(3.0, RandomizePing, _, TIMER_REPEAT); CreateTimer(3.0, RandomizePing, _, TIMER_REPEAT);
CreateTimer(150.0, RandomizeNames, _, TIMER_REPEAT); CreateTimer(150.0, RandomizeNames, _, TIMER_REPEAT);
HookUserMessage(GetUserMessageId("SayText2"), UserMessage_SayText2, true); HookUserMessage(GetUserMessageId("SayText2"), UserMessage_SayText2, true);
RequestFrame(CheckPopulation);
if (!g_hDatabase) if (!g_hDatabase)
{ {
Database.Connect(SQL_OnDatabaseConnect, "racetimercss"); Database.Connect(SQL_OnDatabaseConnect, "racetimercss");
@ -197,36 +180,6 @@ public void OnMapStart()
{ {
randomize_clantags(); randomize_clantags();
} }
/*
char sFile[PLATFORM_MAX_PATH];
char sLine[MAX_NAME_LENGTH];
BuildPath(Path_SM, sFile, sizeof(sFile), "configs/fakeclients_names.txt");
Handle hFile = OpenFile(sFile, "r");
if(hFile != INVALID_HANDLE)
{
int iLine = 0;
g_hNames.Clear();
while (!IsEndOfFile(hFile))
{
if (!ReadFileLine(hFile, sLine, sizeof(sLine)) || iLine >= MAXNAMES)
break;
TrimString(sLine);
g_hNames.PushString(sLine);
iLine++;
}
delete hFile;
}
else
SetFailState("Could not open file: configs/fakeclients_names.txt");
*/
g_bMapEnded = false;
g_bBlockInstantFakeConnects = false;
} }
//---------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------
@ -234,24 +187,15 @@ public void OnMapStart()
//---------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------
public void OnMapEnd() public void OnMapEnd()
{ {
g_bMapEnded = true;
g_iAdminFakes = -1; g_iAdminFakes = -1;
g_iPopulation = GetClientCount(false);
for(int i = 1; i <= MaxClients; i++)
{
if(IsClientConnected(i) && IsFakeClient(i) && !IsClientSourceTV(i))
g_iPopulation--;
}
} }
//---------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------
// Purpose: // Purpose:
//---------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------
public Action BlockInstantFakeConnects(Handle timer) public Action RunPopulationCheck(Handle timer)
{ {
g_bBlockInstantFakeConnects = false;
RequestFrame(CheckPopulation); RequestFrame(CheckPopulation);
return Plugin_Continue; return Plugin_Continue;
} }
@ -364,15 +308,12 @@ public Action Command_DebugFakes(int client, int argc)
iFakes++; iFakes++;
iPlayers--; iPlayers--;
} }
if (IsFakeClient(i) && GetClientTeam(i) > 0) if (IsFakeClient(i) && GetClientTeam(i) > CS_TEAM_SPECTATOR)
iFakesInTeam++; iFakesInTeam++;
} }
ReplyToCommand(client, "[SM] There are currently %d Fake-Clients, from which %d are in Spectate.", iFakes, iFakes - iFakesInTeam); ReplyToCommand(client, "[SM] There are currently %d Fake-Clients, from which %d are in Spectate.", iFakes, iFakes - iFakesInTeam);
ReplyToCommand(client, "[SM] Server Population at the end of the previous Map: %d.", g_iPopulation);
ReplyToCommand(client, "[SM] Current Server Population: %d. Difference: %d.", iPlayers, iPlayers - g_iPopulation);
return Plugin_Handled; return Plugin_Handled;
} }
@ -397,7 +338,6 @@ public Action Command_SetFakes(int client, int argc)
} }
ReplyToCommand(client, "[SM] You set the amount of Fake-Clients to %d.", g_iAdminFakes); ReplyToCommand(client, "[SM] You set the amount of Fake-Clients to %d.", g_iAdminFakes);
CheckPopulation();
return Plugin_Handled; return Plugin_Handled;
} }
@ -433,18 +373,6 @@ public Action Command_Fakes(int client, int args)
return Plugin_Handled; return Plugin_Handled;
} }
//----------------------------------------------------------------------------------------------------
// Purpose:
//----------------------------------------------------------------------------------------------------
public void OnClientConnected(int client)
{
if (!g_bCheckRequested && !IsFakeClient(client) && !IsClientSourceTV(client))
{
RequestFrame(CheckPopulation);
g_bCheckRequested = true;
}
}
//---------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------
// Purpose: // Purpose:
//---------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------
@ -456,62 +384,44 @@ public void OnClientDisconnect(int client)
{ {
g_iLatency[client] = 0; g_iLatency[client] = 0;
} }
if (!g_bCheckRequested && !IsFakeClient(client) && !IsClientSourceTV(client))
{
RequestFrame(CheckPopulation);
g_bCheckRequested = true;
}
} }
} }
public Action repeatCheckPopulation(Handle timer)
{
CheckPopulation();
return Plugin_Continue;
}
//---------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------
// Purpose: // Purpose:
//---------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------
public void CheckPopulation() public void CheckPopulation()
{ {
if (g_hNames.Length == 0 || g_hClanNames.Length == 0) int iPlayers = 0;
{
CreateTimer(5.0, repeatCheckPopulation);
return;
}
g_bCheckRequested = false;
if(g_bMapEnded)
return;
int iPlayers = GetClientCount(false);
for(int i = 1; i <= MaxClients; i++) for(int i = 1; i <= MaxClients; i++)
{ {
if(IsClientConnected(i) && IsClientInGame(i) && IsClientAuthorized(i) && (IsFakeClient(i) || IsClientAutismBot(i) || IsClientSourceTV(i) || GetClientTeam(i) <= CS_TEAM_SPECTATOR)) if(IsClientConnected(i) && IsClientInGame(i) && IsClientAuthorized(i) && !IsFakeClient(i) && !IsClientAutismBot(i) && !IsClientSourceTV(i) && GetClientTeam(i) > CS_TEAM_SPECTATOR)
iPlayers--; iPlayers++;
} }
int iFakes = 0;
int iFakesInTeam = 0; int iFakesInTeam = 0;
for(int i = 1; i <= MaxClients; i++)
{
if (IsClientConnected(i) && IsFakeClient(i) && !IsClientSourceTV(i))
iFakes++;
}
bool okay_to_change_count = true; bool okay_to_change_count = true;
if (iPlayers > 16) if (iPlayers > 16)
{ {
iPlayers = 16; iPlayers = 16;
} }
int iFakesInTeamNeeded = iPlayers; int iFakesInTeamNeeded = iPlayers / 5;
int iFakesNeeded = iPlayers; int iFakesNeeded = iPlayers;
iPlayers = GetClientCount(false); iPlayers = 0;
for(int i = 1; i <= MaxClients; i++)
{
if(IsClientConnected(i) && IsClientInGame(i) && IsClientAuthorized(i) && !IsFakeClient(i) && !IsClientAutismBot(i) && !IsClientSourceTV(i) && GetClientTeam(i) > CS_TEAM_SPECTATOR)
iPlayers++;
}
int iFakes = 0;
for(int i = 1; i <= MaxClients; i++)
{
if (IsClientConnected(i) && IsFakeClient(i) && !IsClientSourceTV(i))
iFakes++;
}
if (iPlayers > 53) if (iPlayers > 53)
{ {
@ -520,7 +430,7 @@ public void CheckPopulation()
} }
else if (iPlayers > 48 && iFakes > 10) else if (iPlayers > 48 && iFakes > 10)
{ {
iFakesInTeamNeeded = 5; iFakesInTeamNeeded = 3;
iFakesNeeded = 10; iFakesNeeded = 10;
} }
else if (iPlayers >= 42) else if (iPlayers >= 42)
@ -538,13 +448,13 @@ public void CheckPopulation()
} }
//LogMessage("specs: %i", specs); //LogMessage("specs: %i", specs);
if (specs >= 13) if (specs >= 13 && iFakesNeeded > 0)
{ {
if (iFakesNeeded > 5) iFakesInTeamNeeded = iFakes;
if (iFakes >= 5)
{ {
iFakesNeeded = 5; iFakesNeeded = iFakesInTeamNeeded = 5;
} }
iFakesInTeamNeeded = iFakesNeeded;
okay_to_change_count = true; okay_to_change_count = true;
//LogMessage("iFakesInTeamNeeded: %i", iFakesInTeamNeeded); //LogMessage("iFakesInTeamNeeded: %i", iFakesInTeamNeeded);
} }
@ -561,7 +471,7 @@ public void CheckPopulation()
if (iFakes != iFakesNeeded && okay_to_change_count) if (iFakes != iFakesNeeded && okay_to_change_count)
{ {
while (iFakes < iFakesNeeded && !g_bBlockInstantFakeConnects) if (iFakes < iFakesNeeded)
{ {
ArrayList hNames = g_hNames.Clone(); ArrayList hNames = g_hNames.Clone();
char sName[MAX_NAME_LENGTH]; char sName[MAX_NAME_LENGTH];
@ -610,7 +520,6 @@ public void CheckPopulation()
} }
iFakes++; iFakes++;
g_bBlockInstantFakeConnects = true;
} }
if (iFakes > iFakesNeeded) if (iFakes > iFakesNeeded)