@@ -99,12 +99,11 @@ void CheckDatabaseForUpdates()
9999 delete results ;
100100 return ;
101101 }
102-
103102 // Version 13 - End
104103
105104 if (! SQL_FastQuery (g_hDb , " SELECT accountid FROM ck_players LIMIT 1" ))
106105 {
107- db_upgradeDatabase (14 );
106+ db_upgradeDatabase (14 , true );
108107 return ;
109108 }
110109
@@ -222,8 +221,11 @@ void db_upgradeDatabase(int ver, bool skipErrorCheck = false)
222221 }
223222 else if (ver == 14 )
224223 {
225- SQL_FastQuery (g_hDb , sql_createPlayers );
226- SelectPlayersStuff ();
224+ if (SQL_FastQuery (g_hDb , sql_createPlayers ))
225+ {
226+ RequestFrame (StartLoadingPlayerStuff );
227+ return ;
228+ }
227229 }
228230
229231 CheckDatabaseForUpdates ();
@@ -387,6 +389,11 @@ public void SQLCleanUpTables(Handle owner, Handle hndl, const char[] error, any
387389 }
388390}
389391
392+ public void StartLoadingPlayerStuff ()
393+ {
394+ SelectPlayersStuff ();
395+ }
396+
390397void SelectPlayersStuff ()
391398{
392399 Transaction tTransaction = new Transaction ();
@@ -424,10 +431,11 @@ void SelectPlayersStuff()
424431
425432public void SQLTxn_GetPlayerDataSuccess (Database db , any data , int numQueries , DBResultSet [] results , any [] queryData )
426433{
434+ int iQueries = 0 ;
435+ Transaction tTransaction = new Transaction ();
436+
427437 for (int i = 0 ; i < numQueries ; i ++ )
428438 {
429- int iQueries = 0 ;
430- Transaction tTransaction = new Transaction ();
431439 char sSteamId2 [32 ], sName [64 ], sSteamId64 [128 ], sQuery [1024 ];
432440 // ck_bonus
433441 if (g_sSteamIdTablesCleanup [i ][3 ] == ' b' )
@@ -561,15 +569,17 @@ public void SQLTxn_GetPlayerDataSuccess(Database db, any data, int numQueries, D
561569 }
562570 }
563571
564- if (iQueries == 0 )
565- {
566- delete tTransaction ;
567- continue ;
568- }
572+ PrintToServer (" Added %d Queries to Transaction for table %s " , iQueries , g_sSteamIdTablesCleanup [i ]);
573+ }
569574
570- PrintToServer (" Transaction for %s with %d queries started..." , g_sSteamIdTablesCleanup [i ], iQueries );
571- SQL_ExecuteTransaction (g_hDb , tTransaction , SQLTxn_InsertToPlayersSuccess , SQLTxn_InsertToPlayersFailed , .priority = DBPrio_High );
575+ if (iQueries == 0 )
576+ {
577+ CheckDatabaseForUpdates ();
578+ return ;
572579 }
580+
581+ PrintToServer (" Transaction started with %d queries started..." , iQueries );
582+ SQL_ExecuteTransaction (g_hDb , tTransaction , SQLTxn_InsertToPlayersSuccess , SQLTxn_InsertToPlayersFailed , .priority = DBPrio_High );
573583}
574584
575585public void SQLTxn_InsertToPlayersSuccess (Database db , any data , int numQueries , DBResultSet [] results , any [] queryData )
@@ -580,13 +590,19 @@ public void SQLTxn_InsertToPlayersSuccess(Database db, any data, int numQueries,
580590public void SQLTxn_InsertToPlayersFailed (Database db , any data , int numQueries , const char [] error , int failIndex , any [] queryData )
581591{
582592 SQL_FastQuery (g_hDb , " DROP TABLE IF EXISTS ck_players;" );
583-
593+
584594 SetFailState (" [SurfTimer] Failed while adding data to table ck_players! Error: %s " , error );
585595}
586596
587597public void SQLTxn_GetPlayerDataFailed (Database db , any data , int numQueries , const char [] error , int failIndex , any [] queryData )
588598{
589599 SQL_FastQuery (g_hDb , " DROP TABLE IF EXISTS ck_players;" );
590-
600+
601+ if (failIndex == - 1 )
602+ {
603+ SetFailState (" [SurfTimer] Failed while getting data! Error: %s " , error );
604+ return ;
605+ }
606+
591607 SetFailState (" [SurfTimer] Failed while getting data from table %s ! Error: %s " , g_sSteamIdTablesCleanup [failIndex ], error );
592608}
0 commit comments