-static void highscores_free(void)
-{
- free( highscore_system.data );
-}
-
-static aatree_ptr highscores_push_record( highscore_record *record )
-{
- struct highscore_system *sys = &highscore_system;
-
- /* TODO: Verify steam ID */
- vg_log( "Inserting record into database for track %hu\n",record->trackid );
-
- if( record->trackid >= vg_list_size(sys->dbheader.tracks) )
- {
- vg_error( "TrackID out of range (%hu>=%d)\n", record->trackid,
- vg_list_size(sys->dbheader.tracks) );
-
- return AATREE_PTR_NIL;
- }
-
- /* Search for existing record on this track */
- highscore_track_table *table = &sys->dbheader.tracks[record->trackid];
- aatree_ptr existing = aatree_find( &sys->aainfo_playerid,
- table->root_playerid,
- record );
-
- if( existing != AATREE_PTR_NIL )
- {
- vg_log( "Freeing existing record for player %lu\n", record->playerid );
- table->root_playerid = aatree_del( &sys->aainfo_playerid, existing );
- table->root_datetime = aatree_del( &sys->aainfo_datetime, existing );
- table->root_points = aatree_del( &sys->aainfo_points, existing );
- table->root_time = aatree_del( &sys->aainfo_time, existing );
-
- aatree_pool_free( &sys->aainfo, existing, &sys->dbheader.pool_head );
- }
-
- aatree_ptr index =
- aatree_pool_alloc( &sys->aainfo, &sys->dbheader.pool_head );
-
- if( index == AATREE_PTR_NIL )
- return index;
-
- highscore_record *dst = aatree_get_data( &sys->aainfo, index );
- memset( dst, 0, sizeof(highscore_record) );
-
- dst->trackid = record->trackid;
- dst->datetime = record->datetime;
- dst->playerid = record->playerid;
- dst->points = record->points;
- dst->time = record->time;
-
- table->root_time =
- aatree_insert( &sys->aainfo_time, table->root_time, index );
- table->root_datetime =
- aatree_insert( &sys->aainfo_datetime, table->root_datetime, index );
- table->root_playerid =
- aatree_insert( &sys->aainfo_playerid, table->root_playerid, index );
- table->root_points =
- aatree_insert( &sys->aainfo_points, table->root_points, index );
-
- return index;
-}
-
-static void _highscore_showtime( void *data )
-{
- highscore_record *record = data;
- printf( "%hu", record->time );
-}
-
-static void highscores_print_track( u32 trackid, u32 count )
-{
- struct highscore_system *sys = &highscore_system;
-
- highscore_track_table *table = &sys->dbheader.tracks[ trackid ];
- aatree_ptr it = aatree_kth( &sys->aainfo_time, table->root_time, 0 );
-
- vg_info( "Highscores, top %u records for track %u\n", count, trackid );
- vg_info( "==============================================\n" );
-
- int i=0;
- while( it != AATREE_PTR_NIL && i < 10 )
- {
- highscore_record *record = aatree_get_data( &sys->aainfo_time, it );
- vg_info( " [%d]: player(%lu), time: %hu, score: %hu, track:%hu\n",
- i+1, record->playerid, record->time, record->points,
- record->trackid );
-
- i++;
- it = aatree_next( &sys->aainfo_time, it );
- }
-
- vg_info( "==============================================\n" );
-}
+static int highscore_intr( char *buf, int value, int len, char alt );
+static int highscore_intl( char *buf, int value, int len );
+static void highscores_board_printf( FILE *fp, const char *buf, u32 count );
+static aatree_ptr highscore_set_user_nickname( u64 steamid, char nick[16] );
+static aatree_ptr highscores_push_record( highscore_record *record );
+static void highscores_board_generate( char *buf, u32 id, u32 count );
+static void highscores_init( u32 pool_size, u32 playerinfo_pool_size );
+static int highscores_read( const char *path );
+static void highscores_create_db(void);
+static int highscores_serialize_all(void);