+VG_STATIC void workshop_steam_scan(void)
+{
+ /*
+ * Steam workshop scan
+ */
+ vg_info( "Scanning steam workshop for boards\n" );
+ PublishedFileId_t workshop_ids[ SKATESHOP_REGISTRY_MAX ];
+ u32 workshop_count = SKATESHOP_REGISTRY_MAX;
+
+ vg_async_item *call = vg_async_alloc(
+ sizeof(struct async_workshop_installed_files_info));
+ struct async_workshop_installed_files_info *info = call->payload;
+ info->buffer = workshop_ids;
+ info->len = &workshop_count;
+ vg_async_dispatch( call, async_workshop_get_installed_files );
+ vg_async_stall();
+
+ for( u32 j=0; j<workshop_count; j++ ){
+ PublishedFileId_t id = workshop_ids[j];
+
+ for( u32 i=0; i<global_skateshop.t1_registry_count; i++ ){
+ struct registry_board *reg = &global_skateshop.registry[i];
+
+ if( reg->workshop_id == id ){
+ reg->state = k_registry_board_state_indexed;
+ goto next_file_workshop;
+ }
+ }
+
+ if( global_skateshop.t1_registry_count == SKATESHOP_REGISTRY_MAX ){
+ vg_error( "You have too many boards installed!\n" );
+ break;
+ }
+
+ vg_info( "new listing from the steam workshop!: "PRINTF_U64"\n", id );
+
+ struct registry_board *reg = &global_skateshop.registry[
+ global_skateshop.t1_registry_count ++ ];
+
+ reg->cache_ptr = NULL;
+ snprintf( reg->filename, 64, PRINTF_U64, id );
+ reg->filename_hash = vg_strdjb2( reg->filename );
+ reg->workshop_id = id;
+ reg->state = k_registry_board_state_indexed;
+
+ workshop_file_info_clear( ®->workshop );
+ strcpy( reg->workshop.title, "Workshop file" );
+
+ /* load the metadata off the disk */
+ vg_async_item *call =
+ vg_async_alloc( sizeof(struct async_workshop_filepath_info) );
+
+ const char *meta_file = "/board.mdl.inf";
+ char path[ 1024 ];
+ struct async_workshop_filepath_info *info = call->payload;
+ info->buf = path;
+ info->id = reg->workshop_id;
+ info->len = vg_list_size(path) - strlen(meta_file)-1;
+ vg_async_dispatch( call, async_workshop_get_filepath );
+ vg_async_stall(); /* too bad! */
+
+ strcat( path, meta_file );
+ workshop_load_metadata( path, ®->workshop );
+
+next_file_workshop:;
+ }
+}
+