From cfef039db519c1b7ffbdab265a9c4a33dc547672 Mon Sep 17 00:00:00 2001 From: jenz Date: Sun, 25 Jun 2023 13:03:32 +0200 Subject: [PATCH] reduced usage of getclientauthID to only on connects --- RaceTimer/scripting/unloze_racetimer_redux.sp | 52 +++++++------------ 1 file changed, 19 insertions(+), 33 deletions(-) diff --git a/RaceTimer/scripting/unloze_racetimer_redux.sp b/RaceTimer/scripting/unloze_racetimer_redux.sp index f2287ef5..6e829f7e 100755 --- a/RaceTimer/scripting/unloze_racetimer_redux.sp +++ b/RaceTimer/scripting/unloze_racetimer_redux.sp @@ -22,6 +22,7 @@ char g_cSpecialMapEnd[g_dLength]; static char g_sConfigzones[PLATFORM_MAX_PATH]; float g_fStartTime[MAXPLAYERS + 1]; char g_csTime_record[MAXPLAYERS + 1][65]; +char g_csSID[MAXPLAYERS + 1][65]; float g_fClientVectors[MAXPLAYERS + 1][3]; float g_fClient_End_time[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) { + GetClientAuthId(client, AuthId_Steam2, g_csSID[client], sizeof(g_csSID[])); resetClient(client); insertPlayerMYSQL(client); client_ignoring_racetimer(client); @@ -418,9 +420,7 @@ public void OnClientPostAdminCheck(int client) public void client_ignoring_racetimer(int client) { char query[g_dLength]; - char steam_auth[g_dIndex]; - 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); + Format(query, sizeof(query), "SELECT is_ignoring FROM `zetimer_table_new_ignoring` where steam_auth = '%s'", g_csSID[client]); g_dDatabase.Query(SQL_OnQueryCompleted_ignoring, query, GetClientSerial(client)); } @@ -467,7 +467,8 @@ public void OnClientCookiesCached(int client) //---------------------------------------------------------------------------------------------------- public void OnClientDisconnect(int client) { - resetClient(client); + Format(g_csSID[client], sizeof(g_csSID[]), ""); + resetClient(client); } //---------------------------------------------------------------------------------------------------- // Purpose: @@ -697,9 +698,7 @@ public void unloze_zoneLeave(int client, char[] zone) { if ((StrContains(zone, "ZONE_PREFIX_START") > -1) || StrEqual(zone, g_cSpecialMapStart)) { - char sAuthID[32]; - GetClientAuthId(client, AuthId_Steam2, sAuthID, sizeof(sAuthID), false); - if (!SteamClientAuthenticated(sAuthID)) + if (!SteamClientAuthenticated(g_csSID[client])) { PrintToChat(client, "Not starting timer due to being listed as nosteamer"); return; @@ -761,16 +760,14 @@ public int RetrieveZoneIndex(char[] zone) //---------------------------------------------------------------------------------------------------- public void FinishedStageRaceZone(int client) { - char sSID[g_dIndex]; char sName[MAX_NAME_LENGTH]; - GetClientAuthId(client, AuthId_Steam2, sSID, sizeof(sSID)); GetClientName(client, sName, sizeof(sName)); int size2 = 2 * strlen(sName) + 1; char[] sEscapedName = new char[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"); 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]); } 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 - 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; char[][] sPart = new char[2][generic_length]; 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) { char query[g_dLength]; - char steam_auth[g_dIndex]; - GetClientAuthId(client, AuthId_Steam2, steam_auth, sizeof(steam_auth)); 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(); hDataPack.WriteCell(GetClientSerial(client)); g_dDatabase.Query(SQL_OnQueryCompleted_retry, query, hDataPack); } 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(); hDataPack.WriteCell(GetClientSerial(client)); hDataPack.WriteString(query); @@ -922,10 +917,8 @@ public void insertPlayerMYSQL(int client) { if (!IsValidClient(client)) return; - char sSID[g_dIndex]; char sQuery[g_dLength]; char sName[MAX_NAME_LENGTH]; - GetClientAuthId(client, AuthId_Steam2, sSID, sizeof(sSID)); GetClientName(client, sName, sizeof(sName)); int size2 = 2 * strlen(sName) + 1; char[] sEscapedName = new char[size2 + 1]; @@ -934,12 +927,12 @@ public void insertPlayerMYSQL(int client) return; } 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"); 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(); hDataPack.WriteString(sQuery); 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"); PrintToChat(client, "You are now ignoring the racetimer"); } - char sSID[g_dIndex]; char sQuery[g_dLength]; - GetClientAuthId(client, AuthId_Steam2, sSID, sizeof(sSID)); if (!g_dDatabase) { 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"); 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(); hDataPack.WriteString(sQuery); 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 "); return Plugin_Handled; } - char sTarget[65], steam2[64]; + char sTarget[65]; GetCmdArg(1, sTarget, sizeof(sTarget)); int targetID = FindTarget(client, sTarget, false); if(targetID == -1) return Plugin_Handled; - GetClientAuthId(targetID, AuthId_Steam2, steam2, sizeof(steam2)); GetCmdArg(2, sTarget, sizeof(sTarget)); - deleteClientTime(steam2, StringToInt(sTarget)); + deleteClientTime(g_csSID[targetID], StringToInt(sTarget)); return Plugin_Handled; } //---------------------------------------------------------------------------------------------------- @@ -1244,8 +1234,6 @@ public void Checkself(int client) { int l_iZoneCount = unloze_zoneCount(); char l_cQuery[g_dLength]; - char l_cSID[g_dIndex]; - GetClientAuthId(client, AuthId_Steam2, l_cSID, sizeof(l_cSID)); if (l_iZoneCount < 1) { PrintToChat(client, "No zones active on this map"); @@ -1253,7 +1241,7 @@ public void Checkself(int client) } 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(); hDataPack.WriteCell(GetClientSerial(client)); hDataPack.WriteString(l_cQuery); @@ -1268,9 +1256,7 @@ public void Checkself(int client) public void CheckStageSelf(int client, int selection) { char l_cQuery[g_dLength]; - char l_cSID[g_dIndex]; - 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); + Format(l_cQuery, sizeof(l_cQuery), "SELECT name, `%sS%i` FROM `zetimer_table_new` WHERE steam_auth = '%s'", g_cMapname, selection, g_csSID[client]); DataPack hDataPack = new DataPack(); hDataPack.WriteCell(GetClientSerial(client)); hDataPack.WriteString(l_cQuery);