- 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! */
+ 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;
+ }