add sqlite and use it
[carveJwlIkooP6JGAAIwe30JlM.git] / gameserver.c
index efc0bbfa72fde60adf25d95e93e5eb7ebf061279..3b58b2360fda202c502d40a4c142849d200fdd8a 100644 (file)
@@ -9,15 +9,16 @@
 
 volatile sig_atomic_t sig_stop;
 
-static void inthandler( int signum ) {
-   sig_stop = 1;
-}
-
 #include "gameserver.h" 
 #include "highscores.c"
 #include "servermonitor_server.c"
 #include "vg/vg_opt.h"
 #include "network_common.h"
+#include "gameserver_db.h"
+
+static void inthandler( int signum ) {
+   sig_stop = 1;
+}
 
 static const u64 k_connection_unauthorized = 0xffffffffffffffff;
 
@@ -524,6 +525,19 @@ static void generate_boards(void){
 }
 
 int main( int argc, char *argv[] ){
+   db_init();
+   char table[DB_TABLE_UID_MAX];
+   if( db_get_highscore_table_name( "sr003-local-mp_mtzero", 
+                                    "megapark-yellow", 302, table ) ){
+      if( db_writeusertime( table, 76561198072130043, 232, 1 ) ){
+         vg_success( "Written time\n" );
+         i32 v = db_readusertime( table, 76561198072130043 );
+         vg_success( "Returned time: %u\n", v );
+      }
+   }
+   db_free();
+   return 0;
+
    signal( SIGINT, inthandler );
    signal( SIGQUIT, inthandler );
    signal( SIGPIPE, SIG_IGN );
@@ -541,7 +555,7 @@ int main( int argc, char *argv[] ){
 
    highscores_init( 250000, 10000 );
    
-   if( !highscores_read() )
+   if( !highscores_read(NULL) )
       highscores_create_db();
 
    steamworks_ensure_txt( "2103940" );
@@ -639,6 +653,7 @@ int main( int argc, char *argv[] ){
    
    vg_info( "Shutting down\n..." );
    SteamGameServer_Shutdown();
+   db_free();
 
    return 0;
 }