+static void world_sfd_compile_scores( struct leaderboard_cache *board ){
+ for( u32 i=0; i<13; i++ )
+ sfd_encode( i, "" );
+
+ if( !board ){
+ sfd_encode( 4, "Error out of range" );
+ return;
+ }
+
+ if( !network_connected() ){
+ sfd_encode( 4, "Offline" );
+ return;
+ }
+
+ if( board->status == k_request_status_not_found ){
+ sfd_encode( 4, "No records" );
+ return;
+ }
+
+ if( board->status != k_request_status_ok ){
+ char buf[32];
+ vg_str s;
+ vg_strnull( &s, buf, 32 );
+ vg_strcat( &s, "Error: " );
+ vg_strcati32( &s, board->status );
+ sfd_encode( 4, buf );
+ return;
+ }
+
+ vg_msg body;
+ vg_msg_init( &body, board->data, board->data_len );
+
+ const char *alias = "rows";
+
+ if( world_sfd.view_weekly ){
+ alias = "rows_weekly";
+ sfd_encode( 0, "Weekly" );
+ }
+ else {
+ sfd_encode( 0, "All-Time" );
+ }
+
+ u32 l = 1;
+ if( vg_msg_seekframe( &body, alias ) ){
+ while( vg_msg_seekframe( &body, NULL ) ){
+ const char *username = vg_msg_getkvstr( &body, "username" );
+
+ if( username )
+ sfd_encode( l ++, username );
+ else
+ sfd_encode( l ++, "UNKNOWN USER" );
+
+ vg_msg_skip_frame( &body );
+ }
+ }
+ else {
+ sfd_encode( 4, "No records" );
+ }
+}
+
+static void world_sfd_compile_active_scores(void){
+ world_instance *world = world_current_instance();
+
+ struct leaderboard_cache *board = NULL;
+
+ if( world_sfd.active_route_board < mdl_arrcount( &world->ent_route ) )
+ board = &world->leaderboard_cache[ world_sfd.active_route_board ];
+
+ world_sfd_compile_scores( board );
+}
+