@@ -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,13 @@ 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+ // Waiting a frame fixed "Lost connection" error for me...
227+ // maybe it was a random thing, but I'll keep it for now.
228+ RequestFrame (StartLoadingPlayerStuff );
229+ return ;
230+ }
227231 }
228232
229233 CheckDatabaseForUpdates ();
@@ -387,6 +391,11 @@ public void SQLCleanUpTables(Handle owner, Handle hndl, const char[] error, any
387391 }
388392}
389393
394+ public void StartLoadingPlayerStuff ()
395+ {
396+ SelectPlayersStuff ();
397+ }
398+
390399void SelectPlayersStuff ()
391400{
392401 Transaction tTransaction = new Transaction ();
@@ -424,10 +433,11 @@ void SelectPlayersStuff()
424433
425434public void SQLTxn_GetPlayerDataSuccess (Database db , any data , int numQueries , DBResultSet [] results , any [] queryData )
426435{
436+ int iQueries = 0 ;
437+ Transaction tTransaction = new Transaction ();
438+
427439 for (int i = 0 ; i < numQueries ; i ++ )
428440 {
429- int iQueries = 0 ;
430- Transaction tTransaction = new Transaction ();
431441 char sSteamId2 [32 ], sName [64 ], sSteamId64 [128 ], sQuery [1024 ];
432442 // ck_bonus
433443 if (g_sSteamIdTablesCleanup [i ][3 ] == ' b' )
@@ -561,15 +571,17 @@ public void SQLTxn_GetPlayerDataSuccess(Database db, any data, int numQueries, D
561571 }
562572 }
563573
564- if (iQueries == 0 )
565- {
566- delete tTransaction ;
567- continue ;
568- }
574+ PrintToServer (" Added %d Queries to Transaction for table %s " , iQueries , g_sSteamIdTablesCleanup [i ]);
575+ }
569576
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 );
577+ if (iQueries == 0 )
578+ {
579+ CheckDatabaseForUpdates ();
580+ return ;
572581 }
582+
583+ PrintToServer (" Transaction started with %d queries started..." , iQueries );
584+ SQL_ExecuteTransaction (g_hDb , tTransaction , SQLTxn_InsertToPlayersSuccess , SQLTxn_InsertToPlayersFailed , .priority = DBPrio_High );
573585}
574586
575587public void SQLTxn_InsertToPlayersSuccess (Database db , any data , int numQueries , DBResultSet [] results , any [] queryData )
@@ -580,13 +592,19 @@ public void SQLTxn_InsertToPlayersSuccess(Database db, any data, int numQueries,
580592public void SQLTxn_InsertToPlayersFailed (Database db , any data , int numQueries , const char [] error , int failIndex , any [] queryData )
581593{
582594 SQL_FastQuery (g_hDb , " DROP TABLE IF EXISTS ck_players;" );
583-
595+
584596 SetFailState (" [SurfTimer] Failed while adding data to table ck_players! Error: %s " , error );
585597}
586598
587599public void SQLTxn_GetPlayerDataFailed (Database db , any data , int numQueries , const char [] error , int failIndex , any [] queryData )
588600{
589601 SQL_FastQuery (g_hDb , " DROP TABLE IF EXISTS ck_players;" );
590-
602+
603+ if (failIndex == - 1 )
604+ {
605+ SetFailState (" [SurfTimer] Failed while getting data! Error: %s " , error );
606+ return ;
607+ }
608+
591609 SetFailState (" [SurfTimer] Failed while getting data from table %s ! Error: %s " , g_sSteamIdTablesCleanup [failIndex ], error );
592610}
0 commit comments