From d2ef8267909ec50130a67c8925ab58a23ca8b8f4 Mon Sep 17 00:00:00 2001 From: Christian Date: Mon, 8 Mar 2021 21:47:50 +0100 Subject: [PATCH] cleaning datapacks and database connections and adding check for fakeclients --- RaceTimer/scripting/unloze_racetimer_redux.sp | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/RaceTimer/scripting/unloze_racetimer_redux.sp b/RaceTimer/scripting/unloze_racetimer_redux.sp index e08e38b9..5f3dad40 100644 --- a/RaceTimer/scripting/unloze_racetimer_redux.sp +++ b/RaceTimer/scripting/unloze_racetimer_redux.sp @@ -146,6 +146,7 @@ public void SQL_FinishedQuery(Database db, DBResultSet results, const char[] err LogError("Query error 3: %s", error); LogError("actual query: %s", sQuery); } + delete data; } public void OnMapStart() @@ -153,6 +154,12 @@ public void OnMapStart() Database.Connect(SQL_OnDatabaseConnect, "racetimercss"); } +public void OnMapEnd() +{ + if (g_dDatabase != null) + delete g_dDatabase; +} + //---------------------------------------------------------------------------------------------------- // Purpose: //---------------------------------------------------------------------------------------------------- @@ -191,7 +198,7 @@ public void Event_RoundStart(Handle event, const char[] name, bool dontBroadcast if (!l_iZoneCount) return; for (int i = 1; i <= MaxClients; i++) - if (IsValidClient(i)) + if (IsValidClient(i) && !IsFakeClient(i)) { resetClientVectors(i); if (l_iZoneCount != 1) @@ -556,8 +563,10 @@ public void SQL_OnQueryCompleted(Database db, DBResultSet results, const char[] data.ReadString(sQuery, sizeof(sQuery)); LogError("Query error 1: %s", error); LogError("actual query: %s", sQuery); + delete data; return; } + delete data; int client; if ((client = GetClientFromSerial(client_serial)) == 0) return; @@ -654,9 +663,10 @@ public void SQL_Select_Top_Callback(Database db, DBResultSet results, const char data.ReadString(sQuery, sizeof(sQuery)); LogError("Query error 2: %s", error); LogError("actual query: %s", sQuery); + delete data; return; } - + delete data; int iclient; if ((iclient = GetClientFromSerial(client_serial)) == 0) return; @@ -884,8 +894,10 @@ public void SQL_CheckSelf(Database db, DBResultSet results, const char[] error, data.ReadString(sQuery, sizeof(sQuery)); LogError("Query error 4: %s", error); LogError("actual query: %s", sQuery); + delete data; return; } + delete data; char sTime[g_dLength]; char l_cMessageContent[g_dLength]; char[] l_cPlayerName = new char[MAX_NAME_LENGTH];