-/*
- * Reciever for board completion; only promotes the status in the main thread
- */
-VG_STATIC void skateshop_async_board_loaded( void *payload, u32 size )
-{
- SDL_AtomicLock( &global_skateshop.sl_cache_access );
- struct cache_board *cache_ptr = payload;
- cache_ptr->last_use_time = vg.time;
- cache_ptr->state = k_cache_board_state_loaded;
-
- cache_ptr->reg_ptr->userdata = cache_ptr;
- SDL_AtomicUnlock( &global_skateshop.sl_cache_access );
- vg_success( "Async board loaded (%s)\n", cache_ptr->reg_ptr->foldername );
-}
-
-/*
- * Thread(or subroutine of thread), for checking view slots that weve installed.
- * Load the model if a view slot wants it
- */
-VG_STATIC void workshop_visibile_load_loop(void)
-{
- vg_info( "Running load loop\n" );
- char path_buf[4096];
- vg_str folder;
-
- for( u32 i=0; i<SKATESHOP_BOARD_CACHE_MAX; i++ ){
- struct cache_board *cache_ptr = &global_skateshop.cache[i];
-
- SDL_AtomicLock( &global_skateshop.sl_cache_access );
- if( cache_ptr->state == k_cache_board_state_load_request ){
- if( cache_ptr->reg_index >= addon_count(k_workshop_file_type_board) ){
- /* should maybe have a different value for this case */
- cache_ptr->state = k_cache_board_state_none;
- SDL_AtomicUnlock( &global_skateshop.sl_cache_access );
- continue;
- }
-
- /* continue with the request */
- SDL_AtomicUnlock( &global_skateshop.sl_cache_access );
-
- cache_ptr->reg_ptr = get_addon_from_index( k_workshop_file_type_board,
- cache_ptr->reg_index );
-
- if( cache_ptr->reg_ptr->workshop_id ){
- vg_async_item *call =
- vg_async_alloc( sizeof(struct async_workshop_filepath_info) );
-
- struct async_workshop_filepath_info *info = call->payload;
- info->buf = path_buf;
- info->id = cache_ptr->reg_ptr->workshop_id;
- info->len = vg_list_size(path_buf);
- vg_async_dispatch( call, async_workshop_get_filepath );
- vg_async_stall(); /* too bad! */
-
- if( path_buf[0] == '\0' ){
- vg_error( "Failed SteamAPI_GetItemInstallInfo(" PRINTF_U64 ")\n",
- cache_ptr->reg_ptr->workshop_id );
- goto file_is_broken;
- }
-
- folder.buffer = path_buf;
- folder.i = strlen(path_buf);
- folder.len = 4096;
- }
- else{
- vg_strnull( &folder, path_buf, 4096 );
- vg_strcat( &folder, "boards/" );
- vg_strcat( &folder, cache_ptr->reg_ptr->foldername );
- }
-
- /* load content files
- * --------------------------------- */
-
- vg_str content_path = folder;
-
- vg_msg root;
- vg_msg_init( &root, cache_ptr->reg_ptr->metadata,
- cache_ptr->reg_ptr->metadata_len );
-
- const char *kv_content = vg_msg_seekkvstr( &root, "content", 0 );
- if( kv_content ){
- vg_strcat( &content_path, "/" );
- vg_strcat( &content_path, kv_content );
- }
- else{
- vg_error( "No content paths in metadata\n" );
- goto file_is_broken;
- }
-
- if( !vg_strgood( &content_path ) ) {
- vg_error( "Metadata path too long\n" );
- goto file_is_broken;
- }
-
- vg_info( "Load content: %s\n", content_path.buffer );
- player_board_load( &cache_ptr->board, content_path.buffer );
- vg_async_call( skateshop_async_board_loaded, cache_ptr, 0 );
- continue;
-
-file_is_broken:;
- SDL_AtomicLock( &global_skateshop.sl_cache_access );
- cache_ptr->state = k_cache_board_state_none;
- SDL_AtomicUnlock( &global_skateshop.sl_cache_access );
- }
- else
- SDL_AtomicUnlock( &global_skateshop.sl_cache_access );
- }
-}
-
-