-/*
- * 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];
-
- /* boards */
- struct addon_cache *cache = &addon_system.cache[k_workshop_file_type_board];
-
- for( u32 id=1; id<=cache->pool.count; id++ ){
- addon_cache_entry *entry = vg_pool_item( &cache->pool, id );
- struct player_board *board =
- addon_cache_item( k_workshop_file_type_board, id );
-
- SDL_AtomicLock( &addon_system.sl_cache_using_resources );
- if( entry->state == k_addon_cache_state_load_request ){
- vg_info( "process cache load request (type:%u#%u, reg:%u)\n",
- k_workshop_file_type_board, id, entry->reg_index );
-
- if( entry->reg_index >= addon_count(k_workshop_file_type_board) ){
- /* should maybe have a different value for this case */
- entry->state = k_addon_cache_state_none;
- SDL_AtomicUnlock( &addon_system.sl_cache_using_resources );
- continue;
- }
-
- SDL_AtomicUnlock( &addon_system.sl_cache_using_resources );
-
- /* continue with the request */
- addon_reg *reg = get_addon_from_index( k_workshop_file_type_board,
- entry->reg_index );
- entry->reg_ptr = reg;
-
- vg_str folder;
- vg_strnull( &folder, path_buf, 4096 );
- if( !addon_get_content_folder( reg, &folder ) )
- goto file_is_broken;
-
-
- /* load content files
- * --------------------------------- */
- vg_str content_path = folder;
-
- vg_msg root = {0};
- root.buf = reg->metadata;
- root.len = reg->metadata_len;
- root.max = sizeof(reg->metadata);
-
- 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( board, content_path.buffer );
-
- /* WELL DONE */
- vg_async_stall();
-
- SDL_AtomicLock( &addon_system.sl_cache_using_resources );
- entry->state = k_addon_cache_state_loaded;
- SDL_AtomicUnlock( &addon_system.sl_cache_using_resources );
-
- vg_success( " loaded (%s)\n", entry->reg_ptr->foldername );
- continue;
-
-file_is_broken:;
- SDL_AtomicLock( &addon_system.sl_cache_using_resources );
- entry->state = k_addon_cache_state_none;
- SDL_AtomicUnlock( &addon_system.sl_cache_using_resources );
- }
- else
- SDL_AtomicUnlock( &addon_system.sl_cache_using_resources );
- }
-}
-
-