-/*
- * 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];
-
- 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 );
-
- vg_str folder;
- vg_strnull( &folder, path_buf, 4096 );
- if( !addon_get_content_folder( cache_ptr->reg_ptr, &folder ) )
- goto file_is_broken;
-
-
- /* 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 );
- }
-}
-
-