delete dbresults in more cases, some printing, using getclientserial
This commit is contained in:
		
							parent
							
								
									48d793437a
								
							
						
					
					
						commit
						334b5bbde4
					
				| @ -184,12 +184,16 @@ public void SQL_OnConnectFinished(Database db, DBResultSet results, const char[] | ||||
| { | ||||
|     if(!db || strlen(error)) | ||||
|     { | ||||
|             delete results; | ||||
|             LogError("Database error: %s", error); | ||||
|             return; | ||||
|     } | ||||
|     static Handle hHostName; | ||||
|     if((hHostName = FindConVar("hostname")) == INVALID_HANDLE) | ||||
|     { | ||||
|         delete results; | ||||
|         return; | ||||
|     } | ||||
|     char line[g_dLength]; | ||||
|     GetConVarString(hHostName, line, sizeof(line)); | ||||
|     if (StrContains(line, "EVENT", false) > -1) | ||||
| @ -204,6 +208,7 @@ public void SQL_OnConnectFinished(Database db, DBResultSet results, const char[] | ||||
|         if (IsValidClient(i)) | ||||
|             OnClientPostAdminCheck(i); | ||||
|     AddBinarySearchIndex(); | ||||
|     delete results; | ||||
| } | ||||
| 
 | ||||
| public void MYSQLCheckMapEntry() | ||||
| @ -238,6 +243,7 @@ public void MYSQLCheckMapEntry() | ||||
| 
 | ||||
| public void SQL_FinishedQuery(Database db, DBResultSet results, const char[] error, DataPack data) | ||||
| { | ||||
|     delete results; | ||||
|     if (!db || strlen(error)) | ||||
|     { | ||||
|         char sQuery[g_dLength]; | ||||
| @ -416,17 +422,28 @@ public void client_ignoring_racetimer(int client) | ||||
|     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); | ||||
|     g_dDatabase.Query(SQL_OnQueryCompleted_ignoring, query, client); | ||||
| 
 | ||||
|     g_dDatabase.Query(SQL_OnQueryCompleted_ignoring, query, GetClientSerial(client)); | ||||
| } | ||||
| 
 | ||||
| public void SQL_OnQueryCompleted_ignoring(Database db, DBResultSet results, const char[] error, int client) | ||||
| public void SQL_OnQueryCompleted_ignoring(Database db, DBResultSet results, const char[] error, int Serial) | ||||
| { | ||||
|     if (!db) | ||||
|     { | ||||
|         delete results; | ||||
|         return; | ||||
|     } | ||||
|     int client;  | ||||
|     if ((client = GetClientFromSerial(Serial)) == 0) | ||||
|     { | ||||
|         delete results; | ||||
|         return; | ||||
|     } | ||||
|     if (!IsValidClient(client)) | ||||
|     { | ||||
|         delete results; | ||||
|         return; | ||||
|     } | ||||
|     int val = 0; | ||||
|     if (results.RowCount && results.FetchRow()) | ||||
|         val = results.FetchInt(0); | ||||
| @ -435,6 +452,7 @@ public void SQL_OnQueryCompleted_ignoring(Database db, DBResultSet results, cons | ||||
|     { | ||||
|         g_bClientsIgnoring[client] = true; | ||||
|     } | ||||
|     delete results; | ||||
| } | ||||
| //---------------------------------------------------------------------------------------------------- | ||||
| // Purpose:  | ||||
| @ -689,6 +707,7 @@ public void unloze_zoneLeave(int client, char[] zone) | ||||
|             } | ||||
|             if (!g_bClient_allowed_to_leave_again[client]) | ||||
|             { | ||||
|                 PrintToChat(client, "Did not start timer due to teleport cooldown."); | ||||
|                 return; | ||||
|             } | ||||
| 
 | ||||
| @ -767,16 +786,16 @@ public void FinishedStageRaceZone(int client) | ||||
|     } | ||||
|     if (l_iZoneCount > 1) | ||||
|         CPrintToChat(client, "{green}[UNLOZE] Stage: %i", player_stage[client]); | ||||
|     CPrintToChat(client, "{green}[UNLOZE] Client: %N Time: %06.3f", client, client_time); | ||||
|     CPrintToChat(client, "{green}[UNLOZE] Time: %06.3f", client_time); | ||||
|     int stage = player_stage[client]; | ||||
|     char sQuery[g_dLength]; | ||||
|     if (StrEqual(g_csTime_record[client], "0.000")) | ||||
|     { | ||||
|         CPrintToChat(client, "Your record: None yet\nCommand: !toptime !mytime !stages"); | ||||
|         CPrintToChat(client, "{green}[UNLOZE] Your record: None yet\nCommand: !toptime !mytime !stages"); | ||||
|     } | ||||
|     else | ||||
|     { | ||||
|         CPrintToChat(client, "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) | ||||
|         Format(sQuery, sizeof(sQuery), "UPDATE `zetimer_table_new` SET `%s` = '%06.3f', name = '%s' WHERE steam_auth = '%s'", g_cMapname, client_time, sEscapedName, sSID); | ||||
| @ -835,18 +854,24 @@ public void SQL_OnQueryCompleted_retry(Database db, DBResultSet results, const c | ||||
|     delete data; | ||||
|     if (!db) | ||||
|     { | ||||
|         delete results; | ||||
|         return; | ||||
|     } | ||||
|     int client;  | ||||
|     if ((client = GetClientFromSerial(client_serial)) == 0) | ||||
|     { | ||||
|         delete results; | ||||
|         return; | ||||
|     } | ||||
|     if (strlen(error)) | ||||
|     { | ||||
|         delete results; | ||||
|         mysql_get_player_time(client, 1); | ||||
|         return; | ||||
|     } | ||||
|     if (results.RowCount && results.FetchRow()) | ||||
|         results.FetchString(0, g_csTime_record[client], sizeof(g_csTime_record[])); | ||||
|     delete results; | ||||
| } | ||||
| 
 | ||||
| public void SQL_OnQueryCompleted(Database db, DBResultSet results, const char[] error, DataPack data) | ||||
| @ -860,14 +885,19 @@ public void SQL_OnQueryCompleted(Database db, DBResultSet results, const char[] | ||||
|         LogError("Query error 1: %s", error); | ||||
|         LogError("actual query: %s", sQuery); | ||||
|         delete data; | ||||
|         delete results; | ||||
|         return; | ||||
|     } | ||||
|     delete data; | ||||
|     int client;  | ||||
|     if ((client = GetClientFromSerial(client_serial)) == 0) | ||||
|     { | ||||
|         delete results; | ||||
|         return; | ||||
|     } | ||||
|     if (results.RowCount && results.FetchRow()) | ||||
|         results.FetchString(0, g_csTime_record[client], sizeof(g_csTime_record[])); | ||||
|     delete results; | ||||
| } | ||||
| 
 | ||||
| //---------------------------------------------------------------------------------------------------- | ||||
| @ -1027,7 +1057,10 @@ public void SQL_Select_Top_Callback(Database db, DBResultSet results, const char | ||||
|     delete data; | ||||
|     int iclient; | ||||
|     if ((iclient = GetClientFromSerial(client_serial)) == 0) | ||||
|     { | ||||
|         delete results; | ||||
|         return; | ||||
|     } | ||||
|     //Player Name | ||||
|     char[] g_cPlayerName = new char[MAX_NAME_LENGTH]; | ||||
|     char g_cContent[g_dLength]; | ||||
| @ -1060,6 +1093,7 @@ public void SQL_Select_Top_Callback(Database db, DBResultSet results, const char | ||||
|         menu.ExitButton = true; | ||||
|         menu.Display(iclient, 0); | ||||
|     } | ||||
|     delete results; | ||||
| } | ||||
| //---------------------------------------------------------------------------------------------------- | ||||
| // Purpose:  | ||||
| @ -1260,6 +1294,7 @@ public void SQL_CheckSelf(Database db, DBResultSet results, const char[] error, | ||||
|         LogError("Query error 4: %s", error);    | ||||
|         LogError("actual query: %s", sQuery); | ||||
|         delete data; | ||||
|         delete results; | ||||
|         return; | ||||
|     } | ||||
|     delete data; | ||||
| @ -1267,7 +1302,10 @@ public void SQL_CheckSelf(Database db, DBResultSet results, const char[] error, | ||||
|     char[] l_cPlayerName = new char[MAX_NAME_LENGTH]; | ||||
|     int iclient; | ||||
|     if ((iclient = GetClientFromSerial(client_serial)) == 0) | ||||
|     { | ||||
|         delete results; | ||||
|         return; | ||||
|     } | ||||
|     if (results.RowCount && results.FetchRow()) | ||||
|     { | ||||
|         results.FetchString(0, l_cPlayerName, MAX_NAME_LENGTH); | ||||
| @ -1275,6 +1313,7 @@ public void SQL_CheckSelf(Database db, DBResultSet results, const char[] error, | ||||
|         if (fTime == 0.0) | ||||
|         { | ||||
|             CPrintToChat(iclient, "You have no time yet!"); | ||||
|             delete results; | ||||
|             return; | ||||
|         } | ||||
|         fTime += 0.001; | ||||
| @ -1283,6 +1322,7 @@ public void SQL_CheckSelf(Database db, DBResultSet results, const char[] error, | ||||
|     } | ||||
|     else | ||||
|         CPrintToChat(iclient, "You have no time yet!"); | ||||
|     delete results; | ||||
| } | ||||
| 
 | ||||
| //---------------------------------------------------------------------------------------------------- | ||||
|  | ||||
| @ -62,7 +62,7 @@ public void SQL_addEntry(int client) | ||||
|     g_dDatabase.Escape(sName, sEscapedName, size2 + 1); | ||||
|     GetClientIP(client, sIP, sizeof(sIP)); | ||||
|     Format(sQuery, sizeof(sQuery), "insert into `ban_detector_steamids` (`steamid`, `name`, `ID`) SELECT '%s', '%s', bd.ID from `ban_detector` bd where bd.ip = '%s' and not exists (select bds.ID from `ban_detector_steamids` bds where bds.ID = bd.ID and bds.steamid = '%s')", sSID, sEscapedName, sIP, sSID); | ||||
|     g_dDatabase.Query(SQL_UpdateEntry, sQuery, client, DBPrio_Low); | ||||
|     g_dDatabase.Query(SQL_UpdateEntry, sQuery, GetClientSerial(client), DBPrio_Low); | ||||
| } | ||||
| 
 | ||||
| public void SQL_OnDatabaseConnect(Database db, const char[] error, any data) | ||||
| @ -86,11 +86,18 @@ public void SQL_OnDatabaseConnect_sb(Database db, const char[] error, any data) | ||||
| } | ||||
| 
 | ||||
| 
 | ||||
| public void SQL_UpdateEntry(Database db, DBResultSet results, const char[] error, int client) | ||||
| public void SQL_UpdateEntry(Database db, DBResultSet results, const char[] error, int Serial) | ||||
| { | ||||
|     if(!db || strlen(error)) | ||||
|     { | ||||
|         LogError("Database error: %s", error); | ||||
|         delete results; | ||||
|         return; | ||||
|     } | ||||
|     int client; | ||||
|     if ((client = GetClientFromSerial(Serial)) == 0) | ||||
|     { | ||||
|         delete results; | ||||
|         return; | ||||
|     } | ||||
|     if (IsValidClient(client)) | ||||
| @ -102,16 +109,28 @@ public void SQL_UpdateEntry(Database db, DBResultSet results, const char[] error | ||||
|         GetClientAuthId(client, AuthId_Steam2, sSID, sizeof(sSID)); | ||||
|         Format(sQuery, sizeof(sQuery), "SELECT bd.fingerprint FROM `ban_detector` bd inner join `ban_detector_steamids` bds on bd.ID = bds.ID where bds.steamid = '%s' or bd.ip = '%s'", sSID, sIP); | ||||
|         //PrintToChatAll("sQuery: %s", sQuery); | ||||
|         g_dDatabase.Query(SQL_FindFingerPrints, sQuery, client, DBPrio_Low); | ||||
|         g_dDatabase.Query(SQL_FindFingerPrints, sQuery, GetClientSerial(client), DBPrio_Low); | ||||
|     } | ||||
|     delete results; | ||||
| } | ||||
| 
 | ||||
| public void SQL_FindFingerPrints(Database db, DBResultSet results, const char[] error, int client) | ||||
| public void SQL_FindFingerPrints(Database db, DBResultSet results, const char[] error, int Serial) | ||||
| { | ||||
|     if (!db || strlen(error)) | ||||
|     { | ||||
|         LogError("Database error: %s", error); | ||||
|         delete results; | ||||
|         return; | ||||
|     } | ||||
|     int client; | ||||
|     if ((client = GetClientFromSerial(Serial)) == 0) | ||||
|     { | ||||
|         delete results; | ||||
|         return; | ||||
|     } | ||||
|     if (!IsValidClient(client)) | ||||
|     { | ||||
|         delete results; | ||||
|         return; | ||||
|     } | ||||
|     char fingerprint[1024]; | ||||
| @ -123,7 +142,7 @@ public void SQL_FindFingerPrints(Database db, DBResultSet results, const char[] | ||||
|         g_dDatabase.Escape(fingerprint, sEscapedFingerPrint, 1024); | ||||
|         Format(sQuery, sizeof(sQuery), "select steamid, ip from ban_detector bd inner join ban_detector_steamids bds on bd.ID = bds.ID where fingerprint = '%s'", sEscapedFingerPrint); | ||||
|         //PrintToChatAll("sQuery: %s", sQuery); | ||||
|         g_dDatabase.Query(SQL_checkSourcebans, sQuery, client, DBPrio_Low); | ||||
|         g_dDatabase.Query(SQL_checkSourcebans, sQuery, GetClientSerial(client), DBPrio_Low); | ||||
|         if (IsValidClient(client) && g_bReportedClientBanAvoiding[client]) | ||||
|         { | ||||
|             break; | ||||
| @ -132,14 +151,26 @@ public void SQL_FindFingerPrints(Database db, DBResultSet results, const char[] | ||||
|     delete results; | ||||
| } | ||||
| 
 | ||||
| public void SQL_checkSourcebans(Database db, DBResultSet results, const char[] error, int client) | ||||
| public void SQL_checkSourcebans(Database db, DBResultSet results, const char[] error, int Serial) | ||||
| { | ||||
|     if (!db || strlen(error)) | ||||
|     { | ||||
|         delete results; | ||||
|         LogError("Database error: %s", error); | ||||
|         return; | ||||
|     } | ||||
|      | ||||
|     int client; | ||||
|     if ((client = GetClientFromSerial(Serial)) == 0) | ||||
|     { | ||||
|         delete results; | ||||
|         return; | ||||
|     } | ||||
|     if (!IsValidClient(client)) | ||||
|     { | ||||
|         delete results; | ||||
|         return; | ||||
|     } | ||||
|     while (results.RowCount > 0 && results.FetchRow()) | ||||
|     { | ||||
|         char sSID[MAX_NAME_LENGTH]; | ||||
| @ -151,7 +182,7 @@ public void SQL_checkSourcebans(Database db, DBResultSet results, const char[] e | ||||
|         //PrintToChatAll(sIP); | ||||
|         // + 3600 for one hour to accomdate timezone difference | ||||
|         Format(sql_statement, sizeof(sql_statement), "select authid, ip from sb_bans where ((ip = '%s' and ip is not null and ip != '') or (authid = '%s' and authid is not null and authid =! '')) and (RemoveType != 'U' or RemoveType is NULL) and (ends > UNIX_TIMESTAMP() + 3600 or ends = created) order by created desc limit 1", sIP, sSID); | ||||
|         g_hDatabase_sourceban.Query(sql_select_sb_bans, sql_statement, client, DBPrio_Low); | ||||
|         g_hDatabase_sourceban.Query(sql_select_sb_bans, sql_statement, GetClientSerial(client), DBPrio_Low); | ||||
|         if (IsValidClient(client) && g_bReportedClientBanAvoiding[client]) | ||||
|         { | ||||
|             break; | ||||
| @ -160,14 +191,21 @@ public void SQL_checkSourcebans(Database db, DBResultSet results, const char[] e | ||||
|     delete results; | ||||
| } | ||||
| 
 | ||||
| public void sql_select_sb_bans(Database db, DBResultSet results, const char[] error, int client) | ||||
| public void sql_select_sb_bans(Database db, DBResultSet results, const char[] error, int Serial) | ||||
| { | ||||
|     if (!db || strlen(error)) | ||||
|     { | ||||
|         delete results; | ||||
|         LogError("Database error: %s", error); | ||||
|         return; | ||||
|     } | ||||
| 
 | ||||
|     int client; | ||||
|     if ((client = GetClientFromSerial(Serial)) == 0) | ||||
|     { | ||||
|         delete results; | ||||
|         return; | ||||
|     } | ||||
|     if (!IsValidClient(client)) | ||||
|     { | ||||
|         delete results; | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user