fixed client not connected
This commit is contained in:
parent
6b2abc9643
commit
b955d26153
@ -150,12 +150,12 @@ public void OnMapEnd()
|
|||||||
|
|
||||||
public void Cvar_backupurl1(ConVar convar, const char[] oldValue, const char[] newValue)
|
public void Cvar_backupurl1(ConVar convar, const char[] oldValue, const char[] newValue)
|
||||||
{
|
{
|
||||||
convar.SetString(newValue);
|
convar.SetString(g_cBackupURLS[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Cvar_backupurl2(ConVar convar, const char[] oldValue, const char[] newValue)
|
public void Cvar_backupurl2(ConVar convar, const char[] oldValue, const char[] newValue)
|
||||||
{
|
{
|
||||||
convar.SetString(newValue);
|
convar.SetString(g_cBackupURLS[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OnConfigsExecuted()
|
public void OnConfigsExecuted()
|
||||||
@ -174,35 +174,36 @@ public MRESReturn sendServerInfoDetCallback_Pre(Address pointer, Handle hReturn,
|
|||||||
|
|
||||||
public MRESReturn buildConVarMessageDetCallback_Pre(Handle hParams) //Second callback
|
public MRESReturn buildConVarMessageDetCallback_Pre(Handle hParams) //Second callback
|
||||||
{
|
{
|
||||||
if ((g_icurrentClient == 0 || g_icurrentClient > MaxClients)) return MRES_Ignored;
|
if (g_icurrentClient > 0 && g_icurrentClient <= MaxClients && IsClientConnected(g_icurrentClient) && IsClientInGame(g_icurrentClient))
|
||||||
|
|
||||||
char clientIPAddress[64]; //IP of the connecting client
|
|
||||||
GetClientIP(g_icurrentClient, clientIPAddress, sizeof(clientIPAddress));
|
|
||||||
|
|
||||||
for (int i = 0; i < sizeof(g_cIPaddresses); i++)
|
|
||||||
{
|
{
|
||||||
if (StrEqual(g_cIPaddresses[i], clientIPAddress))
|
char clientIPAddress[64]; //IP of the connecting client
|
||||||
|
GetClientIP(g_icurrentClient, clientIPAddress, sizeof(clientIPAddress));
|
||||||
|
|
||||||
|
for (int i = 0; i < sizeof(g_cIPaddresses); i++)
|
||||||
{
|
{
|
||||||
int rotated = -1;
|
if (StrEqual(g_cIPaddresses[i], clientIPAddress))
|
||||||
g_SteamIDRotations.GetValue(clientIPAddress, rotated);
|
|
||||||
|
|
||||||
//0 = hetzner nide. 1 = ovh uk unloze. 2 = default sv_downloadurl again. so not overwriting anything
|
|
||||||
rotated = rotated % 3;
|
|
||||||
|
|
||||||
//the bz2 file does not exist on the backup urls so rotate to the next working one. for example hetzner nide might not have but ovh uk has.
|
|
||||||
while (rotated < sizeof(g_cBackupURLS) && !g_bDoesIndexHaveBZ2[rotated])
|
|
||||||
{
|
{
|
||||||
rotated++;
|
int rotated = -1;
|
||||||
|
g_SteamIDRotations.GetValue(clientIPAddress, rotated);
|
||||||
|
|
||||||
|
//0 = hetzner nide. 1 = ovh uk unloze. 2 = default sv_downloadurl again. so not overwriting anything
|
||||||
|
rotated = rotated % 3;
|
||||||
|
|
||||||
|
//the bz2 file does not exist on the backup urls so rotate to the next working one. for example hetzner nide might not have but ovh uk has.
|
||||||
|
while (rotated < sizeof(g_cBackupURLS) && !g_bDoesIndexHaveBZ2[rotated])
|
||||||
|
{
|
||||||
|
rotated++;
|
||||||
|
}
|
||||||
|
if (rotated < sizeof(g_cBackupURLS))
|
||||||
|
{
|
||||||
|
char map[256];
|
||||||
|
GetCurrentMap(map, sizeof(map));
|
||||||
|
g_SteamIDRotations.SetValue(clientIPAddress, rotated, true); //adapting in case of increment.
|
||||||
|
LogMessage("client %N had missing map with cloudflare on %s. using %s instead.", g_icurrentClient, map, g_cBackupURLS[rotated]);
|
||||||
|
setConVarValue(g_cBackupURLS[rotated]);
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
if (rotated < sizeof(g_cBackupURLS))
|
|
||||||
{
|
|
||||||
char map[256];
|
|
||||||
GetCurrentMap(map, sizeof(map));
|
|
||||||
g_SteamIDRotations.SetValue(clientIPAddress, rotated, true); //adapting in case of increment.
|
|
||||||
LogMessage("client %N had missing map with cloudflare on %s. using %s instead.", g_icurrentClient, map, g_cBackupURLS[rotated]);
|
|
||||||
setConVarValue(g_cBackupURLS[rotated]);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return MRES_Ignored;
|
return MRES_Ignored;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user