reduced usage of getclientauthID to only on connects

This commit is contained in:
jenz 2023-06-25 13:03:32 +02:00
parent c5de285cec
commit c1783e81ef

View File

@ -22,6 +22,7 @@ char g_cSpecialMapEnd[g_dLength];
static char g_sConfigzones[PLATFORM_MAX_PATH]; static char g_sConfigzones[PLATFORM_MAX_PATH];
float g_fStartTime[MAXPLAYERS + 1]; float g_fStartTime[MAXPLAYERS + 1];
char g_csTime_record[MAXPLAYERS + 1][65]; char g_csTime_record[MAXPLAYERS + 1][65];
char g_csSID[MAXPLAYERS + 1][65];
float g_fClientVectors[MAXPLAYERS + 1][3]; float g_fClientVectors[MAXPLAYERS + 1][3];
float g_fClient_End_time[MAXPLAYERS + 1]; float g_fClient_End_time[MAXPLAYERS + 1];
int g_iClientFrames[MAXPLAYERS + 1]; int g_iClientFrames[MAXPLAYERS + 1];
@ -410,6 +411,7 @@ public void Event_RoundStart(Handle event, const char[] name, bool dontBroadcast
//---------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------
public void OnClientPostAdminCheck(int client) public void OnClientPostAdminCheck(int client)
{ {
GetClientAuthId(client, AuthId_Steam2, g_csSID[client], sizeof(g_csSID[]));
resetClient(client); resetClient(client);
insertPlayerMYSQL(client); insertPlayerMYSQL(client);
client_ignoring_racetimer(client); client_ignoring_racetimer(client);
@ -418,9 +420,7 @@ public void OnClientPostAdminCheck(int client)
public void client_ignoring_racetimer(int client) public void client_ignoring_racetimer(int client)
{ {
char query[g_dLength]; char query[g_dLength];
char steam_auth[g_dIndex]; Format(query, sizeof(query), "SELECT is_ignoring FROM `zetimer_table_new_ignoring` where steam_auth = '%s'", g_csSID[client]);
GetClientAuthId(client, AuthId_Steam2, steam_auth, sizeof(steam_auth));
Format(query, sizeof(query), "SELECT is_ignoring FROM `zetimer_table_new_ignoring` where steam_auth = '%s'", steam_auth);
g_dDatabase.Query(SQL_OnQueryCompleted_ignoring, query, GetClientSerial(client)); g_dDatabase.Query(SQL_OnQueryCompleted_ignoring, query, GetClientSerial(client));
} }
@ -467,7 +467,8 @@ public void OnClientCookiesCached(int client)
//---------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------
public void OnClientDisconnect(int client) public void OnClientDisconnect(int client)
{ {
resetClient(client); Format(g_csSID[client], sizeof(g_csSID[]), "");
resetClient(client);
} }
//---------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------
// Purpose: // Purpose:
@ -697,9 +698,7 @@ public void unloze_zoneLeave(int client, char[] zone)
{ {
if ((StrContains(zone, "ZONE_PREFIX_START") > -1) || StrEqual(zone, g_cSpecialMapStart)) if ((StrContains(zone, "ZONE_PREFIX_START") > -1) || StrEqual(zone, g_cSpecialMapStart))
{ {
char sAuthID[32]; if (!SteamClientAuthenticated(g_csSID[client]))
GetClientAuthId(client, AuthId_Steam2, sAuthID, sizeof(sAuthID), false);
if (!SteamClientAuthenticated(sAuthID))
{ {
PrintToChat(client, "Not starting timer due to being listed as nosteamer"); PrintToChat(client, "Not starting timer due to being listed as nosteamer");
return; return;
@ -761,16 +760,14 @@ public int RetrieveZoneIndex(char[] zone)
//---------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------
public void FinishedStageRaceZone(int client) public void FinishedStageRaceZone(int client)
{ {
char sSID[g_dIndex];
char sName[MAX_NAME_LENGTH]; char sName[MAX_NAME_LENGTH];
GetClientAuthId(client, AuthId_Steam2, sSID, sizeof(sSID));
GetClientName(client, sName, sizeof(sName)); GetClientName(client, sName, sizeof(sName));
int size2 = 2 * strlen(sName) + 1; int size2 = 2 * strlen(sName) + 1;
char[] sEscapedName = new char[size2 + 1]; char[] sEscapedName = new char[size2 + 1];
g_dDatabase.Escape(sName, sEscapedName, size2 + 1); g_dDatabase.Escape(sName, sEscapedName, size2 + 1);
if (StrEqual(sSID, "STEAM_ID_STOP_IGNORING_RETVALS") || StrEqual(sSID, "STEAM_ID_PENDING")) if (StrEqual(g_csSID[client], "STEAM_ID_STOP_IGNORING_RETVALS") || StrEqual(g_csSID[client], "STEAM_ID_PENDING"))
{ {
PrintToChat(client, "Your steam ID is not working, not updating timer"); PrintToChat(client, "Your steam ID is not working, not updating timer");
return; return;
@ -797,9 +794,9 @@ public void FinishedStageRaceZone(int client)
CPrintToChat(client, "{green}[UNLOZE] Your record: %s\nCommand: !toptime !mytime !stages", g_csTime_record[client]); CPrintToChat(client, "{green}[UNLOZE] Your record: %s\nCommand: !toptime !mytime !stages", g_csTime_record[client]);
} }
if (l_iZoneCount < 2) if (l_iZoneCount < 2)
Format(sQuery, sizeof(sQuery), "UPDATE `zetimer_table_new` SET `%s` = '%06.3f', name = '%s' WHERE steam_auth = '%s'", g_cMapname, client_time, sEscapedName, sSID); Format(sQuery, sizeof(sQuery), "UPDATE `zetimer_table_new` SET `%s` = '%06.3f', name = '%s' WHERE steam_auth = '%s'", g_cMapname, client_time, sEscapedName, g_csSID[client]);
else else
Format(sQuery, sizeof(sQuery), "UPDATE `zetimer_table_new` SET `%sS%i` = '%06.3f', name = '%s' WHERE steam_auth = '%s'", g_cMapname, stage, client_time, sEscapedName, sSID); Format(sQuery, sizeof(sQuery), "UPDATE `zetimer_table_new` SET `%sS%i` = '%06.3f', name = '%s' WHERE steam_auth = '%s'", g_cMapname, stage, client_time, sEscapedName, g_csSID[client]);
int generic_length = 32; int generic_length = 32;
char[][] sPart = new char[2][generic_length]; char[][] sPart = new char[2][generic_length];
float old_client_time = 0.0; float old_client_time = 0.0;
@ -826,18 +823,16 @@ public void FinishedStageRaceZone(int client)
public void mysql_get_player_time(int client, int stage) public void mysql_get_player_time(int client, int stage)
{ {
char query[g_dLength]; char query[g_dLength];
char steam_auth[g_dIndex];
GetClientAuthId(client, AuthId_Steam2, steam_auth, sizeof(steam_auth));
if (!stage) if (!stage)
{ {
Format(query, sizeof(query), "SELECT `%s` FROM `zetimer_table_new` where steam_auth = '%s'", g_cMapname, steam_auth); Format(query, sizeof(query), "SELECT `%s` FROM `zetimer_table_new` where steam_auth = '%s'", g_cMapname, g_csSID[client]);
DataPack hDataPack = new DataPack(); DataPack hDataPack = new DataPack();
hDataPack.WriteCell(GetClientSerial(client)); hDataPack.WriteCell(GetClientSerial(client));
g_dDatabase.Query(SQL_OnQueryCompleted_retry, query, hDataPack); g_dDatabase.Query(SQL_OnQueryCompleted_retry, query, hDataPack);
} }
else else
{ {
Format(query, sizeof(query), "SELECT `%sS%i` FROM `zetimer_table_new` where steam_auth = '%s'", g_cMapname, stage, steam_auth); Format(query, sizeof(query), "SELECT `%sS%i` FROM `zetimer_table_new` where steam_auth = '%s'", g_cMapname, stage, g_csSID[client]);
DataPack hDataPack = new DataPack(); DataPack hDataPack = new DataPack();
hDataPack.WriteCell(GetClientSerial(client)); hDataPack.WriteCell(GetClientSerial(client));
hDataPack.WriteString(query); hDataPack.WriteString(query);
@ -922,10 +917,8 @@ public void insertPlayerMYSQL(int client)
{ {
if (!IsValidClient(client)) if (!IsValidClient(client))
return; return;
char sSID[g_dIndex];
char sQuery[g_dLength]; char sQuery[g_dLength];
char sName[MAX_NAME_LENGTH]; char sName[MAX_NAME_LENGTH];
GetClientAuthId(client, AuthId_Steam2, sSID, sizeof(sSID));
GetClientName(client, sName, sizeof(sName)); GetClientName(client, sName, sizeof(sName));
int size2 = 2 * strlen(sName) + 1; int size2 = 2 * strlen(sName) + 1;
char[] sEscapedName = new char[size2 + 1]; char[] sEscapedName = new char[size2 + 1];
@ -934,12 +927,12 @@ public void insertPlayerMYSQL(int client)
return; return;
} }
g_dDatabase.Escape(sName, sEscapedName, size2 + 1); g_dDatabase.Escape(sName, sEscapedName, size2 + 1);
if (StrEqual(sSID, "STEAM_ID_STOP_IGNORING_RETVALS") || StrEqual(sSID, "STEAM_ID_PENDING")) if (StrEqual(g_csSID[client], "STEAM_ID_STOP_IGNORING_RETVALS") || StrEqual(g_csSID[client], "STEAM_ID_PENDING"))
{ {
PrintToChat(client, "Your steam ID is not working, not updating timer"); PrintToChat(client, "Your steam ID is not working, not updating timer");
return; return;
} }
Format(sQuery, sizeof(sQuery), "INSERT INTO `zetimer_table_new` (`steam_auth`, `name`) VALUES ('%s', '%s') ON DUPLICATE KEY UPDATE `name` = '%s'", sSID, sEscapedName, sEscapedName); Format(sQuery, sizeof(sQuery), "INSERT INTO `zetimer_table_new` (`steam_auth`, `name`) VALUES ('%s', '%s') ON DUPLICATE KEY UPDATE `name` = '%s'", g_csSID[client], sEscapedName, sEscapedName);
DataPack hDataPack = new DataPack(); DataPack hDataPack = new DataPack();
hDataPack.WriteString(sQuery); hDataPack.WriteString(sQuery);
g_dDatabase.Query(SQL_FinishedQuery, sQuery, hDataPack, DBPrio_Normal); g_dDatabase.Query(SQL_FinishedQuery, sQuery, hDataPack, DBPrio_Normal);
@ -971,19 +964,17 @@ public void insert_client_ignoring_racetimer(int client)
SetClientCookie(client, g_hClientCookie, "1"); SetClientCookie(client, g_hClientCookie, "1");
PrintToChat(client, "You are now ignoring the racetimer"); PrintToChat(client, "You are now ignoring the racetimer");
} }
char sSID[g_dIndex];
char sQuery[g_dLength]; char sQuery[g_dLength];
GetClientAuthId(client, AuthId_Steam2, sSID, sizeof(sSID));
if (!g_dDatabase) if (!g_dDatabase)
{ {
return; return;
} }
if (StrEqual(sSID, "STEAM_ID_STOP_IGNORING_RETVALS") || StrEqual(sSID, "STEAM_ID_PENDING")) if (StrEqual(g_csSID[client], "STEAM_ID_STOP_IGNORING_RETVALS") || StrEqual(g_csSID[client], "STEAM_ID_PENDING"))
{ {
PrintToChat(client, "Your steam ID is not working, not updating timer"); PrintToChat(client, "Your steam ID is not working, not updating timer");
return; return;
} }
Format(sQuery, sizeof(sQuery), "INSERT INTO `zetimer_table_new_ignoring` (`steam_auth`, `is_ignoring`) VALUES ('%s', '%i') ON DUPLICATE KEY UPDATE `is_ignoring` = '%i'", sSID, g_bClientsIgnoring[client], g_bClientsIgnoring[client]); Format(sQuery, sizeof(sQuery), "INSERT INTO `zetimer_table_new_ignoring` (`steam_auth`, `is_ignoring`) VALUES ('%s', '%i') ON DUPLICATE KEY UPDATE `is_ignoring` = '%i'", g_csSID[client], g_bClientsIgnoring[client], g_bClientsIgnoring[client]);
DataPack hDataPack = new DataPack(); DataPack hDataPack = new DataPack();
hDataPack.WriteString(sQuery); hDataPack.WriteString(sQuery);
g_dDatabase.Query(SQL_FinishedQuery, sQuery, hDataPack, DBPrio_Normal); g_dDatabase.Query(SQL_FinishedQuery, sQuery, hDataPack, DBPrio_Normal);
@ -1112,14 +1103,13 @@ public Action Cmd_timeReset(int client, int args)
ReplyToCommand(client, "[SM] Usage cleantime <target> <course>"); ReplyToCommand(client, "[SM] Usage cleantime <target> <course>");
return Plugin_Handled; return Plugin_Handled;
} }
char sTarget[65], steam2[64]; char sTarget[65];
GetCmdArg(1, sTarget, sizeof(sTarget)); GetCmdArg(1, sTarget, sizeof(sTarget));
int targetID = FindTarget(client, sTarget, false); int targetID = FindTarget(client, sTarget, false);
if(targetID == -1) if(targetID == -1)
return Plugin_Handled; return Plugin_Handled;
GetClientAuthId(targetID, AuthId_Steam2, steam2, sizeof(steam2));
GetCmdArg(2, sTarget, sizeof(sTarget)); GetCmdArg(2, sTarget, sizeof(sTarget));
deleteClientTime(steam2, StringToInt(sTarget)); deleteClientTime(g_csSID[targetID], StringToInt(sTarget));
return Plugin_Handled; return Plugin_Handled;
} }
//---------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------
@ -1244,8 +1234,6 @@ public void Checkself(int client)
{ {
int l_iZoneCount = unloze_zoneCount(); int l_iZoneCount = unloze_zoneCount();
char l_cQuery[g_dLength]; char l_cQuery[g_dLength];
char l_cSID[g_dIndex];
GetClientAuthId(client, AuthId_Steam2, l_cSID, sizeof(l_cSID));
if (l_iZoneCount < 1) if (l_iZoneCount < 1)
{ {
PrintToChat(client, "No zones active on this map"); PrintToChat(client, "No zones active on this map");
@ -1253,7 +1241,7 @@ public void Checkself(int client)
} }
if (l_iZoneCount < 2) if (l_iZoneCount < 2)
{ {
Format(l_cQuery, sizeof(l_cQuery), "SELECT name, `%s` FROM `zetimer_table_new` WHERE steam_auth = '%s'", g_cMapname, l_cSID); Format(l_cQuery, sizeof(l_cQuery), "SELECT name, `%s` FROM `zetimer_table_new` WHERE steam_auth = '%s'", g_cMapname, g_csSID[client]);
DataPack hDataPack = new DataPack(); DataPack hDataPack = new DataPack();
hDataPack.WriteCell(GetClientSerial(client)); hDataPack.WriteCell(GetClientSerial(client));
hDataPack.WriteString(l_cQuery); hDataPack.WriteString(l_cQuery);
@ -1268,9 +1256,7 @@ public void Checkself(int client)
public void CheckStageSelf(int client, int selection) public void CheckStageSelf(int client, int selection)
{ {
char l_cQuery[g_dLength]; char l_cQuery[g_dLength];
char l_cSID[g_dIndex]; Format(l_cQuery, sizeof(l_cQuery), "SELECT name, `%sS%i` FROM `zetimer_table_new` WHERE steam_auth = '%s'", g_cMapname, selection, g_csSID[client]);
GetClientAuthId(client, AuthId_Steam2, l_cSID, sizeof(l_cSID));
Format(l_cQuery, sizeof(l_cQuery), "SELECT name, `%sS%i` FROM `zetimer_table_new` WHERE steam_auth = '%s'", g_cMapname, selection, l_cSID);
DataPack hDataPack = new DataPack(); DataPack hDataPack = new DataPack();
hDataPack.WriteCell(GetClientSerial(client)); hDataPack.WriteCell(GetClientSerial(client));
hDataPack.WriteString(l_cQuery); hDataPack.WriteString(l_cQuery);