- if( reg->workshop_id == id ){
- reg->state = k_registry_board_state_indexed;
- goto next_file_workshop;
- }
- }
-
- /* new one, lets find out what type it is
- * ---------------------------------------------------------------*/
- vg_info( "new listing from the steam workshop!: "PRINTF_U64"\n", id );
- vg_async_item *call1 =
- vg_async_alloc( sizeof(struct async_workshop_filepath_info) );
-
- char path[ 4096 ];
-
- struct async_workshop_filepath_info *info = call1->payload;
- info->buf = path;
- info->id = id;
- info->len = vg_list_size(path);
- vg_async_dispatch( call1, async_workshop_get_filepath );
- vg_async_stall(); /* too bad! */
-
- vg_info( "%s\n", path );
- vg_str folder = {.buffer = path, .i=strlen(path), .len=4096};
- vg_str meta_path = folder;
- vg_strcat( &meta_path, "/addon.inf" );
- if( !vg_strgood( &meta_path ) ){
- vg_error( "The metadata path is too long\n" );
- goto next_file_workshop;
- }
-
- u8 meta[512];
- FILE *fp = fopen( meta_path.buffer, "rb" );
- if( !fp ){
- vg_error( "Could not open the '%s'\n", meta_path.buffer );
- goto next_file_workshop;
- }
-
- u32 l = fread( meta, 1, 512, fp );
- if( l != 512 ){
- if( !feof(fp) ){
- fclose(fp);
- vg_error( "unknown error codition" );
- goto next_file_workshop;
- }
- }
- fclose(fp);
-
- enum workshop_file_type type = k_workshop_file_type_none;
- vg_msg msg;
- vg_msg_init( &msg, meta, l );
-
- vg_msg_cmd cmd;
- while( vg_msg_next( &msg, &cmd ) ){
- if( (msg.depth == 1) && (cmd.code == k_vg_msg_code_frame) ){
- if( VG_STRDJB2_EQ( "workshop", cmd.key, cmd.key_djb2 ) ){
- u32 depth = msg.depth;
- while( (msg.depth == depth) && vg_msg_next( &msg, &cmd ) ){
- if( cmd.code & k_vg_msg_code_unsigned ){
- if( VG_STRDJB2_EQ( "type", cmd.key, cmd.key_djb2 ) ){
- type = cmd.value._u32;
- }
- }
- }
- }
- }
- }
-
- if( type == k_workshop_file_type_none ){
- vg_error( "Cannot determine addon type\n" );
- goto next_file_workshop;
- }
-
- /* now that we have the type
- * ------------------------------------------------------------------*/
-
- if( type == k_workshop_file_type_board ){
- if( global_skateshop.t1_registry_count == SKATESHOP_REGISTRY_MAX ){
- vg_error( "You have too many boards installed!\n" );
- goto next_file_workshop;
- }
-
- struct registry_board *reg = &global_skateshop.registry[
- global_skateshop.t1_registry_count ++ ];
-
- reg->cache_ptr = NULL;
- snprintf( reg->foldername, 64, PRINTF_U64, id );
- reg->foldername_hash = vg_strdjb2( reg->foldername );
- reg->workshop_id = id;
- reg->state = k_registry_board_state_indexed;
- }
- else if( type == k_workshop_file_type_world ){
- if( global_skateshop.t1_world_registry_count == SKATESHOP_WORLDS_MAX ){
- vg_error( "You have too many worlds installed!\n" );
- goto next_file_workshop;
- }
-
- struct registry_world *reg = &global_skateshop.world_registry[
- global_skateshop.t1_world_registry_count ++ ];
-
- snprintf( reg->foldername, 64, PRINTF_U64, id );
- reg->foldername_hash = vg_strdjb2( reg->foldername );
- reg->type = k_world_load_type_workshop;
- reg->workshop_id = id;
- reg->state = k_registry_board_state_indexed;
- }
-
-next_file_workshop:;