@@ -99,12 +99,11 @@ void CheckDatabaseForUpdates()
99
99
delete results ;
100
100
return ;
101
101
}
102
-
103
102
// Version 13 - End
104
103
105
104
if (! SQL_FastQuery (g_hDb , " SELECT accountid FROM ck_players LIMIT 1" ))
106
105
{
107
- db_upgradeDatabase (14 );
106
+ db_upgradeDatabase (14 , true );
108
107
return ;
109
108
}
110
109
@@ -222,8 +221,13 @@ void db_upgradeDatabase(int ver, bool skipErrorCheck = false)
222
221
}
223
222
else if (ver == 14 )
224
223
{
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
+ }
227
231
}
228
232
229
233
CheckDatabaseForUpdates ();
@@ -387,6 +391,11 @@ public void SQLCleanUpTables(Handle owner, Handle hndl, const char[] error, any
387
391
}
388
392
}
389
393
394
+ public void StartLoadingPlayerStuff ()
395
+ {
396
+ SelectPlayersStuff ();
397
+ }
398
+
390
399
void SelectPlayersStuff ()
391
400
{
392
401
Transaction tTransaction = new Transaction ();
@@ -424,10 +433,11 @@ void SelectPlayersStuff()
424
433
425
434
public void SQLTxn_GetPlayerDataSuccess (Database db , any data , int numQueries , DBResultSet [] results , any [] queryData )
426
435
{
436
+ int iQueries = 0 ;
437
+ Transaction tTransaction = new Transaction ();
438
+
427
439
for (int i = 0 ; i < numQueries ; i ++ )
428
440
{
429
- int iQueries = 0 ;
430
- Transaction tTransaction = new Transaction ();
431
441
char sSteamId2 [32 ], sName [64 ], sSteamId64 [128 ], sQuery [1024 ];
432
442
// ck_bonus
433
443
if (g_sSteamIdTablesCleanup [i ][3 ] == ' b' )
@@ -561,15 +571,17 @@ public void SQLTxn_GetPlayerDataSuccess(Database db, any data, int numQueries, D
561
571
}
562
572
}
563
573
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
+ }
569
576
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 ;
572
581
}
582
+
583
+ PrintToServer (" Transaction started with %d queries started..." , iQueries );
584
+ SQL_ExecuteTransaction (g_hDb , tTransaction , SQLTxn_InsertToPlayersSuccess , SQLTxn_InsertToPlayersFailed , .priority = DBPrio_High );
573
585
}
574
586
575
587
public 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,
580
592
public void SQLTxn_InsertToPlayersFailed (Database db , any data , int numQueries , const char [] error , int failIndex , any [] queryData )
581
593
{
582
594
SQL_FastQuery (g_hDb , " DROP TABLE IF EXISTS ck_players;" );
583
-
595
+
584
596
SetFailState (" [SurfTimer] Failed while adding data to table ck_players! Error: %s " , error );
585
597
}
586
598
587
599
public void SQLTxn_GetPlayerDataFailed (Database db , any data , int numQueries , const char [] error , int failIndex , any [] queryData )
588
600
{
589
601
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
+
591
609
SetFailState (" [SurfTimer] Failed while getting data from table %s ! Error: %s " , g_sSteamIdTablesCleanup [failIndex ], error );
592
610
}
0 commit comments